forked from pool/multipath-tools
205 lines
5.9 KiB
Plaintext
205 lines
5.9 KiB
Plaintext
From 27ec49eca021f1cc85e66d55509f1e051a820bd4 Mon Sep 17 00:00:00 2001
|
|
From: Christophe Varoqui <christophe.varoqui@free.fr>
|
|
Date: Mon, 29 Sep 2008 01:37:02 +0200
|
|
Subject: [PATCH] [multipathd] add "show wildcards" cli command
|
|
|
|
The fact I had to look at the code to find the wildcards to use
|
|
in "show paths format ...", "show multipath format ..." and
|
|
"show pathgroup format ..." was a clear sign that more help was
|
|
necessary.
|
|
|
|
The "show wildcards" command outputs :
|
|
|
|
multipath format wildcards:
|
|
%n name
|
|
%w uuid
|
|
%d sysfs
|
|
%F failback
|
|
%Q queueing
|
|
%N paths
|
|
%r write_prot
|
|
%t dm-st
|
|
%S size
|
|
%f features
|
|
%h hwhandler
|
|
%A action
|
|
%0 path_faults
|
|
%1 switch_grp
|
|
%2 map_loads
|
|
%3 total_q_time
|
|
%4 q_timeouts
|
|
%s vend/prod/rev
|
|
|
|
path format wildcards:
|
|
%w uuid
|
|
%i hcil
|
|
%d dev
|
|
%D dev_t
|
|
%t dm_st
|
|
%T chk_st
|
|
%s vend/prod/rev
|
|
%C next_check
|
|
%p pri
|
|
%S size
|
|
|
|
pathgroup format wildcards:
|
|
%s selector
|
|
%p pri
|
|
%t dm_st
|
|
|
|
And for example, "show paths format foo:%d:%S:%i", outs
|
|
|
|
foo:dev:size:hcil
|
|
foo:sda:149G:2:0:0:0
|
|
---
|
|
libmultipath/print.c | 21 +++++++++++++++++++++
|
|
libmultipath/print.h | 1 +
|
|
multipathd/cli.c | 2 ++
|
|
multipathd/cli.h | 2 ++
|
|
multipathd/cli_handlers.c | 17 +++++++++++++++++
|
|
multipathd/cli_handlers.h | 1 +
|
|
multipathd/main.c | 1 +
|
|
7 files changed, 45 insertions(+), 0 deletions(-)
|
|
|
|
diff --git a/libmultipath/print.c b/libmultipath/print.c
|
|
index 7411ccc..09b3579 100644
|
|
--- a/libmultipath/print.c
|
|
+++ b/libmultipath/print.c
|
|
@@ -436,8 +436,29 @@ struct pathgroup_data pgd[] = {
|
|
{'s', "selector", 0, snprint_pg_selector},
|
|
{'p', "pri", 0, snprint_pg_pri},
|
|
{'t', "dm_st", 0, snprint_pg_state},
|
|
+ {0, NULL, 0 , NULL}
|
|
};
|
|
|
|
+int
|
|
+snprint_wildcards (char * buff, int len)
|
|
+{
|
|
+ int i, fwd = 0;
|
|
+
|
|
+ fwd += snprintf(buff + fwd, len - fwd, "multipath format wildcards:\n");
|
|
+ for (i = 0; mpd[i].header; i++)
|
|
+ fwd += snprintf(buff + fwd, len - fwd, "%%%c %s\n",
|
|
+ mpd[i].wildcard, mpd[i].header);
|
|
+ fwd += snprintf(buff + fwd, len - fwd, "\npath format wildcards:\n");
|
|
+ for (i = 0; pd[i].header; i++)
|
|
+ fwd += snprintf(buff + fwd, len - fwd, "%%%c %s\n",
|
|
+ pd[i].wildcard, pd[i].header);
|
|
+ fwd += snprintf(buff + fwd, len - fwd, "\npathgroup format wildcards:\n");
|
|
+ for (i = 0; pgd[i].header; i++)
|
|
+ fwd += snprintf(buff + fwd, len - fwd, "%%%c %s\n",
|
|
+ pgd[i].wildcard, pgd[i].header);
|
|
+ return fwd;
|
|
+}
|
|
+
|
|
void
|
|
get_path_layout (vector pathvec, int header)
|
|
{
|
|
diff --git a/libmultipath/print.h b/libmultipath/print.h
|
|
index 1718c94..a8be408 100644
|
|
--- a/libmultipath/print.h
|
|
+++ b/libmultipath/print.h
|
|
@@ -44,6 +44,7 @@ int snprint_defaults (char *, int);
|
|
int snprint_blacklist (char *, int);
|
|
int snprint_blacklist_except (char *, int);
|
|
int snprint_blacklist_report (char *, int);
|
|
+int snprint_wildcards (char *, int);
|
|
int snprint_status (char *, int, struct vectors *);
|
|
int snprint_devices (char *, int, struct vectors *);
|
|
int snprint_hwtable (char *, int, vector);
|
|
diff --git a/multipathd/cli.c b/multipathd/cli.c
|
|
index 051624a..34ae07c 100644
|
|
--- a/multipathd/cli.c
|
|
+++ b/multipathd/cli.c
|
|
@@ -170,6 +170,7 @@ load_keys (void)
|
|
r += add_key(keys, "blacklist", BLACKLIST, 0);
|
|
r += add_key(keys, "devices", DEVICES, 0);
|
|
r += add_key(keys, "format", FMT, 1);
|
|
+ r += add_key(keys, "wildcards", WILDCARDS, 0);
|
|
|
|
if (r) {
|
|
free_keys(keys);
|
|
@@ -416,6 +417,7 @@ cli_init (void) {
|
|
add_handler(LIST+CONFIG, NULL);
|
|
add_handler(LIST+BLACKLIST, NULL);
|
|
add_handler(LIST+DEVICES, NULL);
|
|
+ add_handler(LIST+WILDCARDS, NULL);
|
|
add_handler(ADD+PATH, NULL);
|
|
add_handler(DEL+PATH, NULL);
|
|
add_handler(ADD+MAP, NULL);
|
|
diff --git a/multipathd/cli.h b/multipathd/cli.h
|
|
index 8c83eab..9932d96 100644
|
|
--- a/multipathd/cli.h
|
|
+++ b/multipathd/cli.h
|
|
@@ -20,6 +20,7 @@ enum {
|
|
__BLACKLIST,
|
|
__DEVICES,
|
|
__FMT,
|
|
+ __WILDCARDS,
|
|
};
|
|
|
|
#define LIST (1 << __LIST)
|
|
@@ -43,6 +44,7 @@ enum {
|
|
#define BLACKLIST (1 << __BLACKLIST)
|
|
#define DEVICES (1 << __DEVICES)
|
|
#define FMT (1 << __FMT)
|
|
+#define WILDCARDS (1 << __WILDCARDS)
|
|
|
|
#define INITIAL_REPLY_LEN 1000
|
|
|
|
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
|
|
index 415f865..36a4968 100644
|
|
--- a/multipathd/cli_handlers.c
|
|
+++ b/multipathd/cli_handlers.c
|
|
@@ -224,6 +224,23 @@ cli_list_maps_topology (void * v, char ** reply, int * len, void * data)
|
|
}
|
|
|
|
int
|
|
+cli_list_wildcards (void * v, char ** reply, int * len, void * data)
|
|
+{
|
|
+ char * c;
|
|
+
|
|
+ *reply = MALLOC(INITIAL_REPLY_LEN);
|
|
+
|
|
+ if (!reply)
|
|
+ return 1;
|
|
+
|
|
+ c = *reply;
|
|
+ c += snprint_wildcards(c, INITIAL_REPLY_LEN);
|
|
+
|
|
+ *len = INITIAL_REPLY_LEN;
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+int
|
|
show_status (char ** r, int *len, struct vectors * vecs)
|
|
{
|
|
char * c;
|
|
diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h
|
|
index cfc4b12..703a925 100644
|
|
--- a/multipathd/cli_handlers.h
|
|
+++ b/multipathd/cli_handlers.h
|
|
@@ -9,6 +9,7 @@ int cli_list_maps_topology (void * v, char ** reply, int * len, void * data);
|
|
int cli_list_config (void * v, char ** reply, int * len, void * data);
|
|
int cli_list_blacklist (void * v, char ** reply, int * len, void * data);
|
|
int cli_list_devices (void * v, char ** reply, int * len, void * data);
|
|
+int cli_list_wildcards (void * v, char ** reply, int * len, void * data);
|
|
int cli_add_path (void * v, char ** reply, int * len, void * data);
|
|
int cli_del_path (void * v, char ** reply, int * len, void * data);
|
|
int cli_add_map (void * v, char ** reply, int * len, void * data);
|
|
diff --git a/multipathd/main.c b/multipathd/main.c
|
|
index e57a3e4..84fb5c4 100644
|
|
--- a/multipathd/main.c
|
|
+++ b/multipathd/main.c
|
|
@@ -703,6 +703,7 @@ uxlsnrloop (void * ap)
|
|
set_handler_callback(LIST+CONFIG, cli_list_config);
|
|
set_handler_callback(LIST+BLACKLIST, cli_list_blacklist);
|
|
set_handler_callback(LIST+DEVICES, cli_list_devices);
|
|
+ set_handler_callback(LIST+WILDCARDS, cli_list_wildcards);
|
|
set_handler_callback(ADD+PATH, cli_add_path);
|
|
set_handler_callback(DEL+PATH, cli_del_path);
|
|
set_handler_callback(ADD+MAP, cli_add_map);
|
|
--
|
|
1.5.2.4
|
|
|