diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2006-01-24 15:28:04 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2006-01-24 15:28:04 +0000 |
commit | ded54983abd2d80d7f83c9e2e0ac5aa51217b971 (patch) | |
tree | 3a49f75279d2582c27b57dcf271b40afc2925c60 /usr.sbin | |
parent | 55ed7191539b1e13751499710c9b27d872808d52 (diff) |
introduce "bgpctl show summary terse", shows summary in an easy to parse
format, intended for monitoring puposes. claudio ok
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 32 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.c | 11 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/control.c | 9 |
5 files changed, 52 insertions, 6 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index ab1a5b58668..7a62e7b8577 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.99 2006/01/24 10:01:14 henning Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.100 2006/01/24 15:28:03 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -47,6 +47,7 @@ int main(int, char *[]); char *fmt_peer(const struct peer_config *, int); void show_summary_head(void); int show_summary_msg(struct imsg *, int); +int show_summary_terse_msg(struct imsg *, int); int show_neighbor_msg(struct imsg *, enum neighbor_views); void print_neighbor_capa_mp_safi(u_int8_t); void print_neighbor_msgstats(struct peer *); @@ -151,6 +152,9 @@ main(int argc, char *argv[]) imsg_compose(ibuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, NULL, 0); show_summary_head(); break; + case SHOW_SUMMARY_TERSE: + imsg_compose(ibuf, IMSG_CTL_SHOW_TERSE, 0, 0, -1, NULL, 0); + break; case SHOW_FIB: if (!res->addr.af) { struct buf *msg; @@ -297,6 +301,9 @@ main(int argc, char *argv[]) case SHOW_SUMMARY: done = show_summary_msg(&imsg, nodescr); break; + case SHOW_SUMMARY_TERSE: + done = show_summary_terse_msg(&imsg, nodescr); + break; case SHOW_FIB: done = show_fib_msg(&imsg); break; @@ -417,6 +424,29 @@ show_summary_msg(struct imsg *imsg, int nodescr) } int +show_summary_terse_msg(struct imsg *imsg, int nodescr) +{ + struct peer *p; + char *s; + + switch (imsg->hdr.type) { + case IMSG_CTL_SHOW_NEIGHBOR: + p = imsg->data; + s = fmt_peer(&p->conf, nodescr); + printf("%s %u %s\n", s, p->conf.remote_as, + statenames[p->state]); + free(s); + break; + case IMSG_CTL_END: + return (1); + default: + break; + } + + return (0); +} + +int show_neighbor_msg(struct imsg *imsg, enum neighbor_views nv) { struct peer *p; diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index 8a848c5a922..d72afbdf784 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.26 2006/01/03 22:51:14 claudio Exp $ */ +/* $OpenBSD: parser.c,v 1.27 2006/01/24 15:28:03 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -59,6 +59,7 @@ struct token { static const struct token t_main[]; static const struct token t_show[]; +static const struct token t_show_summary[]; static const struct token t_show_fib[]; static const struct token t_show_rib[]; static const struct token t_show_neighbor[]; @@ -100,10 +101,16 @@ static const struct token t_show[] = { { KEYWORD, "nexthop", SHOW_NEXTHOP, NULL}, { KEYWORD, "rib", SHOW_RIB, t_show_rib}, { KEYWORD, "ip", NONE, t_show_ip}, - { KEYWORD, "summary", SHOW_SUMMARY, NULL}, + { KEYWORD, "summary", SHOW_SUMMARY, t_show_summary}, { ENDTOKEN, "", NONE, NULL} }; +static const struct token t_show_summary[] = { + { NOTOKEN, "", NONE, NULL}, + { KEYWORD, "terse", SHOW_SUMMARY_TERSE, NULL}, + { ENDTOKEN, "", NONE, NULL} +}; + static const struct token t_show_fib[] = { { NOTOKEN, "", NONE, NULL}, { FLAG, "connected", F_CONNECTED, t_show_fib}, diff --git a/usr.sbin/bgpctl/parser.h b/usr.sbin/bgpctl/parser.h index 289e036da80..cb0a3378deb 100644 --- a/usr.sbin/bgpctl/parser.h +++ b/usr.sbin/bgpctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.10 2006/01/03 22:51:14 claudio Exp $ */ +/* $OpenBSD: parser.h,v 1.11 2006/01/24 15:28:03 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -24,6 +24,7 @@ enum actions { NONE, SHOW, SHOW_SUMMARY, + SHOW_SUMMARY_TERSE, SHOW_NEIGHBOR, SHOW_NEIGHBOR_TIMERS, SHOW_FIB, diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index af774aa802e..60ad43caa99 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.188 2006/01/24 10:03:44 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.189 2006/01/24 15:28:02 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -317,6 +317,7 @@ enum imsg_type { IMSG_CTL_SHOW_NETWORK, IMSG_CTL_SHOW_NETWORK6, IMSG_CTL_SHOW_RIB_MEM, + IMSG_CTL_SHOW_TERSE, IMSG_REFRESH, IMSG_IFINFO }; diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index a9e043990f2..a22d3629cc4 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.48 2006/01/24 10:04:36 henning Exp $ */ +/* $OpenBSD: control.c,v 1.49 2006/01/24 15:28:03 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -232,6 +232,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) case IMSG_CTL_SHOW_RIB_PREFIX: case IMSG_CTL_SHOW_RIB_MEM: case IMSG_CTL_SHOW_NETWORK: + case IMSG_CTL_SHOW_TERSE: break; default: /* clear imsg type to prevent processing */ @@ -264,6 +265,12 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) p, sizeof(struct peer)); imsg_compose_rde(IMSG_CTL_END, imsg.hdr.pid, NULL, 0); break; + case IMSG_CTL_SHOW_TERSE: + for (p = peers; p != NULL; p = p->next) + imsg_compose(&c->ibuf, IMSG_CTL_SHOW_NEIGHBOR, + 0, 0, -1, p, sizeof(struct peer)); + imsg_compose(&c->ibuf, IMSG_CTL_END, 0, 0, -1, NULL, 0); + break; case IMSG_CTL_RELOAD: case IMSG_CTL_FIB_COUPLE: case IMSG_CTL_FIB_DECOUPLE: |