* SUMMARY: Zero'ng the interface counters??
@ 1996-05-29 18:57 Andrew Brennan
0 siblings, 0 replies; only message in thread
From: Andrew Brennan @ 1996-05-29 18:57 UTC (permalink / raw)
To: tru64-unix-managers
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@alpha.comsource.net) and one from Dan Riley
(dsr@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@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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1996-05-29 18:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-05-29 18:57 SUMMARY: Zero'ng the interface counters?? Andrew Brennan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox