[Orca-checkins] r332 - in trunk/orca: data_gatherers/orcallator lib/SE/3.2.1 lib/SE/3.3 lib/SE/3.3.1

sean at seanoneill.info sean at seanoneill.info
Tue Jun 1 13:13:27 PDT 2004


Author: sean at seanoneill.info
Date: Tue Jun  1 13:11:29 2004
New Revision: 332

Added:
   trunk/orca/lib/SE/3.2.1/orca_p_netstat_class.se
   trunk/orca/lib/SE/3.3.1/orca_p_netstat_class.se
   trunk/orca/lib/SE/3.3/orca_p_netstat_class.se
Modified:
   trunk/orca/data_gatherers/orcallator/orcallator.cfg.in
   trunk/orca/data_gatherers/orcallator/orcallator.se
Log:
*  ADDED the following files:

   lib/SE/3.2.1/orca_p_netstat_class.se
   lib/SE/3.3.1/orca_p_netstat_class.se
   lib/SE/3.3/orca_p_netstat_class.se

   The RICHPse package file p_netstat_class.se file was modified to compute
   the TCP (system wide) and individual interface metrics for In/Out Packet 
   Data Payload Size and In/Out Packet Header Overhead.  The modified file was
   copied into the lib/SE/<SE version> specific directories for orca.pl to
   include at runtime.  Name changed to orca_p_netstat_class.se to match
   currert naming convention.

*  data_gatherers/orcallator/orcallator.cfg.in
   Modified to create the graphs for TCP (system wide) and individual interface
   metrics for In/Out Packet Data Payload Size and In/Out Packet Header 
   Overhead.

*  data_gatherers/orcallator/orcallator.se
   Modified to import new orca_p_netstat_class.se include file.  Also added
   code to collect TCP (system wide) and individual interface metrics for 
   In/Out Packet Data Payload Size and In/Out Packet Header Overhead data.


Modified: trunk/orca/data_gatherers/orcallator/orcallator.cfg.in
==============================================================================
--- trunk/orca/data_gatherers/orcallator/orcallator.cfg.in	(original)
+++ trunk/orca/data_gatherers/orcallator/orcallator.cfg.in	Tue Jun  1 13:11:29 2004
@@ -437,6 +437,34 @@
 }
 
 plot {
+title			%g Interface In/Out Packet Data Payload Size: $1
+source			orcallator
+data			(.*\d+)InDtSz/p
+data			$1OuDtSz/p
+line_type		area
+line_type		line1
+legend			Input
+legend			Output
+y_legend		Data Bytes/packet
+data_min		0
+data_max		1540
+}
+
+plot {
+title			%g Interface In/Out Packet Header Overhead: $1
+source			orcallator
+data			(.*\d+)InOvH%/p
+data			$1OuOvH%/p
+line_type		area
+line_type		line1
+legend			Input
+legend			Output
+y_legend		% Pkt Hdr Overhead/packet
+data_min		0
+data_max		100
+}
+
+plot {
 title			%g TCP Bits Per Second
 source			orcallator
 data			1024 * 8 * tcp_InKB/s
@@ -482,6 +510,34 @@
 }
 
 plot {
+title			%g TCP In/Out Packet Data Payload Size
+source			orcallator
+data			tcp_InDtSz/p
+data			tcp_OuDtSz/p
+line_type		area
+line_type		line1
+legend			Input
+legend			Output
+y_legend		Data Bytes/packet
+data_min		0
+data_max		1540
+}
+
+plot {
+title			%g TCP In/Out Packet Header Overhead
+source			orcallator
+data			tcp_InOvH%/p
+data			tcp_OuOvH%/p
+line_type		area
+line_type		line1
+legend			Input
+legend			Output
+y_legend		% Pkt Hdr Overhead/packet
+data_min		0
+data_max		100
+}
+
+plot {
 title			%g TCP New Connection Rate
 source			orcallator
 data			tcp_Icn/s

Modified: trunk/orca/data_gatherers/orcallator/orcallator.se
==============================================================================
--- trunk/orca/data_gatherers/orcallator/orcallator.se	(original)
+++ trunk/orca/data_gatherers/orcallator/orcallator.se	Tue Jun  1 13:11:29 2004
@@ -65,7 +65,8 @@
 #include <utsname.se>
 
 #include <p_iostat_class.se>
-#include <p_netstat_class.se>
+//#include <p_netstat_class.se>
+#include <orca_p_netstat_class.se>
 //#include <p_vmstat_class.se>
 #include <orca_p_vmstat_class.se>
 #include <pure_rules.se>
@@ -1344,8 +1345,16 @@
 	       sprintf("%11.3f", GLOBAL_net[i].opackets));
     put_output(sprintf("%5sInKB/s", tmp_lr_net.names[i]),
 	       sprintf("%11.3f", GLOBAL_net[i].ioctets/1024.0));
+    put_output(sprintf("%5sInDtSz/p", tmp_lr_net.names[i]),
+	       sprintf("%11.3f", GLOBAL_net[i].idtsize));
+    put_output(sprintf("%5sInOvH%%/p", tmp_lr_net.names[i]),
+	       sprintf("%11.3f", GLOBAL_net[i].ihdrovhd));
     put_output(sprintf("%5sOuKB/s", tmp_lr_net.names[i]),
 	       sprintf("%11.3f", GLOBAL_net[i].ooctets/1024.0));
+    put_output(sprintf("%5sOuDtSz/p", tmp_lr_net.names[i]),
+	       sprintf("%11.3f", GLOBAL_net[i].odtsize));
+    put_output(sprintf("%5sOuOvH%%/p", tmp_lr_net.names[i]),
+	       sprintf("%11.3f", GLOBAL_net[i].ohdrovhd));
     put_output(sprintf("%5sIErr/s", tmp_lr_net.names[i]),
 	       sprintf("%11.3f", GLOBAL_net[i].ierrors));
     put_output(sprintf("%5sOErr/s", tmp_lr_net.names[i]),
@@ -1369,10 +1378,33 @@
 #ifdef WATCH_TCP
 measure_tcp()
 {
+  double tmp_tcp_InDtpPkt;
+  double tmp_tcp_OuDtpPkt;
+  double tmp_tcp_InOvHPct;
+  double tmp_tcp_OuOvHPct;
+
   put_output("tcp_Iseg/s", sprintf("%10.3f", tmp_tcp.InDataSegs));
   put_output("tcp_Oseg/s", sprintf("%10.3f", tmp_tcp.OutDataSegs));
   put_output("tcp_InKB/s", sprintf("%10.3f", tmp_tcp.InDataBytes/1024.0));
   put_output("tcp_OuKB/s", sprintf("%10.3f", tmp_tcp.OutDataBytes/1024.0));
+  if ( tmp_tcp.InDataSegs == 0.0 ) {
+    tmp_tcp_InDtpPkt = 0.0;
+    tmp_tcp_InOvHPct = 0.0;
+  } else {
+    tmp_tcp_InDtpPkt = tmp_tcp.InDataBytes/tmp_tcp.InDataSegs;
+    tmp_tcp_InOvHPct = 100 * (40 * tmp_tcp.InDataSegs / (40 * tmp_tcp.InDataSegs + tmp_tcp.InDataBytes));
+  }
+  put_output("tcp_InDtSz/p", sprintf("%10.3f", tmp_tcp_InDtpPkt));
+  put_output("tcp_InOvH%/p", sprintf("%8.3f",  tmp_tcp_InOvHPct));
+  if ( tmp_tcp.OutDataSegs == 0.0 ) {
+    tmp_tcp_OuDtpPkt = 0.0;
+    tmp_tcp_OuOvHPct = 0.0;
+  } else {
+    tmp_tcp_OuDtpPkt = tmp_tcp.OutDataBytes/tmp_tcp.OutDataSegs;
+    tmp_tcp_OuOvHPct = 100 * (40 * tmp_tcp.OutDataSegs / (40 * tmp_tcp.OutDataSegs + tmp_tcp.OutDataBytes));
+  }
+  put_output("tcp_OuDtSz/p", sprintf("%10.3f", tmp_tcp_OuDtpPkt));
+  put_output("tcp_OuOvH%/p", sprintf("%8.3f",  tmp_tcp_OuOvHPct));
   put_output("tcp_Ret%",   sprintf("%8.3f",  tmp_tcp.RetransPercent));
   put_output("tcp_Dup%",   sprintf("%8.3f",  tmp_tcp.InDupPercent));
   put_output("tcp_Icn/s",  sprintf("%9.3f",  tmp_tcp.PassiveOpens));

Added: trunk/orca/lib/SE/3.2.1/orca_p_netstat_class.se
==============================================================================
--- (empty file)
+++ trunk/orca/lib/SE/3.2.1/orca_p_netstat_class.se	Tue Jun  1 13:11:29 2004
@@ -0,0 +1,247 @@
+//
+// Copyright (c) 1993-2001 by Richard Pettit. All rights reserved.
+//
+// Some of this work was derived from include files containing the following
+// copyrights.
+//
+//   Copyright (c) 1986-1994 by Sun Microsystems, Inc.
+//   Copyright (c) 1983-1989 by AT&T
+//   Copyright (c) 1980-1993 by The Regents of the University of California.
+//
+// The work as a whole represents unique intellectual property and is
+// copyright by Richard Pettit as shown on the first line.
+//
+
+#ifndef _P_NETSTAT_CLASS_SE_
+#define _P_NETSTAT_CLASS_SE_
+
+#include <unistd.se>
+#include <time.se>
+#include <string.se>
+#include <kstat.se>
+#include <sysdepend.se>
+#include <netif.se>
+
+#define NANODOUBLE 0.000000001	/* converts gethrtime to seconds */
+
+/* robust difference generator for wrapping 32bit counters */
+/* unsigned to double difference */
+
+#define UD_DIFF(now, then) (((double) now) >= ((double) then) ? \
+                             (now - then) :  \
+                            ((double) now) + 4294967296.0 - ((double) then))
+
+// All this crap must be global 'cause I can't fix the interpreter bug.
+
+double pnetGLOB_net_ipackets[]; /* these are rates */
+double pnetGLOB_net_idtsize[];
+double pnetGLOB_net_ihdrovhd[];
+double pnetGLOB_net_ierrors[];
+double pnetGLOB_net_opackets[];
+double pnetGLOB_net_odtsize[];
+double pnetGLOB_net_ohdrovhd[];
+double pnetGLOB_net_oerrors[];
+double pnetGLOB_net_collisions[];
+double pnetGLOB_net_defer[];
+double pnetGLOB_net_nocanput[];
+double pnetGLOB_net_ioctets[];
+double pnetGLOB_net_ooctets[];
+netif  pnetGLOB_save_nets[];    /* these are absolute values */
+double pnetGLOB_save_et[];
+
+int    pnetGLOB_net_size = MAX_IF;
+
+pnetGLOB_realloc()
+{
+  pnetGLOB_net_ipackets = renew pnetGLOB_net_ipackets[pnetGLOB_net_size];
+  pnetGLOB_net_idtsize = renew pnetGLOB_net_idtsize[pnetGLOB_net_size];
+  pnetGLOB_net_ihdrovhd = renew pnetGLOB_net_ihdrovhd[pnetGLOB_net_size];
+  pnetGLOB_net_ierrors = renew pnetGLOB_net_ierrors[pnetGLOB_net_size];
+  pnetGLOB_net_opackets = renew pnetGLOB_net_opackets[pnetGLOB_net_size];
+  pnetGLOB_net_odtsize = renew pnetGLOB_net_odtsize[pnetGLOB_net_size];
+  pnetGLOB_net_ohdrovhd = renew pnetGLOB_net_ohdrovhd[pnetGLOB_net_size];
+  pnetGLOB_net_oerrors = renew pnetGLOB_net_oerrors[pnetGLOB_net_size];
+  pnetGLOB_net_collisions = renew pnetGLOB_net_collisions[pnetGLOB_net_size];
+  pnetGLOB_net_defer = renew pnetGLOB_net_defer[pnetGLOB_net_size];
+  pnetGLOB_net_nocanput = renew pnetGLOB_net_nocanput[pnetGLOB_net_size];
+  pnetGLOB_net_ioctets = renew pnetGLOB_net_ioctets[pnetGLOB_net_size];
+  pnetGLOB_net_ooctets = renew pnetGLOB_net_ooctets[pnetGLOB_net_size];
+  pnetGLOB_save_nets = renew pnetGLOB_save_nets[pnetGLOB_net_size];
+  pnetGLOB_save_et = renew pnetGLOB_save_et[pnetGLOB_net_size];
+}
+
+class p_netstat {
+
+  int number$;
+  char name$[12];
+
+  int     net_count;
+  double  ipackets;
+  double  ierrors;
+  double  idtsize;
+  double  ihdrovhd;
+  double  opackets;
+  double  oerrors;
+  double  odtsize;
+  double  ohdrovhd;
+  double  collisions;
+  double  collpercent;
+  double  nocanput;
+  double  defer;
+  double  ioctets;
+  double  ooctets;
+  ulong_t ifspeed;
+  int     iftype;
+  double  utilization;
+
+  p_netstat$()
+  {
+    int i;
+    int initialized = 0;
+    netif interface;
+    double et;
+    double now;
+
+    /* do initialization code */
+    if (initialized == 0) {
+
+      pnetGLOB_net_ipackets = new double[pnetGLOB_net_size];
+      pnetGLOB_net_idtsize = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ihdrovhd = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ierrors = new double[pnetGLOB_net_size];
+      pnetGLOB_net_opackets = new double[pnetGLOB_net_size];
+      pnetGLOB_net_odtsize = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ohdrovhd = new double[pnetGLOB_net_size];
+      pnetGLOB_net_oerrors = new double[pnetGLOB_net_size];
+      pnetGLOB_net_collisions = new double[pnetGLOB_net_size];
+      pnetGLOB_net_defer = new double[pnetGLOB_net_size];
+      pnetGLOB_net_nocanput = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ioctets = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ooctets = new double[pnetGLOB_net_size];
+      pnetGLOB_save_nets = new netif[pnetGLOB_net_size];
+      pnetGLOB_save_et = new double[pnetGLOB_net_size];
+
+      /* grab initial info from netif class */
+      for(refresh$(interface), i=0; i<interface.if_count;
+          i++, interface.number$ = i, refresh$(interface)) {
+        if (interface.number$ == pnetGLOB_net_size) {
+          pnetGLOB_net_size += 4;
+          pnetGLOB_realloc();
+        }
+        pnetGLOB_save_et[interface.number$] = gethrtime() * NANODOUBLE;
+        pnetGLOB_save_nets[interface.number$] = interface;
+        net_count++;
+      }
+      ipackets = pnetGLOB_save_nets[i].ipackets;
+      ierrors = pnetGLOB_save_nets[i].ierrors;
+      opackets = pnetGLOB_save_nets[i].opackets;
+      oerrors = pnetGLOB_save_nets[i].oerrors;
+      collisions = pnetGLOB_save_nets[i].collisions;
+      if (opackets != 0) {
+        collpercent = (collisions * 100.0) / opackets;
+      } else {
+        collpercent = 0.0;
+      }
+      nocanput = pnetGLOB_save_nets[i].nocanput;
+      defer = pnetGLOB_save_nets[i].defer;
+      ioctets = pnetGLOB_save_nets[i].ioctets;
+      ooctets = pnetGLOB_save_nets[i].ooctets;
+      idtsize = 0.0;
+      ihdrovhd = 0.0;
+      odtsize = 0.0;
+      ohdrovhd = 0.0;
+      ifspeed = pnetGLOB_save_nets[i].ifspeed;
+      iftype  = pnetGLOB_save_nets[i].iftype;
+      utilization = 0.0; // this will always be around 0.000000000000000001
+      initialized = 1;
+      return;
+    }
+
+    /* bounds check */
+    i = number$;
+    if ((i < 0) || (i >= net_count)) {
+      number$ = -1;
+      return;
+    }
+
+    /* find out how many seconds have elapsed */
+    now = gethrtime() * NANODOUBLE;
+    et = (now - pnetGLOB_save_et[i]);
+
+    /* do computes if at least a second has gone by */
+    if (et > 1.0) {
+      /* save the time */
+      pnetGLOB_save_et[i] = now;
+
+      /* grab the info for this net */
+      interface.number$ = i;
+      refresh$(interface);
+  
+      /* compute new values */
+      pnetGLOB_net_ipackets[i]   =
+        UD_DIFF(interface.ipackets,   pnetGLOB_save_nets[i].ipackets) / et;
+      pnetGLOB_net_ierrors[i]    =
+        UD_DIFF(interface.ierrors,    pnetGLOB_save_nets[i].ierrors)  / et;
+      pnetGLOB_net_opackets[i]   =
+        UD_DIFF(interface.opackets,   pnetGLOB_save_nets[i].opackets) / et;
+      pnetGLOB_net_oerrors[i]    =
+        UD_DIFF(interface.oerrors,    pnetGLOB_save_nets[i].oerrors)  / et;
+      pnetGLOB_net_collisions[i] =
+        UD_DIFF(interface.collisions, pnetGLOB_save_nets[i].collisions) / et;
+      pnetGLOB_net_nocanput[i] =
+        UD_DIFF(interface.nocanput,   pnetGLOB_save_nets[i].nocanput) / et;
+      pnetGLOB_net_defer[i] =
+        UD_DIFF(interface.defer,      pnetGLOB_save_nets[i].defer)   / et;
+      pnetGLOB_net_ioctets[i] =
+        UD_DIFF(interface.ioctets,    pnetGLOB_save_nets[i].ioctets) / et;
+      pnetGLOB_net_ooctets[i] =
+        UD_DIFF(interface.ooctets,    pnetGLOB_save_nets[i].ooctets) / et;
+      if ( pnetGLOB_net_ipackets[i] == 0.0 ) {
+         pnetGLOB_net_idtsize[i] = 0.0;
+         pnetGLOB_net_ihdrovhd[i] = 0.0;
+      } else {
+         pnetGLOB_net_idtsize[i] = pnetGLOB_net_ioctets[i] / pnetGLOB_net_ipackets[i];
+         pnetGLOB_net_ihdrovhd[i] = 100 * (40 * pnetGLOB_net_ipackets[i] / ( 40 * pnetGLOB_net_ipackets[i] + pnetGLOB_net_ioctets[i] ));
+      }
+      if ( pnetGLOB_net_opackets[i] == 0.0 ) {
+         pnetGLOB_net_odtsize[i] = 0.0;
+         pnetGLOB_net_ohdrovhd[i] = 0.0;
+      } else {
+         pnetGLOB_net_odtsize[i] = pnetGLOB_net_ooctets[i] / pnetGLOB_net_opackets[i];
+         pnetGLOB_net_ohdrovhd[i] = 100 * (40 * pnetGLOB_net_opackets[i] / ( 40 * pnetGLOB_net_opackets[i] + pnetGLOB_net_ooctets[i] ));
+      }
+      /* save old */
+      pnetGLOB_save_nets[i] = interface;
+    }
+  
+    /* update and return */
+    strncpy(name$, pnetGLOB_save_nets[i].name$, 12);
+    ipackets    = pnetGLOB_net_ipackets[i];
+    ierrors     = pnetGLOB_net_ierrors[i];
+    opackets    = pnetGLOB_net_opackets[i];
+    oerrors     = pnetGLOB_net_oerrors[i];
+    collisions  = pnetGLOB_net_collisions[i];
+    if (opackets > 0.0) {
+      collpercent = collisions * 100.0 / opackets;
+    } else {
+      collpercent = 0.0;
+    }
+    nocanput	= pnetGLOB_net_nocanput[i];
+    defer       = pnetGLOB_net_defer[i];
+    ioctets     = pnetGLOB_net_ioctets[i];
+    ooctets     = pnetGLOB_net_ooctets[i];
+    idtsize     = pnetGLOB_net_idtsize[i];
+    ihdrovhd    = pnetGLOB_net_ihdrovhd[i];
+    odtsize     = pnetGLOB_net_odtsize[i];
+    ohdrovhd    = pnetGLOB_net_ohdrovhd[i];
+    ifspeed     = pnetGLOB_save_nets[i].ifspeed;
+    iftype      = pnetGLOB_save_nets[i].iftype;
+    if (ifspeed != 0) {
+      utilization = (((ioctets + ooctets) * 8) * 100.0) / ifspeed;
+    } else {
+      utilization = 0.0;
+    }
+  }
+};
+
+#endif _P_NETSTAT_CLASS_SE_

Added: trunk/orca/lib/SE/3.3.1/orca_p_netstat_class.se
==============================================================================
--- (empty file)
+++ trunk/orca/lib/SE/3.3.1/orca_p_netstat_class.se	Tue Jun  1 13:11:29 2004
@@ -0,0 +1,247 @@
+//
+// Copyright (c) 1993-2001 by Richard Pettit. All rights reserved.
+//
+// Some of this work was derived from include files containing the following
+// copyrights.
+//
+//   Copyright (c) 1986-1994 by Sun Microsystems, Inc.
+//   Copyright (c) 1983-1989 by AT&T
+//   Copyright (c) 1980-1993 by The Regents of the University of California.
+//
+// The work as a whole represents unique intellectual property and is
+// copyright by Richard Pettit as shown on the first line.
+//
+
+#ifndef _P_NETSTAT_CLASS_SE_
+#define _P_NETSTAT_CLASS_SE_
+
+#include <unistd.se>
+#include <time.se>
+#include <string.se>
+#include <kstat.se>
+#include <sysdepend.se>
+#include <netif.se>
+
+#define NANODOUBLE 0.000000001	/* converts gethrtime to seconds */
+
+/* robust difference generator for wrapping 32bit counters */
+/* unsigned to double difference */
+
+#define UD_DIFF(now, then) (((double) now) >= ((double) then) ? \
+                             (now - then) :  \
+                            ((double) now) + 4294967296.0 - ((double) then))
+
+// All this crap must be global 'cause I can't fix the interpreter bug.
+
+double pnetGLOB_net_ipackets[]; /* these are rates */
+double pnetGLOB_net_idtsize[];
+double pnetGLOB_net_ihdrovhd[];
+double pnetGLOB_net_ierrors[];
+double pnetGLOB_net_opackets[];
+double pnetGLOB_net_odtsize[];
+double pnetGLOB_net_ohdrovhd[];
+double pnetGLOB_net_oerrors[];
+double pnetGLOB_net_collisions[];
+double pnetGLOB_net_defer[];
+double pnetGLOB_net_nocanput[];
+double pnetGLOB_net_ioctets[];
+double pnetGLOB_net_ooctets[];
+netif  pnetGLOB_save_nets[];    /* these are absolute values */
+double pnetGLOB_save_et[];
+
+int    pnetGLOB_net_size = MAX_IF;
+
+pnetGLOB_realloc()
+{
+  pnetGLOB_net_ipackets = renew pnetGLOB_net_ipackets[pnetGLOB_net_size];
+  pnetGLOB_net_idtsize = renew pnetGLOB_net_idtsize[pnetGLOB_net_size];
+  pnetGLOB_net_ihdrovhd = renew pnetGLOB_net_ihdrovhd[pnetGLOB_net_size];
+  pnetGLOB_net_ierrors = renew pnetGLOB_net_ierrors[pnetGLOB_net_size];
+  pnetGLOB_net_opackets = renew pnetGLOB_net_opackets[pnetGLOB_net_size];
+  pnetGLOB_net_odtsize = renew pnetGLOB_net_odtsize[pnetGLOB_net_size];
+  pnetGLOB_net_ohdrovhd = renew pnetGLOB_net_ohdrovhd[pnetGLOB_net_size];
+  pnetGLOB_net_oerrors = renew pnetGLOB_net_oerrors[pnetGLOB_net_size];
+  pnetGLOB_net_collisions = renew pnetGLOB_net_collisions[pnetGLOB_net_size];
+  pnetGLOB_net_defer = renew pnetGLOB_net_defer[pnetGLOB_net_size];
+  pnetGLOB_net_nocanput = renew pnetGLOB_net_nocanput[pnetGLOB_net_size];
+  pnetGLOB_net_ioctets = renew pnetGLOB_net_ioctets[pnetGLOB_net_size];
+  pnetGLOB_net_ooctets = renew pnetGLOB_net_ooctets[pnetGLOB_net_size];
+  pnetGLOB_save_nets = renew pnetGLOB_save_nets[pnetGLOB_net_size];
+  pnetGLOB_save_et = renew pnetGLOB_save_et[pnetGLOB_net_size];
+}
+
+class p_netstat {
+
+  int number$;
+  char name$[12];
+
+  int     net_count;
+  double  ipackets;
+  double  ierrors;
+  double  idtsize;
+  double  ihdrovhd;
+  double  opackets;
+  double  oerrors;
+  double  odtsize;
+  double  ohdrovhd;
+  double  collisions;
+  double  collpercent;
+  double  nocanput;
+  double  defer;
+  double  ioctets;
+  double  ooctets;
+  ulong_t ifspeed;
+  int     iftype;
+  double  utilization;
+
+  p_netstat$()
+  {
+    int i;
+    int initialized = 0;
+    netif interface;
+    double et;
+    double now;
+
+    /* do initialization code */
+    if (initialized == 0) {
+
+      pnetGLOB_net_ipackets = new double[pnetGLOB_net_size];
+      pnetGLOB_net_idtsize = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ihdrovhd = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ierrors = new double[pnetGLOB_net_size];
+      pnetGLOB_net_opackets = new double[pnetGLOB_net_size];
+      pnetGLOB_net_odtsize = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ohdrovhd = new double[pnetGLOB_net_size];
+      pnetGLOB_net_oerrors = new double[pnetGLOB_net_size];
+      pnetGLOB_net_collisions = new double[pnetGLOB_net_size];
+      pnetGLOB_net_defer = new double[pnetGLOB_net_size];
+      pnetGLOB_net_nocanput = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ioctets = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ooctets = new double[pnetGLOB_net_size];
+      pnetGLOB_save_nets = new netif[pnetGLOB_net_size];
+      pnetGLOB_save_et = new double[pnetGLOB_net_size];
+
+      /* grab initial info from netif class */
+      for(refresh$(interface), i=0; i<interface.if_count;
+          i++, interface.number$ = i, refresh$(interface)) {
+        if (interface.number$ == pnetGLOB_net_size) {
+          pnetGLOB_net_size += 4;
+          pnetGLOB_realloc();
+        }
+        pnetGLOB_save_et[interface.number$] = gethrtime() * NANODOUBLE;
+        pnetGLOB_save_nets[interface.number$] = interface;
+        net_count++;
+      }
+      ipackets = pnetGLOB_save_nets[i].ipackets;
+      ierrors = pnetGLOB_save_nets[i].ierrors;
+      opackets = pnetGLOB_save_nets[i].opackets;
+      oerrors = pnetGLOB_save_nets[i].oerrors;
+      collisions = pnetGLOB_save_nets[i].collisions;
+      if (opackets != 0) {
+        collpercent = (collisions * 100.0) / opackets;
+      } else {
+        collpercent = 0.0;
+      }
+      nocanput = pnetGLOB_save_nets[i].nocanput;
+      defer = pnetGLOB_save_nets[i].defer;
+      ioctets = pnetGLOB_save_nets[i].ioctets;
+      ooctets = pnetGLOB_save_nets[i].ooctets;
+      idtsize = 0.0;
+      ihdrovhd = 0.0;
+      odtsize = 0.0;
+      ohdrovhd = 0.0;
+      ifspeed = pnetGLOB_save_nets[i].ifspeed;
+      iftype  = pnetGLOB_save_nets[i].iftype;
+      utilization = 0.0; // this will always be around 0.000000000000000001
+      initialized = 1;
+      return;
+    }
+
+    /* bounds check */
+    i = number$;
+    if ((i < 0) || (i >= net_count)) {
+      number$ = -1;
+      return;
+    }
+
+    /* find out how many seconds have elapsed */
+    now = gethrtime() * NANODOUBLE;
+    et = (now - pnetGLOB_save_et[i]);
+
+    /* do computes if at least a second has gone by */
+    if (et > 1.0) {
+      /* save the time */
+      pnetGLOB_save_et[i] = now;
+
+      /* grab the info for this net */
+      interface.number$ = i;
+      refresh$(interface);
+  
+      /* compute new values */
+      pnetGLOB_net_ipackets[i]   =
+        UD_DIFF(interface.ipackets,   pnetGLOB_save_nets[i].ipackets) / et;
+      pnetGLOB_net_ierrors[i]    =
+        UD_DIFF(interface.ierrors,    pnetGLOB_save_nets[i].ierrors)  / et;
+      pnetGLOB_net_opackets[i]   =
+        UD_DIFF(interface.opackets,   pnetGLOB_save_nets[i].opackets) / et;
+      pnetGLOB_net_oerrors[i]    =
+        UD_DIFF(interface.oerrors,    pnetGLOB_save_nets[i].oerrors)  / et;
+      pnetGLOB_net_collisions[i] =
+        UD_DIFF(interface.collisions, pnetGLOB_save_nets[i].collisions) / et;
+      pnetGLOB_net_nocanput[i] =
+        UD_DIFF(interface.nocanput,   pnetGLOB_save_nets[i].nocanput) / et;
+      pnetGLOB_net_defer[i] =
+        UD_DIFF(interface.defer,      pnetGLOB_save_nets[i].defer)   / et;
+      pnetGLOB_net_ioctets[i] =
+        UD_DIFF(interface.ioctets,    pnetGLOB_save_nets[i].ioctets) / et;
+      pnetGLOB_net_ooctets[i] =
+        UD_DIFF(interface.ooctets,    pnetGLOB_save_nets[i].ooctets) / et;
+      if ( pnetGLOB_net_ipackets[i] == 0.0 ) {
+         pnetGLOB_net_idtsize[i] = 0.0;
+         pnetGLOB_net_ihdrovhd[i] = 0.0;
+      } else {
+         pnetGLOB_net_idtsize[i] = pnetGLOB_net_ioctets[i] / pnetGLOB_net_ipackets[i];
+         pnetGLOB_net_ihdrovhd[i] = 100 * (40 * pnetGLOB_net_ipackets[i] / ( 40 * pnetGLOB_net_ipackets[i] + pnetGLOB_net_ioctets[i] ));
+      }
+      if ( pnetGLOB_net_opackets[i] == 0.0 ) {
+         pnetGLOB_net_odtsize[i] = 0.0;
+         pnetGLOB_net_ohdrovhd[i] = 0.0;
+      } else {
+         pnetGLOB_net_odtsize[i] = pnetGLOB_net_ooctets[i] / pnetGLOB_net_opackets[i];
+         pnetGLOB_net_ohdrovhd[i] = 100 * (40 * pnetGLOB_net_opackets[i] / ( 40 * pnetGLOB_net_opackets[i] + pnetGLOB_net_ooctets[i] ));
+      }
+      /* save old */
+      pnetGLOB_save_nets[i] = interface;
+    }
+  
+    /* update and return */
+    strncpy(name$, pnetGLOB_save_nets[i].name$, 12);
+    ipackets    = pnetGLOB_net_ipackets[i];
+    ierrors     = pnetGLOB_net_ierrors[i];
+    opackets    = pnetGLOB_net_opackets[i];
+    oerrors     = pnetGLOB_net_oerrors[i];
+    collisions  = pnetGLOB_net_collisions[i];
+    if (opackets > 0.0) {
+      collpercent = collisions * 100.0 / opackets;
+    } else {
+      collpercent = 0.0;
+    }
+    nocanput	= pnetGLOB_net_nocanput[i];
+    defer       = pnetGLOB_net_defer[i];
+    ioctets     = pnetGLOB_net_ioctets[i];
+    ooctets     = pnetGLOB_net_ooctets[i];
+    idtsize     = pnetGLOB_net_idtsize[i];
+    ihdrovhd    = pnetGLOB_net_ihdrovhd[i];
+    odtsize     = pnetGLOB_net_odtsize[i];
+    ohdrovhd    = pnetGLOB_net_ohdrovhd[i];
+    ifspeed     = pnetGLOB_save_nets[i].ifspeed;
+    iftype      = pnetGLOB_save_nets[i].iftype;
+    if (ifspeed != 0) {
+      utilization = (((ioctets + ooctets) * 8) * 100.0) / ifspeed;
+    } else {
+      utilization = 0.0;
+    }
+  }
+};
+
+#endif _P_NETSTAT_CLASS_SE_

Added: trunk/orca/lib/SE/3.3/orca_p_netstat_class.se
==============================================================================
--- (empty file)
+++ trunk/orca/lib/SE/3.3/orca_p_netstat_class.se	Tue Jun  1 13:11:29 2004
@@ -0,0 +1,247 @@
+//
+// Copyright (c) 1993-2001 by Richard Pettit. All rights reserved.
+//
+// Some of this work was derived from include files containing the following
+// copyrights.
+//
+//   Copyright (c) 1986-1994 by Sun Microsystems, Inc.
+//   Copyright (c) 1983-1989 by AT&T
+//   Copyright (c) 1980-1993 by The Regents of the University of California.
+//
+// The work as a whole represents unique intellectual property and is
+// copyright by Richard Pettit as shown on the first line.
+//
+
+#ifndef _P_NETSTAT_CLASS_SE_
+#define _P_NETSTAT_CLASS_SE_
+
+#include <unistd.se>
+#include <time.se>
+#include <string.se>
+#include <kstat.se>
+#include <sysdepend.se>
+#include <netif.se>
+
+#define NANODOUBLE 0.000000001	/* converts gethrtime to seconds */
+
+/* robust difference generator for wrapping 32bit counters */
+/* unsigned to double difference */
+
+#define UD_DIFF(now, then) (((double) now) >= ((double) then) ? \
+                             (now - then) :  \
+                            ((double) now) + 4294967296.0 - ((double) then))
+
+// All this crap must be global 'cause I can't fix the interpreter bug.
+
+double pnetGLOB_net_ipackets[]; /* these are rates */
+double pnetGLOB_net_idtsize[];
+double pnetGLOB_net_ihdrovhd[];
+double pnetGLOB_net_ierrors[];
+double pnetGLOB_net_opackets[];
+double pnetGLOB_net_odtsize[];
+double pnetGLOB_net_ohdrovhd[];
+double pnetGLOB_net_oerrors[];
+double pnetGLOB_net_collisions[];
+double pnetGLOB_net_defer[];
+double pnetGLOB_net_nocanput[];
+double pnetGLOB_net_ioctets[];
+double pnetGLOB_net_ooctets[];
+netif  pnetGLOB_save_nets[];    /* these are absolute values */
+double pnetGLOB_save_et[];
+
+int    pnetGLOB_net_size = MAX_IF;
+
+pnetGLOB_realloc()
+{
+  pnetGLOB_net_ipackets = renew pnetGLOB_net_ipackets[pnetGLOB_net_size];
+  pnetGLOB_net_idtsize = renew pnetGLOB_net_idtsize[pnetGLOB_net_size];
+  pnetGLOB_net_ihdrovhd = renew pnetGLOB_net_ihdrovhd[pnetGLOB_net_size];
+  pnetGLOB_net_ierrors = renew pnetGLOB_net_ierrors[pnetGLOB_net_size];
+  pnetGLOB_net_opackets = renew pnetGLOB_net_opackets[pnetGLOB_net_size];
+  pnetGLOB_net_odtsize = renew pnetGLOB_net_odtsize[pnetGLOB_net_size];
+  pnetGLOB_net_ohdrovhd = renew pnetGLOB_net_ohdrovhd[pnetGLOB_net_size];
+  pnetGLOB_net_oerrors = renew pnetGLOB_net_oerrors[pnetGLOB_net_size];
+  pnetGLOB_net_collisions = renew pnetGLOB_net_collisions[pnetGLOB_net_size];
+  pnetGLOB_net_defer = renew pnetGLOB_net_defer[pnetGLOB_net_size];
+  pnetGLOB_net_nocanput = renew pnetGLOB_net_nocanput[pnetGLOB_net_size];
+  pnetGLOB_net_ioctets = renew pnetGLOB_net_ioctets[pnetGLOB_net_size];
+  pnetGLOB_net_ooctets = renew pnetGLOB_net_ooctets[pnetGLOB_net_size];
+  pnetGLOB_save_nets = renew pnetGLOB_save_nets[pnetGLOB_net_size];
+  pnetGLOB_save_et = renew pnetGLOB_save_et[pnetGLOB_net_size];
+}
+
+class p_netstat {
+
+  int number$;
+  char name$[12];
+
+  int     net_count;
+  double  ipackets;
+  double  ierrors;
+  double  idtsize;
+  double  ihdrovhd;
+  double  opackets;
+  double  oerrors;
+  double  odtsize;
+  double  ohdrovhd;
+  double  collisions;
+  double  collpercent;
+  double  nocanput;
+  double  defer;
+  double  ioctets;
+  double  ooctets;
+  ulong_t ifspeed;
+  int     iftype;
+  double  utilization;
+
+  p_netstat$()
+  {
+    int i;
+    int initialized = 0;
+    netif interface;
+    double et;
+    double now;
+
+    /* do initialization code */
+    if (initialized == 0) {
+
+      pnetGLOB_net_ipackets = new double[pnetGLOB_net_size];
+      pnetGLOB_net_idtsize = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ihdrovhd = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ierrors = new double[pnetGLOB_net_size];
+      pnetGLOB_net_opackets = new double[pnetGLOB_net_size];
+      pnetGLOB_net_odtsize = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ohdrovhd = new double[pnetGLOB_net_size];
+      pnetGLOB_net_oerrors = new double[pnetGLOB_net_size];
+      pnetGLOB_net_collisions = new double[pnetGLOB_net_size];
+      pnetGLOB_net_defer = new double[pnetGLOB_net_size];
+      pnetGLOB_net_nocanput = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ioctets = new double[pnetGLOB_net_size];
+      pnetGLOB_net_ooctets = new double[pnetGLOB_net_size];
+      pnetGLOB_save_nets = new netif[pnetGLOB_net_size];
+      pnetGLOB_save_et = new double[pnetGLOB_net_size];
+
+      /* grab initial info from netif class */
+      for(refresh$(interface), i=0; i<interface.if_count;
+          i++, interface.number$ = i, refresh$(interface)) {
+        if (interface.number$ == pnetGLOB_net_size) {
+          pnetGLOB_net_size += 4;
+          pnetGLOB_realloc();
+        }
+        pnetGLOB_save_et[interface.number$] = gethrtime() * NANODOUBLE;
+        pnetGLOB_save_nets[interface.number$] = interface;
+        net_count++;
+      }
+      ipackets = pnetGLOB_save_nets[i].ipackets;
+      ierrors = pnetGLOB_save_nets[i].ierrors;
+      opackets = pnetGLOB_save_nets[i].opackets;
+      oerrors = pnetGLOB_save_nets[i].oerrors;
+      collisions = pnetGLOB_save_nets[i].collisions;
+      if (opackets != 0) {
+        collpercent = (collisions * 100.0) / opackets;
+      } else {
+        collpercent = 0.0;
+      }
+      nocanput = pnetGLOB_save_nets[i].nocanput;
+      defer = pnetGLOB_save_nets[i].defer;
+      ioctets = pnetGLOB_save_nets[i].ioctets;
+      ooctets = pnetGLOB_save_nets[i].ooctets;
+      idtsize = 0.0;
+      ihdrovhd = 0.0;
+      odtsize = 0.0;
+      ohdrovhd = 0.0;
+      ifspeed = pnetGLOB_save_nets[i].ifspeed;
+      iftype  = pnetGLOB_save_nets[i].iftype;
+      utilization = 0.0; // this will always be around 0.000000000000000001
+      initialized = 1;
+      return;
+    }
+
+    /* bounds check */
+    i = number$;
+    if ((i < 0) || (i >= net_count)) {
+      number$ = -1;
+      return;
+    }
+
+    /* find out how many seconds have elapsed */
+    now = gethrtime() * NANODOUBLE;
+    et = (now - pnetGLOB_save_et[i]);
+
+    /* do computes if at least a second has gone by */
+    if (et > 1.0) {
+      /* save the time */
+      pnetGLOB_save_et[i] = now;
+
+      /* grab the info for this net */
+      interface.number$ = i;
+      refresh$(interface);
+  
+      /* compute new values */
+      pnetGLOB_net_ipackets[i]   =
+        UD_DIFF(interface.ipackets,   pnetGLOB_save_nets[i].ipackets) / et;
+      pnetGLOB_net_ierrors[i]    =
+        UD_DIFF(interface.ierrors,    pnetGLOB_save_nets[i].ierrors)  / et;
+      pnetGLOB_net_opackets[i]   =
+        UD_DIFF(interface.opackets,   pnetGLOB_save_nets[i].opackets) / et;
+      pnetGLOB_net_oerrors[i]    =
+        UD_DIFF(interface.oerrors,    pnetGLOB_save_nets[i].oerrors)  / et;
+      pnetGLOB_net_collisions[i] =
+        UD_DIFF(interface.collisions, pnetGLOB_save_nets[i].collisions) / et;
+      pnetGLOB_net_nocanput[i] =
+        UD_DIFF(interface.nocanput,   pnetGLOB_save_nets[i].nocanput) / et;
+      pnetGLOB_net_defer[i] =
+        UD_DIFF(interface.defer,      pnetGLOB_save_nets[i].defer)   / et;
+      pnetGLOB_net_ioctets[i] =
+        UD_DIFF(interface.ioctets,    pnetGLOB_save_nets[i].ioctets) / et;
+      pnetGLOB_net_ooctets[i] =
+        UD_DIFF(interface.ooctets,    pnetGLOB_save_nets[i].ooctets) / et;
+      if ( pnetGLOB_net_ipackets[i] == 0.0 ) {
+         pnetGLOB_net_idtsize[i] = 0.0;
+         pnetGLOB_net_ihdrovhd[i] = 0.0;
+      } else {
+         pnetGLOB_net_idtsize[i] = pnetGLOB_net_ioctets[i] / pnetGLOB_net_ipackets[i];
+         pnetGLOB_net_ihdrovhd[i] = 100 * (40 * pnetGLOB_net_ipackets[i] / ( 40 * pnetGLOB_net_ipackets[i] + pnetGLOB_net_ioctets[i] ));
+      }
+      if ( pnetGLOB_net_opackets[i] == 0.0 ) {
+         pnetGLOB_net_odtsize[i] = 0.0;
+         pnetGLOB_net_ohdrovhd[i] = 0.0;
+      } else {
+         pnetGLOB_net_odtsize[i] = pnetGLOB_net_ooctets[i] / pnetGLOB_net_opackets[i];
+         pnetGLOB_net_ohdrovhd[i] = 100 * (40 * pnetGLOB_net_opackets[i] / ( 40 * pnetGLOB_net_opackets[i] + pnetGLOB_net_ooctets[i] ));
+      }
+      /* save old */
+      pnetGLOB_save_nets[i] = interface;
+    }
+  
+    /* update and return */
+    strncpy(name$, pnetGLOB_save_nets[i].name$, 12);
+    ipackets    = pnetGLOB_net_ipackets[i];
+    ierrors     = pnetGLOB_net_ierrors[i];
+    opackets    = pnetGLOB_net_opackets[i];
+    oerrors     = pnetGLOB_net_oerrors[i];
+    collisions  = pnetGLOB_net_collisions[i];
+    if (opackets > 0.0) {
+      collpercent = collisions * 100.0 / opackets;
+    } else {
+      collpercent = 0.0;
+    }
+    nocanput	= pnetGLOB_net_nocanput[i];
+    defer       = pnetGLOB_net_defer[i];
+    ioctets     = pnetGLOB_net_ioctets[i];
+    ooctets     = pnetGLOB_net_ooctets[i];
+    idtsize     = pnetGLOB_net_idtsize[i];
+    ihdrovhd    = pnetGLOB_net_ihdrovhd[i];
+    odtsize     = pnetGLOB_net_odtsize[i];
+    ohdrovhd    = pnetGLOB_net_ohdrovhd[i];
+    ifspeed     = pnetGLOB_save_nets[i].ifspeed;
+    iftype      = pnetGLOB_save_nets[i].iftype;
+    if (ifspeed != 0) {
+      utilization = (((ioctets + ooctets) * 8) * 100.0) / ifspeed;
+    } else {
+      utilization = 0.0;
+    }
+  }
+};
+
+#endif _P_NETSTAT_CLASS_SE_



More information about the Orca-checkins mailing list