summaryrefslogtreecommitdiff
path: root/usr.sbin/hoststatectl
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2006-12-16 18:50:34 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2006-12-16 18:50:34 +0000
commit19d82ea2d7751a0b7ec8fa66d2a2053a369f0403 (patch)
treed91fc3a03e096ac77beaf625f8687d85b92e7b05 /usr.sbin/hoststatectl
parenteb9e468ffdd8750ab38d6914ccb20acb388e2102 (diff)
- allow to use host/service/table names instead of Ids in hostatectl.
- minor change of the "hostatectl show" command output - increase the max service and tag names (max pf tag name size is 64 now!) thanks to pyr who found a bug in my initial diff
Diffstat (limited to 'usr.sbin/hoststatectl')
-rw-r--r--usr.sbin/hoststatectl/hoststatectl.814
-rw-r--r--usr.sbin/hoststatectl/hoststatectl.c10
-rw-r--r--usr.sbin/hoststatectl/parser.c26
-rw-r--r--usr.sbin/hoststatectl/parser.h4
4 files changed, 30 insertions, 24 deletions
diff --git a/usr.sbin/hoststatectl/hoststatectl.8 b/usr.sbin/hoststatectl/hoststatectl.8
index 686148f9574..c511bc9da66 100644
--- a/usr.sbin/hoststatectl/hoststatectl.8
+++ b/usr.sbin/hoststatectl/hoststatectl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: hoststatectl.8,v 1.2 2006/12/16 11:48:38 reyk Exp $
+.\" $OpenBSD: hoststatectl.8,v 1.3 2006/12/16 18:50:33 reyk Exp $
.\"
.\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
.\"
@@ -36,32 +36,32 @@ The following commands are available:
.It Cm show
.It Cm show summary
Show status of services, tables and hosts.
-.It Cm service disable id
+.It Cm service disable Op Ar name | id
Disable a service.
If it has
.Xr pf 4
redirection rules installed, remove them.
Mark the service's main table and -
if applicable - backup table disabled as well.
-.It Cm service enable id
+.It Cm service enable Op Ar name | id
Enable a service.
Mark the service's main table and - if applicable - backup
table enabled as well.
-.It Cm table disable id
+.It Cm table disable Op Ar name | id
Disable a table.
Consider all hosts disabled.
If it is a main table of a service which has a non-empty backup table,
swap the contents of the
.Xr pf 4
table with those of the backup table.
-.It Cm table enable id
+.It Cm table enable Op Ar name | id
Enable a table.
Start doing checks for all hosts that aren't individually disabled
again.
-.It Cm host disable id
+.It Cm host disable Op Ar name | id
Disable a host.
Treat it as though it were always down.
-.It Cm host enable id
+.It Cm host enable Op Ar name | id
Enable the host.
Start checking its health again.
.El
diff --git a/usr.sbin/hoststatectl/hoststatectl.c b/usr.sbin/hoststatectl/hoststatectl.c
index ca9c0917d6a..9c81a0f6811 100644
--- a/usr.sbin/hoststatectl/hoststatectl.c
+++ b/usr.sbin/hoststatectl/hoststatectl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hoststatectl.c,v 1.5 2006/12/16 17:52:21 deraadt Exp $ */
+/* $OpenBSD: hoststatectl.c,v 1.6 2006/12/16 18:50:33 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -100,7 +100,7 @@ main(int argc, char *argv[])
/* not reached */
case SHOW_SUM:
imsg_compose(ibuf, IMSG_CTL_SHOW_SUM, 0, 0, NULL, 0);
- printf("type\t%4s\t%-16s\tstatus\n\n", "id", "name");
+ printf("Type\t%4s\t%-24s\tStatus\n", "Id", "Name");
break;
case SERV_ENABLE:
imsg_compose(ibuf, IMSG_CTL_SERVICE_ENABLE, 0, 0,
@@ -185,20 +185,20 @@ show_summary_msg(struct imsg *imsg)
switch (imsg->hdr.type) {
case IMSG_CTL_SERVICE:
service = imsg->data;
- printf("service\t%4u\t%-16s\t%s\n",
+ printf("service\t%4u\t%-24s\t%s\n",
service->id, service->name,
print_service_status(service->flags));
break;
case IMSG_CTL_TABLE:
table = imsg->data;
- printf("table\t%4u\t%-16s\t%s",
+ printf("table\t%4u\t%-24s\t%s",
table->id, table->name,
print_table_status(table->up, table->flags));
printf("\n");
break;
case IMSG_CTL_HOST:
host = imsg->data;
- printf("host\t%4u\t%-16s\t%s\n",
+ printf("host\t%4u\t%-24s\t%s\n",
host->id, host->name,
print_host_status(host->up, host->flags));
break;
diff --git a/usr.sbin/hoststatectl/parser.c b/usr.sbin/hoststatectl/parser.c
index 2f535990ed9..43703a6622b 100644
--- a/usr.sbin/hoststatectl/parser.c
+++ b/usr.sbin/hoststatectl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.3 2006/12/16 17:53:03 deraadt Exp $ */
+/* $OpenBSD: parser.c,v 1.4 2006/12/16 18:50:33 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -166,23 +166,29 @@ match_token(const char *word, const struct token table[])
}
break;
case HOSTID:
- res.id = strtonum(word, 0, UINT_MAX, &errstr);
- if (errstr)
- errx(1, "host id %s is %s", word, errstr);
+ res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
+ if (errstr) {
+ strlcpy(res.id.name, word, sizeof(res.id.name));
+ res.id.id = EMPTY_ID;
+ }
t = &table[i];
match++;
break;
case TABLEID:
- res.id = strtonum(word, 0, UINT_MAX, &errstr);
- if (errstr)
- errx(1, "table id %s is %s", word, errstr);
+ res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
+ if (errstr) {
+ strlcpy(res.id.name, word, sizeof(res.id.name));
+ res.id.id = EMPTY_ID;
+ }
t = &table[i];
match++;
break;
case SERVICEID:
- res.id = strtonum(word, 0, UINT_MAX, &errstr);
- if (errstr)
- errx(1, "service id %s is %s", word, errstr);
+ res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
+ if (errstr) {
+ strlcpy(res.id.name, word, sizeof(res.id.name));
+ res.id.id = EMPTY_ID;
+ }
t = &table[i];
match++;
break;
diff --git a/usr.sbin/hoststatectl/parser.h b/usr.sbin/hoststatectl/parser.h
index 2fef7464faf..1f1c8e879e1 100644
--- a/usr.sbin/hoststatectl/parser.h
+++ b/usr.sbin/hoststatectl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.1 2006/12/16 11:45:07 reyk Exp $ */
+/* $OpenBSD: parser.h,v 1.2 2006/12/16 18:50:33 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -30,7 +30,7 @@ enum actions {
};
struct parse_result {
- objid_t id;
+ struct ctl_id id;
enum actions action;
};