beostat_get_net_dev

Name

beostat_get_net_dev -- get the network interface statistics on a node

Synopsis

#include <sys/beostat.h>

int beostat_get_net_dev (int node, struct beostat_net_dev *devs, int size);

Arguments

node

The node to query

devs

A pointer to a array of structures of the type struct beostat_net_dev, which is defined as follows:

 struct beostat_net_dev
 {
   char name[16];
   struct beostat_net_stat recv;
   unsigned long frame;
   unsigned long multicast;
   struct beostat_net_stat trans;
   unsigned long colls;
   unsigned long carrier;
 };
where beostat_net_stat is defined as follows:
 struct beostat_net_stat
 {
   unsigned long bytes;
   unsigned long packets;
   unsigned long errs;
   unsigned long drop;
   unsigned long fifo;
   unsigned long compressed;
 };

size

The number of beostat_net_dev structures allocated by the caller.

Description

beostat_get_net_dev will get the network interface statistics of a node. The caller must allocate the memory for the array of structures and up MAX_NET_DEV or size entries will be filled (which ever is smaller). If there are less network devices available, the remaining structure(s) will be filled with zeros.

Examples

 int i;
 struct beostat_net_dev net_dev[MAX_NET_DEV];
 beostat_get_net_dev (3, net_dev, MAX_NET_DEV);
 for (i = 0; i < MAX_NET_DEV; I++)
   if (net_dev[i].name[0] != 0)
     printf ("%ld bytes of interface %s has been received on node 3.\n", 
       net_dev[i].recv.bytes, net_dev[i].name

Return Value

Return 0 on success. If an error occurs, it will return -1.

Errors

This function relies on the Beostat subsystem, which consists of the proc filesystem on the remote node, the sendstats daemon on the remote node, the recvstats daemon on the master node, and two shared memory files in the directory /var/shm. If any part of the system breaks down, this function could fail.