From: Andrew Brennan <brennan () crashprone ! hahnemann ! edu>
To: tru64-unix-managers
Subject: SUMMARY: Zero'ng the interface counters??
Date: Wed, 29 May 1996 18:57:28 +0000 [thread overview]
Message-ID: <96076332421588.tru64-unix-managers.marc@archive.invalid> (raw)
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);
}
reply other threads:[~1996-05-29 18:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox