]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ntpdc_ops.c, layout.std, ntp_request.c, ntp_io.c, ntp_request.h, ntp.h:
authorFrank Kardel <kardel@ntp.org>
Wed, 31 Aug 2005 08:05:42 +0000 (08:05 +0000)
committerFrank Kardel <kardel@ntp.org>
Wed, 31 Aug 2005 08:05:42 +0000 (08:05 +0000)
  output interface life time in log and via ntpdc

bk: 431564d6PnEuo466Mbk_1jyVgKEEXg

include/ntp.h
include/ntp_request.h
ntpd/ntp_io.c
ntpd/ntp_request.c
ntpdc/layout.std
ntpdc/ntpdc_ops.c

index c73badaf1cf8a30e492e735ad959af173abca1fb..f2455eb836f3cc94c2f312f237423a400283c197 100644 (file)
@@ -184,6 +184,7 @@ struct interface {
        int last_ttl;                   /* last TTL specified */
        u_int32 addr_refid;             /* IPv4 addr or IPv6 hash */
        int num_mcast;                  /* No. of IP addresses in multicast socket */
+       u_long starttime;               /* current_time as of creation of interface structure */
        volatile long received;         /* number of incoming packets */
        long sent;                      /* number of outgoing packets */
        long notsent;                   /* number of send failures */
index ab12c60866b8e0aa15da58c2a003cbfd1bddb3e2..8662308589d92a3fbb1c8d7491cf28ff6f635a2f 100644 (file)
@@ -899,6 +899,7 @@ struct info_if_stats {
         int32 received;                        /* number of incoming packets */
        int32 sent;                     /* number of outgoing packets */
        int32 notsent;                  /* number of send failures */
+       int32 uptime;                   /* number of seconds this interface was active */
        u_int32 scopeid;                /* Scope used for Multicasting */
        u_int32 ifindex;                /* interface index - from system */
        u_int32 ifnum;                  /* sequential interface number */
index 9ee139e9b22a356059a4dda6a7350f210da4204a..df06d8d87df6ba936c6fc4c9515cc63f88716205 100644 (file)
@@ -607,11 +607,16 @@ remove_interface(struct interface *interface)
   
        if (interface->fd != INVALID_SOCKET) 
        {
-               msyslog(LOG_INFO, "Deleting interface #%d %s, %s#%d",
+               msyslog(LOG_INFO, "Deleting interface #%d %s, %s#%d, interface stats: received=%ld, sent=%ld, dropped=%ld, active_time=%ld secs",
                        interface->ifnum,
                        interface->name,
                        stoa((&interface->sin)),
-                       NTP_PORT);  /* XXX should extract port from sin structure */
+                       NTP_PORT,  /* XXX should extract port from sin structure */
+                       interface->received,
+                       interface->sent,
+                       interface->notsent,
+                       current_time - interface->starttime);
+
                close_and_delete_fd_from_list(interface->fd);
        }
   
index d754f39810b0c16394e0f7e857eaf45e6b68e365..28878125274c528d37f5383cf9079a51e2d26f29 100644 (file)
@@ -2806,6 +2806,7 @@ fill_info_if_stats(void *data, interface_info_t *interface_info)
        ifs->scopeid = htonl(interface->scopeid);
        ifs->ifindex = htonl(interface->ifindex);
        ifs->ifnum = htonl(interface->ifnum);
+       ifs->uptime = htonl(current_time - interface->starttime);
        ifs->ignore_packets = interface->ignore_packets;
        ifs->peercnt = htonl(interface->peercnt);
        ifs->action = interface_info->action;
index f7e3589ca453a99540ae60013b3b8bc9e6238c57..a244bf7cd2f1a9c1067aa9fea6d2d5edf8713307 100644 (file)
@@ -410,7 +410,7 @@ offsetof(calcnt) = 48
 offsetof(errcnt) = 52
 offsetof(stbcnt) = 56
 
-sizeof(struct info_if_stats) = 136
+sizeof(struct info_if_stats) = 140
 offsetof(unaddr) = 0
 offsetof(unbcast) = 16
 offsetof(unmask) = 32
@@ -423,12 +423,13 @@ offsetof(num_mcast) = 96
 offsetof(received) = 100
 offsetof(sent) = 104
 offsetof(notsent) = 108
-offsetof(scopeid) = 112
-offsetof(ifindex) = 116
-offsetof(ifnum) = 120
-offsetof(ignore_packets) = 124
-offsetof(peercnt) = 128
-offsetof(action) = 132
+offsetof(uptime) = 112
+offsetof(scopeid) = 116
+offsetof(ifindex) = 120
+offsetof(ifnum) = 124
+offsetof(ignore_packets) = 128
+offsetof(peercnt) = 132
+offsetof(action) = 136
 
 sizeof(struct info_dns_assoc) = 32
 offsetof(peeraddr) = 0
index 8c7007a3f0c770c352985d00a43288b1fa1eee83..51fae2c1f51a356bf74e7f03aaf946513946136e 100644 (file)
@@ -3037,11 +3037,11 @@ again:
                      (u_long)ntohl(ik->errcnt));
 }
 
-#define IF_LIST_FMT     "%2d %c %48s %c %c %12.12s %03x %3d %2d %5d %5d %5d %2d %2d %3d\n"
-#define IF_LIST_FMT_STR "%2s %c %48s %c %c %12.12s %3s %3s %2s %5s %5s %5s %2s %2s %3s\n"
+#define IF_LIST_FMT     "%2d %c %48s %c %c %12.12s %03x %3d %2d %5d %5d %5d %2d %2d %3d %7d\n"
+#define IF_LIST_FMT_STR "%2s %c %48s %c %c %12.12s %3s %3s %2s %5s %5s %5s %2s %2s %3s %7s\n"
 #define IF_LIST_AFMT_STR "     %48s %c\n"
-#define IF_LIST_LABELS  "#", 'A', "Address/Mask/Broadcast", 'T', 'E', "IF name", "Flg", "TL", "#M", "recv", "sent", "drop", "S", "IX", "PC"
-#define IF_LIST_LINE    "=============================================================================================================\n"
+#define IF_LIST_LABELS  "#", 'A', "Address/Mask/Broadcast", 'T', 'E', "IF name", "Flg", "TL", "#M", "recv", "sent", "drop", "S", "IX", "PC", "uptime"
+#define IF_LIST_LINE    "=====================================================================================================================\n"
 
 static void
 iflist(
@@ -3092,7 +3092,8 @@ iflist(
                        ntohl(ifs->notsent),
                        ntohl(ifs->scopeid),
                        ntohl(ifs->ifindex),
-                       ntohl(ifs->peercnt));
+                       ntohl(ifs->peercnt),
+                       ntohl(ifs->uptime));
 
                if (!ntohl(ifs->v6_flag)) {
                        memcpy((char *)&GET_INADDR(saddr), (char *)&ifs->unbcast.addr, sizeof(ifs->unbcast.addr));