Hello,

When monitoring my bgpd, I need to check the session duration and the number of
prefixes. Here is a patch that add these informations to "bgpctl show sum
terse"

Before :
# bgpctl show sum terse
10.20.30.254 65003 Established

After :
# bgpctl show sum terse
10.20.30.254 65003 Established 10 3

Denis


Index: bgpctl/bgpctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v
retrieving revision 1.187
diff -u -p -r1.187 bgpctl.c
--- bgpctl/bgpctl.c     5 Dec 2015 13:17:05 -0000       1.187
+++ bgpctl/bgpctl.c     17 Apr 2016 15:55:59 -0000
@@ -186,11 +186,9 @@ main(int argc, char *argv[])
                /* NOTREACHED */
        case SHOW:
        case SHOW_SUMMARY:
-               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);
+               imsg_compose(ibuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, NULL, 0);
                break;
        case SHOW_FIB:
                if (!res->addr.aid) {
@@ -584,8 +582,9 @@ show_summary_terse_msg(struct imsg *imsg
                p = imsg->data;
                s = fmt_peer(p->conf.descr, &p->conf.remote_addr,
                    p->conf.remote_masklen, nodescr);
-               printf("%s %s %s\n", s, log_as(p->conf.remote_as),
-                   p->conf.template ? "Template" : statenames[p->state]);
+               printf("%s %s %s %llu %u\n", s, log_as(p->conf.remote_as),
+                   p->conf.template ? "Template" : statenames[p->state],
+                   (time(NULL) - p->stats.last_updown), p->stats.prefix_cnt);
                free(s);
                break;
        case IMSG_CTL_END:
Index: bgpd/bgpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
retrieving revision 1.292
diff -u -p -r1.292 bgpd.h
--- bgpd/bgpd.h 6 Nov 2015 16:23:26 -0000       1.292
+++ bgpd/bgpd.h 17 Apr 2016 15:55:59 -0000
@@ -374,7 +374,6 @@ enum imsg_type {
        IMSG_CTL_SHOW_RIB_COMMUNITY,
        IMSG_CTL_SHOW_NETWORK,
        IMSG_CTL_SHOW_RIB_MEM,
-       IMSG_CTL_SHOW_TERSE,
        IMSG_CTL_SHOW_TIMER,
        IMSG_CTL_LOG_VERBOSE,
        IMSG_CTL_SHOW_FIB_TABLES,
Index: bgpd/control.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/control.c,v
retrieving revision 1.82
diff -u -p -r1.82 control.c
--- bgpd/control.c      5 Dec 2015 18:28:04 -0000       1.82
+++ bgpd/control.c      17 Apr 2016 15:55:59 -0000
@@ -245,7 +245,6 @@ control_dispatch_msg(struct pollfd *pfd,
                        case IMSG_CTL_SHOW_RIB_MEM:
                        case IMSG_CTL_SHOW_RIB_COMMUNITY:
                        case IMSG_CTL_SHOW_NETWORK:
-                       case IMSG_CTL_SHOW_TERSE:
                        case IMSG_CTL_SHOW_TIMER:
                                break;
                        default:
@@ -306,12 +305,6 @@ control_dispatch_msg(struct pollfd *pfd,
                                imsg_ctl_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_FIB_COUPLE:
                case IMSG_CTL_FIB_DECOUPLE:

Reply via email to