summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/hastctl/hastctl.812
-rw-r--r--sbin/hastctl/hastctl.c64
2 files changed, 71 insertions, 5 deletions
diff --git a/sbin/hastctl/hastctl.8 b/sbin/hastctl/hastctl.8
index 9266fc0..bdca80d 100644
--- a/sbin/hastctl/hastctl.8
+++ b/sbin/hastctl/hastctl.8
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 10, 2011
+.Dd March 14, 2013
.Dt HASTCTL 8
.Os
.Sh NAME
@@ -49,6 +49,11 @@
.Aq init | primary | secondary
.Ar all | name ...
.Nm
+.Cm list
+.Op Fl d
+.Op Fl c Ar config
+.Op Ar all | name ...
+.Nm
.Cm status
.Op Fl d
.Op Fl c Ar config
@@ -139,8 +144,11 @@ GEOM provider
.Pa /dev/hast/<name>
will not be created on secondary node.
.El
+.It Cm list
+Present verbose status of the configured resources.
.It Cm status
-Present status of the configured resources.
+Present terse (and more easy machine-parseable) status of the configured
+resources.
.It Cm dump
Dump metadata stored on local component for the configured resources.
.El
diff --git a/sbin/hastctl/hastctl.c b/sbin/hastctl/hastctl.c
index bd6f70f..883a298 100644
--- a/sbin/hastctl/hastctl.c
+++ b/sbin/hastctl/hastctl.c
@@ -60,7 +60,8 @@ enum {
CMD_CREATE,
CMD_ROLE,
CMD_STATUS,
- CMD_DUMP
+ CMD_DUMP,
+ CMD_LIST
};
static __dead2 void
@@ -75,6 +76,9 @@ usage(void)
" %s role [-d] [-c config] <init | primary | secondary> all | name ...\n",
getprogname());
fprintf(stderr,
+ " %s list [-d] [-c config] [all | name ...]\n",
+ getprogname());
+ fprintf(stderr,
" %s status [-d] [-c config] [all | name ...]\n",
getprogname());
fprintf(stderr,
@@ -287,7 +291,7 @@ control_set_role(struct nv *nv, const char *newrole)
}
static int
-control_status(struct nv *nv)
+control_list(struct nv *nv)
{
unsigned int ii;
const char *str;
@@ -351,6 +355,43 @@ control_status(struct nv *nv)
return (ret);
}
+static int
+control_status(struct nv *nv)
+{
+ unsigned int ii;
+ const char *str;
+ int error, hprinted, ret;
+
+ hprinted = 0;
+ ret = 0;
+
+ for (ii = 0; ; ii++) {
+ str = nv_get_string(nv, "resource%u", ii);
+ if (str == NULL)
+ break;
+ if (!hprinted) {
+ printf("Name\tStatus\t Role\t\tComponents\n");
+ hprinted = 1;
+ }
+ printf("%s\t", str);
+ error = nv_get_int16(nv, "error%u", ii);
+ if (error != 0) {
+ if (ret == 0)
+ ret = error;
+ printf("ERR%d\n", error);
+ continue;
+ }
+ str = nv_get_string(nv, "status%u", ii);
+ printf("%-9s", (str != NULL) ? str : "-");
+ printf("%-15s", nv_get_string(nv, "role%u", ii));
+ printf("%s\t",
+ nv_get_string(nv, "localpath%u", ii));
+ printf("%s\n",
+ nv_get_string(nv, "remoteaddr%u", ii));
+ }
+ return (ret);
+}
+
int
main(int argc, char *argv[])
{
@@ -371,6 +412,9 @@ main(int argc, char *argv[])
} else if (strcmp(argv[1], "role") == 0) {
cmd = CMD_ROLE;
optstr = "c:dh";
+ } else if (strcmp(argv[1], "list") == 0) {
+ cmd = CMD_LIST;
+ optstr = "c:dh";
} else if (strcmp(argv[1], "status") == 0) {
cmd = CMD_STATUS;
optstr = "c:dh";
@@ -459,8 +503,19 @@ main(int argc, char *argv[])
for (ii = 0; ii < argc - 1; ii++)
nv_add_string(nv, argv[ii + 1], "resource%d", ii);
break;
+ case CMD_LIST:
+ /* Obtain verbose status of the given resources. */
+ nv = nv_alloc();
+ nv_add_uint8(nv, HASTCTL_CMD_STATUS, "cmd");
+ if (argc == 0)
+ nv_add_string(nv, "all", "resource%d", 0);
+ else {
+ for (ii = 0; ii < argc; ii++)
+ nv_add_string(nv, argv[ii], "resource%d", ii);
+ }
+ break;
case CMD_STATUS:
- /* Obtain status of the given resources. */
+ /* Obtain brief status of the given resources. */
nv = nv_alloc();
nv_add_uint8(nv, HASTCTL_CMD_STATUS, "cmd");
if (argc == 0)
@@ -514,6 +569,9 @@ main(int argc, char *argv[])
case CMD_ROLE:
error = control_set_role(nv, argv[0]);
break;
+ case CMD_LIST:
+ error = control_list(nv);
+ break;
case CMD_STATUS:
error = control_status(nv);
break;
OpenPOWER on IntegriCloud