diff options
Diffstat (limited to 'usr.sbin/relayctl')
-rw-r--r-- | usr.sbin/relayctl/parser.c | 3 | ||||
-rw-r--r-- | usr.sbin/relayctl/parser.h | 5 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.8 | 5 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.c | 60 |
4 files changed, 68 insertions, 5 deletions
diff --git a/usr.sbin/relayctl/parser.c b/usr.sbin/relayctl/parser.c index aca5a16c9e9..3347f2639f0 100644 --- a/usr.sbin/relayctl/parser.c +++ b/usr.sbin/relayctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.7 2007/01/29 14:23:31 pyr Exp $ */ +/* $OpenBSD: parser.c,v 1.8 2007/02/01 20:03:38 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -63,6 +63,7 @@ static const struct token t_table_id[]; static const struct token t_host_id[]; static const struct token t_main[] = { + {KEYWORD, "monitor", MONITOR, NULL}, {KEYWORD, "show", SHOW_SUM, NULL}, {KEYWORD, "stop", SHUTDOWN, NULL}, {KEYWORD, "service", NULL, t_service}, diff --git a/usr.sbin/relayctl/parser.h b/usr.sbin/relayctl/parser.h index 1f1c8e879e1..9d0cbeb62a7 100644 --- a/usr.sbin/relayctl/parser.h +++ b/usr.sbin/relayctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.2 2006/12/16 18:50:33 reyk Exp $ */ +/* $OpenBSD: parser.h,v 1.3 2007/02/01 20:03:38 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -26,7 +26,8 @@ enum actions { HOST_DISABLE, HOST_ENABLE, SHUTDOWN, - RELOAD + RELOAD, + MONITOR }; struct parse_result { diff --git a/usr.sbin/relayctl/relayctl.8 b/usr.sbin/relayctl/relayctl.8 index 61a11ce7942..5b26cb1d91a 100644 --- a/usr.sbin/relayctl/relayctl.8 +++ b/usr.sbin/relayctl/relayctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: relayctl.8,v 1.6 2007/01/09 13:50:10 pyr Exp $ +.\" $OpenBSD: relayctl.8,v 1.7 2007/02/01 20:03:38 pyr Exp $ .\" .\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> .\" @@ -39,6 +39,9 @@ Treat it as though it were always down. .It Cm host enable Op Ar name | id Enable the host. Start checking its health again. +.It Cm monitor +Continuously report any changes in the host checking engine and the +pf engine. .It Cm service disable Op Ar name | id Disable a service. If it has diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index 8332f2f0229..cfb796c43ce 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.9 2007/01/29 14:23:31 pyr Exp $ */ +/* $OpenBSD: relayctl.c,v 1.10 2007/02/01 20:03:38 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -44,6 +44,7 @@ __dead void usage(void); int show_summary_msg(struct imsg *); int show_command_output(struct imsg *); +int monitor(struct imsg *); char *print_service_status(int); char *print_host_status(int, int); char *print_table_status(int, int); @@ -134,6 +135,9 @@ main(int argc, char *argv[]) case RELOAD: imsg_compose(ibuf, IMSG_CTL_RELOAD, 0, 0, NULL, 0); break; + case MONITOR: + imsg_compose(ibuf, IMSG_CTL_NOTIFY, 0, 0, NULL, 0); + break; } while (ibuf->w.queued) @@ -167,6 +171,9 @@ main(int argc, char *argv[]) case SHUTDOWN: case NONE: break; + case MONITOR: + done = monitor(&imsg); + break; } imsg_free(&imsg); } @@ -178,6 +185,57 @@ main(int argc, char *argv[]) } int +monitor(struct imsg *imsg) +{ + time_t now; + int done; + struct ctl_status cs; + struct ctl_id id; + + done = 0; + now = time(NULL); + printf("got message of size %u on %s", imsg->hdr.len, ctime(&now)); + switch (imsg->hdr.type) { + case IMSG_HOST_STATUS: + memcpy(&cs, imsg->data, sizeof(cs)); + printf("HOST_STATUS: %u is in state %d\n", cs.id, cs.up); + break; + case IMSG_CTL_SERVICE_DISABLE: + memcpy(&id, imsg->data, sizeof(id)); + printf("CTL_SERVICE_DISABLE: %u\n", id.id); + break; + case IMSG_CTL_SERVICE_ENABLE: + memcpy(&id, imsg->data, sizeof(id)); + printf("CTL_SERVICE_ENABLE: %u\n", id.id); + break; + case IMSG_CTL_TABLE_DISABLE: + memcpy(&id, imsg->data, sizeof(id)); + printf("CTL_TABLE_DISABLE: %u\n", id.id); + break; + case IMSG_CTL_TABLE_ENABLE: + memcpy(&id, imsg->data, sizeof(id)); + printf("CTL_TABLE_ENABLE: %u\n", id.id); + break; + case IMSG_CTL_HOST_DISABLE: + memcpy(&id, imsg->data, sizeof(id)); + printf("CTL_HOST_DISABLE: %u\n", id.id); + break; + case IMSG_CTL_HOST_ENABLE: + memcpy(&id, imsg->data, sizeof(id)); + printf("CTL_HOST_ENABLE: %u\n", id.id); + break; + case IMSG_SYNC: + printf("SYNC\n"); + break; + default: + printf("INVALID\n"); + done = 1; + break; + } + return (done); +} + +int show_summary_msg(struct imsg *imsg) { struct service *service; |