diff options
-rw-r--r-- | usr.sbin/hoststatectl/hoststatectl.8 | 6 | ||||
-rw-r--r-- | usr.sbin/hoststatectl/hoststatectl.c | 42 | ||||
-rw-r--r-- | usr.sbin/hoststatectl/parser.c | 3 | ||||
-rw-r--r-- | usr.sbin/hoststatectl/parser.h | 3 | ||||
-rw-r--r-- | usr.sbin/relayctl/parser.c | 3 | ||||
-rw-r--r-- | usr.sbin/relayctl/parser.h | 3 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.8 | 6 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.c | 42 |
8 files changed, 98 insertions, 10 deletions
diff --git a/usr.sbin/hoststatectl/hoststatectl.8 b/usr.sbin/hoststatectl/hoststatectl.8 index ce96f4a19d1..52fcf227315 100644 --- a/usr.sbin/hoststatectl/hoststatectl.8 +++ b/usr.sbin/hoststatectl/hoststatectl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: hoststatectl.8,v 1.10 2007/08/02 16:10:58 pyr Exp $ +.\" $OpenBSD: hoststatectl.8,v 1.11 2007/09/07 08:33:31 reyk Exp $ .\" .\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 2 2007 $ +.Dd $Mdocdate: September 7 2007 $ .Dt HOSTSTATECTL 8 .Os .Sh NAME @@ -61,6 +61,8 @@ Show detailed status of hosts, tables, and services. Show detailed status of relays including the current and average access statistics. The statistics will be updated every minute. +.It Cm show sessions +Dump the complete list of running relay sessions. .It Cm show summary Display a list of all relays, services, tables, and hosts. .It Cm table disable Op Ar name | id diff --git a/usr.sbin/hoststatectl/hoststatectl.c b/usr.sbin/hoststatectl/hoststatectl.c index cd8dafc9772..15754b4507c 100644 --- a/usr.sbin/hoststatectl/hoststatectl.c +++ b/usr.sbin/hoststatectl/hoststatectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststatectl.c,v 1.21 2007/09/07 08:31:36 reyk Exp $ */ +/* $OpenBSD: hoststatectl.c,v 1.22 2007/09/07 08:33:31 reyk 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); +int show_session_msg(struct imsg *); int show_command_output(struct imsg *); char *print_service_status(int); char *print_host_status(int, int); @@ -146,6 +147,9 @@ main(int argc, char *argv[]) printf("Type\t%4s\t%-24s\t%-7s\tStatus\n", "Id", "Name", "Avlblty"); break; + case SHOW_SESSIONS: + imsg_compose(ibuf, IMSG_CTL_SESSION, 0, 0, -1, NULL, 0); + break; case SERV_ENABLE: imsg_compose(ibuf, IMSG_CTL_SERVICE_ENABLE, 0, 0, -1, &res->id, sizeof(res->id)); @@ -202,6 +206,9 @@ main(int argc, char *argv[]) case SHOW_RELAYS: done = show_summary_msg(&imsg, res->action); break; + case SHOW_SESSIONS: + done = show_session_msg(&imsg); + break; case SERV_DISABLE: case SERV_ENABLE: case TABLE_DISABLE: @@ -378,6 +385,39 @@ show_summary_msg(struct imsg *imsg, int type) } int +show_session_msg(struct imsg *imsg) +{ + struct session *con; + char a[128], b[128]; + struct timeval tv_now; + + switch (imsg->hdr.type) { + case IMSG_CTL_SESSION: + con = imsg->data; + + (void)print_host(&con->in.ss, a, sizeof(a)); + (void)print_host(&con->out.ss, b, sizeof(b)); + printf("session %u:%u %s:%u -> %s:%u\t%s\n", + imsg->hdr.peerid, con->id, + a, ntohs(con->in.port), b, ntohs(con->out.port), + con->done ? "DONE" : "RUNNING"); + + if (gettimeofday(&tv_now, NULL)) + fatal("show_session_msg: gettimeofday"); + print_time(&tv_now, &con->tv_start, a, sizeof(a)); + print_time(&tv_now, &con->tv_last, b, sizeof(b)); + printf("\tage %s, idle %s, relay %u\n", a, b, con->relayid); + break; + case IMSG_CTL_END: + return (1); + default: + errx(1, "wrong message in session: %u", imsg->hdr.type); + break; + } + return (0); +} + +int show_command_output(struct imsg *imsg) { switch (imsg->hdr.type) { diff --git a/usr.sbin/hoststatectl/parser.c b/usr.sbin/hoststatectl/parser.c index 70983b0d64a..6f507d1335e 100644 --- a/usr.sbin/hoststatectl/parser.c +++ b/usr.sbin/hoststatectl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.11 2007/05/29 22:41:48 pyr Exp $ */ +/* $OpenBSD: parser.c,v 1.12 2007/09/07 08:33:31 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -78,6 +78,7 @@ static const struct token t_show[] = { {KEYWORD, "summary", SHOW_SUM, NULL}, {KEYWORD, "hosts", SHOW_HOSTS, NULL}, {KEYWORD, "relays", SHOW_RELAYS, NULL}, + {KEYWORD, "sessions", SHOW_SESSIONS, NULL}, {ENDTOKEN, "", NONE, NULL} }; diff --git a/usr.sbin/hoststatectl/parser.h b/usr.sbin/hoststatectl/parser.h index 0f9509f7dbf..1116677893c 100644 --- a/usr.sbin/hoststatectl/parser.h +++ b/usr.sbin/hoststatectl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.4 2007/02/22 03:32:40 reyk Exp $ */ +/* $OpenBSD: parser.h,v 1.5 2007/09/07 08:33:31 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -21,6 +21,7 @@ enum actions { SHOW_SUM, SHOW_HOSTS, SHOW_RELAYS, + SHOW_SESSIONS, SERV_DISABLE, SERV_ENABLE, TABLE_DISABLE, diff --git a/usr.sbin/relayctl/parser.c b/usr.sbin/relayctl/parser.c index 70983b0d64a..6f507d1335e 100644 --- a/usr.sbin/relayctl/parser.c +++ b/usr.sbin/relayctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.11 2007/05/29 22:41:48 pyr Exp $ */ +/* $OpenBSD: parser.c,v 1.12 2007/09/07 08:33:31 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -78,6 +78,7 @@ static const struct token t_show[] = { {KEYWORD, "summary", SHOW_SUM, NULL}, {KEYWORD, "hosts", SHOW_HOSTS, NULL}, {KEYWORD, "relays", SHOW_RELAYS, NULL}, + {KEYWORD, "sessions", SHOW_SESSIONS, NULL}, {ENDTOKEN, "", NONE, NULL} }; diff --git a/usr.sbin/relayctl/parser.h b/usr.sbin/relayctl/parser.h index 0f9509f7dbf..1116677893c 100644 --- a/usr.sbin/relayctl/parser.h +++ b/usr.sbin/relayctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.4 2007/02/22 03:32:40 reyk Exp $ */ +/* $OpenBSD: parser.h,v 1.5 2007/09/07 08:33:31 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -21,6 +21,7 @@ enum actions { SHOW_SUM, SHOW_HOSTS, SHOW_RELAYS, + SHOW_SESSIONS, SERV_DISABLE, SERV_ENABLE, TABLE_DISABLE, diff --git a/usr.sbin/relayctl/relayctl.8 b/usr.sbin/relayctl/relayctl.8 index bb1ddcb3840..d9f2c88a150 100644 --- a/usr.sbin/relayctl/relayctl.8 +++ b/usr.sbin/relayctl/relayctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: relayctl.8,v 1.10 2007/08/02 16:10:58 pyr Exp $ +.\" $OpenBSD: relayctl.8,v 1.11 2007/09/07 08:33:31 reyk Exp $ .\" .\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 2 2007 $ +.Dd $Mdocdate: September 7 2007 $ .Dt HOSTSTATECTL 8 .Os .Sh NAME @@ -61,6 +61,8 @@ Show detailed status of hosts, tables, and services. Show detailed status of relays including the current and average access statistics. The statistics will be updated every minute. +.It Cm show sessions +Dump the complete list of running relay sessions. .It Cm show summary Display a list of all relays, services, tables, and hosts. .It Cm table disable Op Ar name | id diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index 9c39215729e..2a3702d73ab 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.21 2007/09/07 08:31:36 reyk Exp $ */ +/* $OpenBSD: relayctl.c,v 1.22 2007/09/07 08:33:31 reyk 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); +int show_session_msg(struct imsg *); int show_command_output(struct imsg *); char *print_service_status(int); char *print_host_status(int, int); @@ -146,6 +147,9 @@ main(int argc, char *argv[]) printf("Type\t%4s\t%-24s\t%-7s\tStatus\n", "Id", "Name", "Avlblty"); break; + case SHOW_SESSIONS: + imsg_compose(ibuf, IMSG_CTL_SESSION, 0, 0, -1, NULL, 0); + break; case SERV_ENABLE: imsg_compose(ibuf, IMSG_CTL_SERVICE_ENABLE, 0, 0, -1, &res->id, sizeof(res->id)); @@ -202,6 +206,9 @@ main(int argc, char *argv[]) case SHOW_RELAYS: done = show_summary_msg(&imsg, res->action); break; + case SHOW_SESSIONS: + done = show_session_msg(&imsg); + break; case SERV_DISABLE: case SERV_ENABLE: case TABLE_DISABLE: @@ -378,6 +385,39 @@ show_summary_msg(struct imsg *imsg, int type) } int +show_session_msg(struct imsg *imsg) +{ + struct session *con; + char a[128], b[128]; + struct timeval tv_now; + + switch (imsg->hdr.type) { + case IMSG_CTL_SESSION: + con = imsg->data; + + (void)print_host(&con->in.ss, a, sizeof(a)); + (void)print_host(&con->out.ss, b, sizeof(b)); + printf("session %u:%u %s:%u -> %s:%u\t%s\n", + imsg->hdr.peerid, con->id, + a, ntohs(con->in.port), b, ntohs(con->out.port), + con->done ? "DONE" : "RUNNING"); + + if (gettimeofday(&tv_now, NULL)) + fatal("show_session_msg: gettimeofday"); + print_time(&tv_now, &con->tv_start, a, sizeof(a)); + print_time(&tv_now, &con->tv_last, b, sizeof(b)); + printf("\tage %s, idle %s, relay %u\n", a, b, con->relayid); + break; + case IMSG_CTL_END: + return (1); + default: + errx(1, "wrong message in session: %u", imsg->hdr.type); + break; + } + return (0); +} + +int show_command_output(struct imsg *imsg) { switch (imsg->hdr.type) { |