diff options
-rw-r--r-- | interface.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/interface.c b/interface.c index ccccd505..9c01a0e9 100644 --- a/interface.c +++ b/interface.c @@ -41,6 +41,14 @@ struct interface_pair_s { struct in_addr interface_mask; } *interface_pair; +#ifdef linux22 +/* Linux 2.2 /proc/net/dev format -- transmit packet count in 10th field */ +#define PROCNETDEV "%d %d %*d %*d %*d %d %*d %*d %*d %*d %d %*d %d" +#else +/* pre-linux-2.2 format -- transmit packet count in 8th field */ +#define PROCNETDEV "%d %d %*d %*d %*d %d %*d %d %*d %*d %*d %*d %d" +#endif + static int _get_ifinfo_(int socket_fd, FILE *stats_file, const char *ifname, ifinfo_t *ifinfo) /* get active network interface information - return non-zero upon success */ @@ -60,8 +68,8 @@ static int _get_ifinfo_(int socket_fd, FILE *stats_file, const char *ifname, if (!strncmp(cp, ifname, namelen) && cp[namelen] == ':') { cp += namelen + 1; - if (sscanf(cp, "%d %d %*d %*d %*d %d %*d %d %*d %*d" - " %*d %*d %d",counts, counts+1, counts+2, + if (sscanf(cp, PROCNETDEV, + counts, counts+1, counts+2, counts+3,&found)>4) { /* found = dummy */ /* newer kernel with byte counts */ ifinfo->rx_packets=counts[1]; @@ -264,6 +272,12 @@ int interface_approve(struct hostdata *hp) return(FALSE); } +#ifdef ACTIVITY_DEBUG + error(0, 0, _("activity on %s was %d, is %d"), + hp->monitor, hp->monitor_io, + ifinfo.rx_packets + ifinfo.tx_packets); +#endif + return(TRUE); } #endif /* defined(linux) && !defined(INET6) */ |