diff --git a/html/graph.php b/html/graph.php index 0faeab8c9..a0d04db01 100644 --- a/html/graph.php +++ b/html/graph.php @@ -18,7 +18,10 @@ $device = getifhost($_GET['if']); $ifIndex = getifindexbyid($_GET['if']); } - $hostname = gethostbyid($device); + if($device) { + $hostname = gethostbyid($device); + } + $from = $_GET['from']; $to = $_GET['to']; $width = $_GET['width']; @@ -34,6 +37,9 @@ switch ($type) { + case 'global_bits': + $graph = graph_global_bits ("global_bits.png", $from, $to, $width, $height); + break; case 'device_bits': $graph = graph_device_bits ($device, $graphfile, $from, $to, $width, $height, $title, $vertical); break; diff --git a/html/includes/print-interface.inc b/html/includes/print-interface.inc index 105505b3d..84d73b1a2 100644 --- a/html/includes/print-interface.inc +++ b/html/includes/print-interface.inc @@ -13,7 +13,7 @@ if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; } $graph_url = "graph.php?if=$if_id&from=$twoday&to=$now&width=400&height=120&type=bits"; echo(" - + ');\" onmouseout=\"return nd();\" class='$ifclass' href='?page=interface&id=$interface[id]'> $i. $inf @@ -27,9 +27,9 @@ $break = " "; } echo(""); - echo(""); + echo(""); if($speed && $speed != "") { echo("$speed"); } - echo(""); + echo(""); if($iftype && $iftype != "") { echo("$iftype"); } else { echo("-"); } echo(""); if($mac && $mac != "") { echo("$mac"); } else { echo("-"); } diff --git a/html/pages/customers.php b/html/pages/customers.php index de7657160..d091cc647 100644 --- a/html/pages/customers.php +++ b/html/pages/customers.php @@ -10,14 +10,16 @@ while($data = mysql_fetch_array($query)) { unset($class); - $iid = $data[iid]; - $ifIndex = $data[ifIndex]; - $did = $data[did]; - $hostname = $data[hostname]; - $up = $data[up]; - $up_admin = $data[up_admin]; - $ifname = fixifname($data[ifname]); - $ifalias = $data[ifalias]; + $iid = $data['iid']; + $ifIndex = $data['ifIndex']; + $did = $data['did']; + $device[id] = $did; + $device['hostname'] = $data['hostname']; + $hostname = $data['hostname']; + $up = $data['up']; + $up_admin = $data['up_admin']; + $ifname = fixifname($data['ifname']); + $ifalias = $data['ifalias']; $ifalias = str_replace("Cust: ", "", $ifalias); $ifalias = str_replace("[PNI]", "Private", $ifalias); $ifclass = ifclass($up, $up_admin); @@ -47,9 +49,9 @@ echo(" - $useifalias - $hostname - $ifname + $useifalias + " . generatedevicelink($device) . " + " . generateiflink($data, makeshortif($data['if'])) . " $notes "); diff --git a/includes/functions.php b/includes/functions.php index cc51b88bb..3a19bcd31 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -338,6 +338,7 @@ function fixifName ($inf) { $inf = str_replace("-802.1q Vlan subif", "", $inf); $inf = str_replace("serial", "Serial", $inf); $inf = str_replace("-aal5 layer", " aal5", $inf); + $inf = str_replace("null", "Null", $inf); $inf = str_replace("atm", "ATM", $inf); $inf = str_replace("port-channel", "Port-Channel", $inf); $inf = str_replace("dial", "Dial", $inf); @@ -535,17 +536,19 @@ function cpugraph ($rrd, $graph , $from, $to, $width, $height) "--title", $title, "DEF:5s=$database:LOAD5S:AVERAGE", "DEF:5m=$database:LOAD5M:AVERAGE", - "AREA:5s#FAFDCE:5sec", - "LINE1.25:5s#dd8800:", - "GPRINT:5s:LAST:Cur\:%6.2lf", - "GPRINT:5s:AVERAGE:Avg\: %6.2lf", - "GPRINT:5s:MIN:Min\:%6.2lf", - "GPRINT:5s:MAX:Max\:%6.2lf\\n", + "COMMENT: Days Current Minimum Maximum Average\\n", + "AREA:5m#c5aa00:", + "AREA:5s#ffeeaa:5 sec", + "LINE1:5s#ea8f00:", + "GPRINT:5s:LAST:%6.2lf ", + "GPRINT:5s:AVERAGE:%6.2lf ", + "GPRINT:5s:MAX:%6.2lf ", + "GPRINT:5s:AVERAGE:%6.2lf\\n", "LINE1.25:5m#aa2200:5min", - "GPRINT:5m:LAST:Cur\:%6.2lf", - "GPRINT:5m:AVERAGE:Avg\: %6.2lf", - "GPRINT:5m:MIN:Min\:%6.2lf", - "GPRINT:5m:MAX:Max\:%6.2lf\\n"); + "GPRINT:5m:LAST:%6.2lf ", + "GPRINT:5m:AVERAGE:%6.2lf ", + "GPRINT:5m:MAX:%6.2lf ", + "GPRINT:5m:AVERAGE:%6.2lf\\n"); if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font", "--font", "AXIS:6:$mono_font", @@ -556,45 +559,7 @@ function cpugraph ($rrd, $graph , $from, $to, $width, $height) if( !is_array($ret) ) { $err = rrd_error(); - #echo "rrd_graph() ERROR: $err\n"; - return FALSE; - } else { - return $imgfile; - } -} - -function tempgraph ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) -{ - global $rrdtool, $installdir, $mono_font; - $database = "rrd/" . $rrd; - $imgfile = "graphs/" . "$graph"; - - $optsa = array( "--start", $from, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max", - "-E", "-l 0", "--title", $title, - "DEF:in=$database:TEMPIN1:AVERAGE", - "DEF:out=$database:TEMPOUT1:AVERAGE", - "LINE1.5:in#cc0000:Inlet ", - "GPRINT:in:LAST: Cur\:%6.2lf", - "GPRINT:in:AVERAGE:Avg\: %6.2lf", - "GPRINT:in:MIN:Min\:%6.2lf", - "GPRINT:in:MAX:Max\:%6.2lf\\n", - "LINE1.25:out#009900:Outlet ", - "GPRINT:out:LAST:Cur\:%6.2lf", - "GPRINT:out:AVERAGE:Avg\: %6.2lf", - "GPRINT:out:MIN:Min\:%6.2lf", - "GPRINT:out:MAX:Max\:%6.2lf\\n"); - - if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font", - "--font", "AXIS:6:$mono_font", - "--font-render-mode", "normal");} - $opts = array_merge($optsa, $optsb); - - - $ret = rrd_graph("$imgfile", $opts, count($opts)); - - if( !is_array($ret) ) { - $err = rrd_error(); -# echo "rrd_graph() ERROR: $err\n"; + echo "rrd_graph() ERROR: $err\n"; return FALSE; } else { return $imgfile; @@ -610,11 +575,13 @@ function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $verti "-E", "-l 0", "DEF:uptime=$rrd:uptime:AVERAGE", "CDEF:cuptime=uptime,86400,/", + "COMMENT: Days Current Minimum Maximum Average\\n", "AREA:cuptime#EEEEEE:Uptime", "LINE1.25:cuptime#36393D:", - "GPRINT:cuptime:LAST:Cur\:%6.2lf", - "GPRINT:cuptime:AVERAGE:Avg\: %6.2lf", - "GPRINT:cuptime:MAX:Max\:%6.2lf\\n"); + "GPRINT:cuptime:LAST:%6.2lf ", + "GPRINT:cuptime:AVERAGE:%6.2lf ", + "GPRINT:cuptime:MAX:%6.2lf ", + "GPRINT:cuptime:AVERAGE:%6.2lf\\n"); if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font", "--font", "AXIS:6:$mono_font", "--font-render-mode", "normal");} @@ -625,7 +592,7 @@ function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $verti if( !is_array($ret) ) { $err = rrd_error(); - # echo "rrd_graph() ERROR: $err\n"; +# echo "rrd_graph() ERROR: $err\n"; return FALSE; } else { return $imgfile; @@ -651,9 +618,19 @@ function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical DEF:PROCUSED=$memrrd:PROCUSED:AVERAGE \ CDEF:FREE=IOFREE,PROCFREE,+ \ CDEF:USED=IOUSED,PROCUSED,+ \ - AREA:USED#ee9900:Used \ - AREA:FREE#FAFDCE:Free:STACK \ - LINE1.5:MEMTOTAL#cc0000:"; + COMMENT:'Bytes Current Minimum Maximum Average\\n' \ + AREA:USED#f0e0a0:Used\ + GPRINT:USED:LAST:\%6.2lf%s\ + GPRINT:USED:MIN:%6.2lf%s\ + GPRINT:USED:MAX:%6.2lf%s\ + GPRINT:USED:AVERAGE:'%6.2lf%s \\n'\ + AREA:FREE#cccccc:Free:STACK\ + GPRINT:FREE:LAST:\%6.2lf%s\ + GPRINT:FREE:MIN:%6.2lf%s\ + GPRINT:FREE:MAX:%6.2lf%s\ + GPRINT:FREE:AVERAGE:%6.2lf%s\ + LINE1:USED#d0b080:\ + LINE1:MEMTOTAL#000000:"; if($width <= "300") {$opts .= "\ --font LEGEND:7:$mono_font \ diff --git a/includes/graphing.php b/includes/graphing.php index 91d8071f4..8d5521c1a 100644 --- a/includes/graphing.php +++ b/includes/graphing.php @@ -40,6 +40,91 @@ function temp_graph ($device, $graph, $from, $to, $width, $height, $title, $vert } } +function graph_global_bits ($graph, $from, $to, $width, $height) { + + global $rrdtool, $installdir, $mono_font, $rrd_dir; + $imgfile = "graphs/" . $graph; + $opts = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; + + $query = mysql_query("SELECT `ifIndex`, I.id as id, D.hostname FROM `interfaces` AS I, `devices` AS D WHERE I.host = D.id AND I.iftype LIKE '%ethernet%'"); + + while($int = mysql_fetch_row($query)) { + $hostname = $int[2]; + $id = $int[1]; + if(is_file($rrd_dir . "/" . $hostname . "." . $int[0] . ".rrd")) { + $opts .= "DEF:inoctets" . $int[1] . "=" . $rrd_dir . "/" . $hostname . "." . $int[0] . ".rrd:INOCTETS:AVERAGE \ +DEF:outoctets" . $int[1] . "=" . $rrd_dir . "/" . $hostname . "." . $int[0] . ".rrd:OUTOCTETS:AVERAGE \ +"; + $in_thing .= $seperator . "inoctets" . $int[1] . ",UN,0," . "inoctets" . $int[1] . ",IF"; + $out_thing .= $seperator . "outoctets" . $int[1] . ",UN,0," . "outoctets" . $int[1] . ",IF"; + $pluses .= $plus; + $seperator = ","; + $plus = ",+"; + } + } + + $opts .= " CDEF:inoctets=" . $in_thing . $pluses . " \ + CDEF:outoctets=" . $out_thing . $pluses . " \ + CDEF:doutoctets=outoctets,-1,* \ + CDEF:inbits=inoctets,8,* \ + CDEF:outbits=outoctets,8,* \ + CDEF:doutbits=doutoctets,8,* \ + AREA:inbits#CDEB8B: \ + COMMENT:BPS Current Average Max 95th %\\n \ + LINE1.25:inbits#006600:In \ + GPRINT:inbits:LAST:%6.2lf%s \ + GPRINT:inbits:AVERAGE:%6.2lf%s \ + GPRINT:inbits:MAX:%6.2lf%s\l \ + AREA:doutbits#C3D9FF: \ + LINE1.25:doutbits#000099:Out \ + GPRINT:outbits:LAST:%6.2lf%s \ + GPRINT:outbits:AVERAGE:%6.2lf%s \ + GPRINT:outbits:MAX:%6.2lf%s "; + + + if($width <= '300') { + $opts .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; + } + + echo("
");
+  echo($imgfile . "\n" . $opts);
+
+
+  $cmd = "/usr/bin/rrdtool";
+
+  `rm /tmp/poo`;
+  $handle = fopen("/tmp/poo", "w");
+  fwrite($handle, " graph test.png " . $opts);
+
+  if (( $fh = popen($cmd, 'r')) === false)
+       die("Open failed : ${php_errormsg}\n");
+
+  fwrite($fh, " graph $imgfile " . $opts);
+
+
+  pclose($fh);
+
+  
+
+  echo`$rrdtool graph $imgfile $opts`;
+
+
+#  $ret = rrd_graph("$imgfile", $opts, count($opts));
+
+#  if( !is_array($ret) )
+#  {
+ #   $err = rrd_error();
+#    echo "rrd_graph() ERROR: $err\n";
+#  if ( !is_file($installdir . $imgfile) ) {
+#    return FALSE;
+#  } else {
+    return $imgfile;
+#  }
+
+}
+
+
+
 function graph_device_bits ($device, $graph, $from, $to, $width, $height)
 {
   global $rrdtool, $installdir, $mono_font, $rrd_dir;
@@ -76,7 +161,7 @@ function graph_device_bits ($device, $graph, $from, $to, $width, $height)
                  "CDEF:outbits=outoctets,8,*",
                  "CDEF:doutbits=doutoctets,8,*",
                  "AREA:inbits#CDEB8B:",
-                 "COMMENT:BPS    Current   Average      Max   95th %\\n",
+                 "COMMENT:BPS    Current   Average      Max\\n",
                  "LINE1.25:inbits#006600:In ",
                  "GPRINT:inbits:LAST:%6.2lf%s",
                  "GPRINT:inbits:AVERAGE:%6.2lf%s",
diff --git a/poll-interface.php b/poll-interface.php
index 90dde221d..9d6d6d59a 100755
--- a/poll-interface.php
+++ b/poll-interface.php
@@ -28,7 +28,6 @@ while ($interface = mysql_fetch_array($interface_query)) {
   $snmp_output = trim($snmp_output);
   $snmp_output = str_replace("No Such Object available on this agent at this OID", "", $snmp_output);
   $snmp_output = str_replace("No Such Instance currently exists at this OID", "", $snmp_output);
-
   $ifPhysAddress = strtolower(str_replace("\"", "", $ifPhysAddress));
   $ifPhysAddress = str_replace(" ", ":", $ifPhysAddress);
   echo("Looking at $old_if on $hostname \n");
@@ -39,6 +38,8 @@ while ($interface = mysql_fetch_array($interface_query)) {
   if ($ifAlias == " ") { $ifAlias = str_replace(" ", "", $ifAlias); }
   $ifAlias = trim(str_replace("\"", "", $ifAlias));
   $ifAlias = trim($ifAlias);
+  if($interface['os'] == "IOS") { $ifType = trim(str_replace("\"", "", `snmpget -O qv -v2c -c $community $hostname 1.3.6.1.4.1.9.2.2.1.1.1.$ifIndex`)); }
+
 
   $rrdfile = "rrd/" . $hostname . ".". $ifIndex . ".rrd";
   if(!is_file($rrdfile)) {