Two weeks ago, I posted a request for a way to zero out the counters on
an ethernet interface without rebooting the machine. I received a note
relaying DEC info that it's not possible without downing the interface
(from Andy Saylor - asaylor_at_alpha.comsource.net) and one from Dan Riley
(dsr_at_lns598.lns.cornell.edu) with a small program to zero the counters.
I've included Dan's message in case someone else needs the same & would
rather not reboot their machine (and lose an RZ74 like we did :^p )
andrew. (brennan_at_crashprone.hahnemann.edu)
---Dan Riley's message/program---
There's an ioctl to do it. The following program shows how
(takes one arg, the name of the interface, should be run as root):
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
main(int argc, char **argv)
{
int af = AF_INET;
int s;
struct ctrreq ifctr;
if (argc != 2) {
fprintf(stderr, "usage: %s interface", argv[0]);
exit(1);
}
argc--, argv++;
strncpy(ifctr.ctr_name, *argv, sizeof(ifctr.ctr_name));
s = socket(af, SOCK_DGRAM, 0);
if (s < 0) {
perror("ifclr: socket");
exit(1);
}
if (ioctl(s, SIOCRDZCTRS, &ifctr) < 0) {
perror("ioctl (SIOCRDZCTRS)");
exit(1);
}
printf("rec %d sent %d col %d %d\n",
ifctr.ctr_ether.est_blokrcvd,
ifctr.ctr_ether.est_bloksent,
ifctr.ctr_ether.est_single,
ifctr.ctr_ether.est_multiple);
}
Received on Wed May 29 1996 - 21:19:08 NZST