adding new graphing types

git-svn-id: http://www.observium.org/svn/observer/trunk@491 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-10-27 13:04:16 +00:00
parent 5ae22069f4
commit bb969a845a
31 changed files with 1013 additions and 137 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
include("common.inc.php");
$rrd_options .= " -u 100 -l 0 -E -b 1024 ";
$iter = "1";
$sql = mysql_query("SELECT * FROM `cempMemPool` AS C, `devices` AS D where C.`cempMemPool_id` = '".mres($_GET['id'])."' AND C.device_id = D.device_id");
$rrd_options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n";
while($mempool = mysql_fetch_array($sql)) {
$entPhysicalName = mysql_result(mysql_query("SELECT entPhysicalName from entPhysical WHERE device_id = '".$mempool['device_id']."'
AND entPhysicalIndex = '".$mempool['entPhysicalIndex']."'"),0);
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$mempool['descr_fixed'] = $entPhysicalName . " " . $mempool['cempMemPoolName'];
$mempool['descr_fixed'] = str_replace("Routing Processor", "RP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Switching Processor", "SP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Processor", "Proc", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_pad($mempool['descr_fixed'], 28);
$mempool['descr_fixed'] = substr($mempool['descr_fixed'],0,28);
$oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index'];
$rrd = $config['rrd_dir'] . "/".$mempool['hostname']."/cempMemPool-$oid.rrd";
$id = $mempool['entPhysicalIndex'] . "-" . $mempool['Index'];
$rrd_options .= " DEF:mempool" . $id . "free=$rrd:free:AVERAGE ";
$rrd_options .= " DEF:mempool" . $id . "used=$rrd:used:AVERAGE ";
$rrd_options .= " CDEF:mempool" . $id . "total=mempool" . $id . "used,mempool" . $id . "used,mempool" . $id . "free,+,/,100,* ";
$rrd_options .= " LINE1:mempool" . $id . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' ";
$rrd_options .= " GPRINT:mempool" . $id . "total:LAST:%3.0lf";
$rrd_options .= " GPRINT:mempool" . $id . "total:MAX:%3.0lf\\\l ";
$iter++;
}
?>
@@ -0,0 +1,25 @@
<?php
include("common.inc.php");
$sensor = mysql_fetch_array(mysql_query("SELECT * FROM entPhysical as E, devices as D WHERE entPhysical_id = '".mres($_GET['a'])."' and D.device_id = E.device_id"));
$rrd_filename = $config['rrd_dir'] . "/" . $sensor['hostname'] . "/ces-" . $sensor['entPhysicalIndex'] . ".rrd";
$type = str_pad($sensor['entSensorType'], 8);
$type = substr($type,0,8);
$rrd_options .= " DEF:avg=$rrd_filename:value:AVERAGE";
$rrd_options .= " DEF:min=$rrd_filename:value:MIN";
$rrd_options .= " DEF:max=$rrd_filename:value:MAX";
$rrd_options .= " COMMENT:' Last Min Max Ave\\n'";
$rrd_options .= " AREA:max#a5a5a5";
$rrd_options .= " AREA:min#ffffff";
$rrd_options .= " LINE1.25:avg#aa2200:'".$type."'";
$rrd_options .= " GPRINT:avg:AVERAGE:%5.2lf%s";
$rrd_options .= " GPRINT:max:MAX:%5.2lf%s";
$rrd_options .= " GPRINT:max:MAX:%5.2lf%s";
$rrd_options .= " GPRINT:avg:LAST:%5.2lf%s";
?>
+24 -6
View File
@@ -1,12 +1,30 @@
<?php
global $config, $installdir;
$graphfile = $config['install_dir'] . "/graphs/" . $args['graphfile'];
if($_GET['from']) { $from = mres($_GET['from']); }
if($_GET['to']) { $to = mres($_GET['to']); }
if($_GET['width']) { $width = mres($_GET['width']); }
if($_GET['height']) { $height = mres($_GET['height']); }
$options .= " --alt-autoscale-max -E --start ".$args['from']." --end " . ($args['to'] - 150) . " --width ".$args['width']." --height ".$args['height']." ";
$options .= $config['rrdgraph_def_text'];
if($_GET['bg']) { $bg = mres($_GET['bg']); }
if($args['height'] < "99") { $options .= " --only-graph"; }
if($args['width'] <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; }
if($_GET['inverse']) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; }
if($_GET['legend'] == "no") { $rrd_options = " -g"; }
#if($bg) { $rrd_options .= " -c CANVAS#" . $bg . " "; }
if(!$scale_min && !$scale_max) { $rrd_options .= " --alt-autoscale-max"; }
if($scale_min) { $rrd_options .= " -l $scale_min"; }
if($scale_max) { $rrd_options .= " -u $scale_max"; }
$rrd_options .= " -E --start ".$from." --end " . ($to - 150) . " --width ".$width." --height ".$height." ";
$rrd_options .= $config['rrdgraph_def_text'];
$rrd_options .= " -c BACK#FFFFFF";
if($height < "99") { $rrd_options .= " --only-graph"; }
if($width <= "300") { $rrd_options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal";
} else { $rrd_options .= " --font LEGEND:8:".$config['mono_font']." --font AXIS:7:".$config['mono_font']." --font-render-mode normal"; }
?>
+12 -6
View File
@@ -2,18 +2,24 @@
## Generate a list of interfaces and then call the multi_bits grapher to generate from the list
$device = $_GET['device'];
$device = mres($_GET['device']);
$hostname = gethostbyid($device);
$query = mysql_query("SELECT `ifIndex`,`interface_id` FROM `interfaces` WHERE `device_id` = '$device' AND `ifType` NOT LIKE '%oopback%' AND `ifType` NOT LIKE '%SVI%' AND `ifType` != 'l2vlan'");
$pluses = "";
while($int = mysql_fetch_row($query)) {
if(is_file($config['rrd_dir'] . "/" . $hostname . "/" . $int[0] . ".rrd")) {
$interfaces .= $seperator . $int[1];
$seperator = ",";
$rrd_filenames[] = $config['rrd_dir'] . "/" . $hostname . "/" . $int[0] . ".rrd";
}
}
include ("multi_bits.inc.php");
$rra_in = "INOCTETS";
$rra_out = "OUTOCTETS";
$colour_line_in = "006600";
$colour_line_out = "000099";
$colour_area_in = "CDEB8B";
$colour_area_out = "C3D9FF";
include ("generic_multi_bits.inc.php");
?>
+7
View File
@@ -0,0 +1,7 @@
<?php
if($os == "Linux" || $os == "NetBSD" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "Windows" || $os == "m0n0wall" || $os == "Voswall" || $os == "pfSense" || $os == "DragonFly" || $os == "OpenBSD") {
include("device_cpu_unix.inc.php");
}
?>
@@ -0,0 +1,36 @@
<?php
$query = mysql_query("SELECT * FROM `cpmCPU` where `device_id` = '".mres($device_id)."'");
$i=0;
while($proc = mysql_fetch_array($query)) {
$rrd_filename = $config['rrd_dir'] . "/$hostname/cpmCPU-" . $proc['cpmCPU_oid'] . ".rrd";
if(is_file($rrd_filename)) {
$descr = str_pad($proc['entPhysicalDescr'], 8);
$descr = substr($descr,0,8);
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $descr;
$rrd_list[$i]['rra'] = "usage";
$i++;
}
}
$unit_text = "Load %";
$units='%';
$total_units='%';
$colours='mixed';
$scale_min = "0";
$scale_max = "100";
$nototal = 1;
include ("generic_multi_line.inc.php");
?>
@@ -0,0 +1,34 @@
<?php
include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . "cpu.rrd";
$rrd_options .= " DEF:user=$rrd_filename:user:AVERAGE";
$rrd_options .= " DEF:nice=$rrd_filename:nice:AVERAGE";
$rrd_options .= " DEF:system=$rrd_filename:system:AVERAGE";
$rrd_options .= " DEF:idle=$rrd_filename:idle:AVERAGE";
$rrd_options .= " CDEF:total=user,nice,system,idle,+,+,+";
$rrd_options .= " CDEF:user_perc=user,total,/,100,*";
$rrd_options .= " CDEF:nice_perc=nice,total,/,100,*";
$rrd_options .= " CDEF:system_perc=system,total,/,100,*";
$rrd_options .= " CDEF:idle_perc=idle,total,/,100,*";
$rrd_options .= " COMMENT:Usage\ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ Maximum\\\\n";
$rrd_options .= " AREA:user_perc#c02020:user";
$rrd_options .= " GPRINT:user_perc:LAST:\ \ \ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:user_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:user_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$rrd_options .= " AREA:nice_perc#008f00:nice:STACK";
$rrd_options .= " GPRINT:nice_perc:LAST:\ \ \ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:nice_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:nice_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$rrd_options .= " AREA:system_perc#ea8f00:system:STACK";
$rrd_options .= " GPRINT:system_perc:LAST:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:system_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:system_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$rrd_options .= " AREA:idle_perc#f5f5e5:idle:STACK";
$rrd_options .= " GPRINT:idle_perc:LAST:\ \ \ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:idle_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:idle_perc:MAX:\ \ \ %5.2lf%%\\\\n";
?>
+51
View File
@@ -0,0 +1,51 @@
<?php
include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/netinfo.rrd";
$rrd_options .= " DEF:icmpInMsgs=$rrd_filename:icmpInMsgs:AVERAGE";
$rrd_options .= " DEF:icmpOutMsgs=$rrd_filename:icmpOutMsgs:AVERAGE";
$rrd_options .= " DEF:icmpInErrors=$rrd_filename:icmpInErrors:AVERAGE";
$rrd_options .= " DEF:icmpOutErrors=$rrd_filename:icmpOutErrors:AVERAGE";
$rrd_options .= " DEF:icmpInEchos=$rrd_filename:icmpInEchos:AVERAGE";
$rrd_options .= " DEF:icmpOutEchos=$rrd_filename:icmpOutEchos:AVERAGE";
$rrd_options .= " DEF:icmpInEchoReps=$rrd_filename:icmpInEchoReps:AVERAGE";
$rrd_options .= " DEF:icmpOutEchoReps=$rrd_filename:icmpOutEchoReps:AVERAGE";
$rrd_options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ \ Average\ \ \ Maximum\\\\n";
$rrd_options .= " LINE1.25:icmpInMsgs#00cc00:InMsgs ";
$rrd_options .= " GPRINT:icmpInMsgs:LAST:\ \ \ \ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpInMsgs:AVERAGE:\ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpInMsgs:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:icmpOutMsgs#006600:OutMsgs ";
$rrd_options .= " GPRINT:icmpOutMsgs:LAST:\ \ \ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpOutMsgs:AVERAGE:\ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpOutMsgs:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:icmpInErrors#cc0000:InErrors ";
$rrd_options .= " GPRINT:icmpInErrors:LAST:\ \ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpInErrors:AVERAGE:\ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpInErrors:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:icmpOutErrors#660000:OutErrors ";
$rrd_options .= " GPRINT:icmpOutErrors:LAST:\ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpOutErrors:AVERAGE:\ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpOutErrors:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:icmpInEchos#0066cc:InEchos ";
$rrd_options .= " GPRINT:icmpInEchos:LAST:\ \ \ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpInEchos:AVERAGE:\ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpInEchos:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:icmpOutEchos#003399:OutEchos ";
$rrd_options .= " GPRINT:icmpOutEchos:LAST:\ \ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpOutEchos:AVERAGE:\ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpOutEchos:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:icmpInEchoReps#cc00cc:InEchoReps ";
$rrd_options .= " GPRINT:icmpInEchoReps:LAST:\ %6.2lf%s";
$rrd_options .= " GPRINT:icmpInEchoReps:AVERAGE:\ \ %6.2lf%s";
$rrd_options .= " GPRINT:icmpInEchoReps:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:icmpOutEchoReps#990099:OutEchoReps";
$rrd_options .= " GPRINT:icmpOutEchoReps:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:icmpOutEchoReps:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:icmpOutEchoReps:MAX:\ %6.2lf%s\\\\n";
?>
+44
View File
@@ -0,0 +1,44 @@
<?php
include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/netinfo.rrd";
$rrd_options .= " DEF:ipForwDatagrams=$rrd_filename:ipForwDatagrams:AVERAGE";
$rrd_options .= " DEF:ipInDelivers=$rrd_filename:ipInDelivers:AVERAGE";
$rrd_options .= " DEF:ipInReceives=$rrd_filename:ipInReceives:AVERAGE";
$rrd_options .= " DEF:ipOutRequests=$rrd_filename:ipOutRequests:AVERAGE";
$rrd_options .= " DEF:ipInDiscards=$rrd_filename:ipInDiscards:AVERAGE";
$rrd_options .= " DEF:ipOutDiscards=$rrd_filename:ipOutDiscards:AVERAGE";
$rrd_options .= " DEF:ipOutNoRoutes=$rrd_filename:ipInDiscards:AVERAGE";
$rrd_options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ Average\ \ \ Maximum\\\\n";
$rrd_options .= " LINE1.25:ipForwDatagrams#cc0000:ForwDgrams\ ";
$rrd_options .= " GPRINT:ipForwDatagrams:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ipForwDatagrams:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:ipForwDatagrams:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:ipInDelivers#00cc00:InDelivers\ ";
$rrd_options .= " GPRINT:ipInDelivers:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ipInDelivers:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:ipInDelivers:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:ipInReceives#006600:InReceives\ ";
$rrd_options .= " GPRINT:ipInReceives:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ipInReceives:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:ipInReceives:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:ipOutRequests#0000cc:OutRequests";
$rrd_options .= " GPRINT:ipOutRequests:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ipOutRequests:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:ipOutRequests:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:ipInDiscards#cccc00:InDiscards\ ";
$rrd_options .= " GPRINT:ipInDiscards:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ipInDiscards:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:ipInDiscards:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:ipOutDiscards#330033:OutDiscards";
$rrd_options .= " GPRINT:ipOutDiscards:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ipOutDiscards:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:ipOutDiscards:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:ipOutNoRoutes#660000:OutNoRoutes";
$rrd_options .= " GPRINT:ipOutNoRoutes:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ipOutNoRoutes:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:ipOutNoRoutes:MAX:\ %6.2lf%s\\\\n";
?>
@@ -0,0 +1,3 @@
<?php
?>
@@ -0,0 +1,34 @@
<?php
include("common.inc.php");
$rrd_options .= " -l 0 -E -b 1024 -u 100 -r";
$iter = "1";
$rrd_options .= " COMMENT:' Cur Max\\n'";
$sql = mysql_query("SELECT * FROM `cempMemPool` where `device_id` = '$device_id'");
while($mempool = mysql_fetch_array($sql)) {
$entPhysicalName = mysql_result(mysql_query("SELECT entPhysicalName from entPhysical WHERE device_id = '".$device_id."'
AND entPhysicalIndex = '".$mempool['entPhysicalIndex']."'"),0);
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$mempool['descr_fixed'] = $entPhysicalName . " " . $mempool['cempMemPoolName'];
$mempool['descr_fixed'] = str_replace("Routing Processor", "RP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Switching Processor", "SP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Processor", "Proc", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_pad($mempool['descr_fixed'], 28);
$mempool['descr_fixed'] = substr($mempool['descr_fixed'],0,28);
$oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index'];
$rrd = $config['rrd_dir'] . "/$hostname/cempMemPool-$oid.rrd";
$rrd_options .= " DEF:mempool" . $iter . "free=$rrd:free:AVERAGE ";
$rrd_options .= " DEF:mempool" . $iter . "used=$rrd:used:AVERAGE ";
$rrd_options .= " CDEF:mempool" . $iter . "total=mempool" . $iter . "used,mempool" . $iter . "used,mempool" . $iter . "free,+,/,100,* ";
$rrd_options .= " LINE1:mempool" . $iter . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' ";
$rrd_options .= " GPRINT:mempool" . $iter . "total:LAST:%3.0lf";
$rrd_options .= " GPRINT:mempool" . $iter . "total:MAX:%3.0lf\\\l ";
$iter++;
}
?>
+45
View File
@@ -0,0 +1,45 @@
<?php
include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/netinfo.rrd";
$rrd_options .= " DEF:icmpInMsgs=$rrd_filename:icmpInMsgs:AVERAGE";
$rrd_options .= " DEF:tcpActiveOpens=$rrd_filename:tcpActiveOpens:AVERAGE";
$rrd_options .= " DEF:tcpPassiveOpens=$rrd_filename:tcpPassiveOpens:AVERAGE";
$rrd_options .= " DEF:tcpAttemptFails=$rrd_filename:tcpAttemptFails:AVERAGE";
$rrd_options .= " DEF:tcpEstabResets=$rrd_filename:tcpEstabResets:AVERAGE";
$rrd_options .= " DEF:tcpInSegs=$rrd_filename:tcpInSegs:AVERAGE";
$rrd_options .= " DEF:tcpOutSegs=$rrd_filename:tcpOutSegs:AVERAGE";
$rrd_options .= " DEF:tcpRetransSegs=$rrd_filename:tcpRetransSegs:AVERAGE";
$rrd_options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ \ Average\ \ \ Maximum\\\\n";
$rrd_options .= " LINE1.25:tcpActiveOpens#00cc00:ActiveOpens\ ";
$rrd_options .= " GPRINT:tcpActiveOpens:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:tcpActiveOpens:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:tcpActiveOpens:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:tcpPassiveOpens#006600:PassiveOpens";
$rrd_options .= " GPRINT:tcpPassiveOpens:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:tcpPassiveOpens:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:tcpPassiveOpens:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:tcpAttemptFails#cc0000:AttemptFails";
$rrd_options .= " GPRINT:tcpAttemptFails:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:tcpAttemptFails:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:tcpAttemptFails:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:tcpEstabResets#660000:EstabResets\ ";
$rrd_options .= " GPRINT:tcpEstabResets:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:tcpEstabResets:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:tcpEstabResets:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:tcpInSegs#0066cc:InSegs\ \ \ \ \ \ ";
$rrd_options .= " GPRINT:tcpInSegs:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:tcpInSegs:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:tcpInSegs:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:tcpOutSegs#003399:OutSegs\ \ \ \ \ ";
$rrd_options .= " GPRINT:tcpOutSegs:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:tcpOutSegs:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:tcpOutSegs:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:tcpRetransSegs#cc00cc:RetransSegs\ ";
$rrd_options .= " GPRINT:tcpRetransSegs:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:tcpRetransSegs:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:tcpRetransSegs:MAX:\ %6.2lf%s\\\\n";
?>
@@ -0,0 +1,28 @@
<?php
include("common.inc.php");
$rrd_options .= " -l 0 -E ";
$iter = "1";
$sql = mysql_query("SELECT * FROM temperature where temp_host = '$device_id'");
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
while($temperature = mysql_fetch_array($sql)) {
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$temperature['temp_descr_fixed'] = str_pad($temperature['temp_descr'], 22);
$temperature['temp_descr_fixed'] = substr($temperature['temp_descr_fixed'],0,22);
$temprrd = addslashes($config['rrd_dir'] . "/$hostname/temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = str_replace(")", "_", $temprrd);
$temprrd = str_replace("(", "_", $temprrd);
$rrd_options .= " DEF:temp" . $temperature[temp_id] . "=$temprrd:temp:AVERAGE ";
$rrd_options .= " LINE1:temp" . $temperature[temp_id] . "#" . $colour . ":'" . $temperature[temp_descr_fixed] . "' ";
$rrd_options .= " GPRINT:temp" . $temperature[temp_id] . ":LAST:%3.0lfC ";
$rrd_options .= " GPRINT:temp" . $temperature[temp_id] . ":MIN:%3.0lfC ";
$rrd_options .= " GPRINT:temp" . $temperature[temp_id] . ":MAX:%3.0lfC\\\l ";
$iter++;
}
?>
+31
View File
@@ -0,0 +1,31 @@
<?php
include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/netinfo.rrd";
$rrd_options .= " DEF:icmpInMsgs=$rrd_filename:icmpInMsgs:AVERAGE";
$rrd_options .= " DEF:udpInDatagrams=$rrd_filename:udpInDatagrams:AVERAGE";
$rrd_options .= " DEF:udpOutDatagrams=$rrd_filename:udpOutDatagrams:AVERAGE";
$rrd_options .= " DEF:udpInErrors=$rrd_filename:udpInErrors:AVERAGE";
$rrd_options .= " DEF:udpNoPorts=$rrd_filename:udpNoPorts:AVERAGE";
$rrd_options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ \ Average\ \ \ Maximum\\\\n";
$rrd_options .= " LINE1.25:udpInDatagrams#00cc00:InDatagrams\ ";
$rrd_options .= " GPRINT:udpInDatagrams:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:udpInDatagrams:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:udpInDatagrams:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:udpOutDatagrams#006600:OutDatagrams";
$rrd_options .= " GPRINT:udpOutDatagrams:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:udpOutDatagrams:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:udpOutDatagrams:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:udpInErrors#cc0000:InErrors\ \ \ \ ";
$rrd_options .= " GPRINT:udpInErrors:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:udpInErrors:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:udpInErrors:MAX:\ %6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:udpNoPorts#660000:NoPorts\ \ \ \ \ ";
$rrd_options .= " GPRINT:udpNoPorts:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:udpNoPorts:AVERAGE:\ %6.2lf%s";
$rrd_options .= " GPRINT:udpNoPorts:MAX:\ %6.2lf%s\\\\n";
?>
@@ -0,0 +1,17 @@
<?php
include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/uptime.rrd";
$rrd_options .= " DEF:uptime=$rrd_filename:uptime:AVERAGE";
$rrd_options .= " CDEF:cuptime=uptime,86400,/";
$rrd_options .= " COMMENT:Days\ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\ \ Average\\\\n";
$rrd_options .= " AREA:cuptime#EEEEEE:Uptime";
$rrd_options .= " LINE1.25:cuptime#36393D:";
$rrd_options .= " GPRINT:cuptime:LAST:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\ ";
$rrd_options .= " GPRINT:cuptime:MAX:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\\\\n";
$scale_min = "0";
?>
+54
View File
@@ -0,0 +1,54 @@
<?php
/// Draw generic bits graph
/// args: rra_in, rra_out, rrd_filename, bg, legend, from, to, width, height, inverse
include("common.inc.php");
if($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; }
$rrd_options .= " DEF:".$out."octets=".$rrd_filename.":".$rra_out.":AVERAGE";
$rrd_options .= " DEF:".$in."octets=".$rrd_filename.":".$rra_in.":AVERAGE";
$rrd_options .= " DEF:".$out."octets_max=".$rrd_filename.":".$rra_out.":MAX";
$rrd_options .= " DEF:".$in."octets_max=".$rrd_filename.":".$rra_in.":MAX";
$rrd_options .= " CDEF:octets=inoctets,outoctets,+";
$rrd_options .= " CDEF:doutoctets=outoctets,-1,*";
$rrd_options .= " CDEF:inbits=inoctets,8,*";
$rrd_options .= " CDEF:inbits_max=inoctets_max,8,*";
$rrd_options .= " CDEF:outbits_max=outoctets_max,8,*";
$rrd_options .= " CDEF:doutoctets_max=outoctets_max,-1,*";
$rrd_options .= " CDEF:doutbits_max=doutoctets_max,8,*";
$rrd_options .= " CDEF:outbits=outoctets,8,*";
$rrd_options .= " CDEF:doutbits=doutoctets,8,*";
$rrd_options .= " VDEF:totin=inoctets,TOTAL";
$rrd_options .= " VDEF:totout=outoctets,TOTAL";
$rrd_options .= " VDEF:tot=octets,TOTAL";
$rrd_options .= " VDEF:95thin=inbits,95,PERCENT";
$rrd_options .= " VDEF:95thout=outbits,95,PERCENT";
$rrd_options .= " VDEF:d95thout=doutbits,5,PERCENT";
$rrd_options .= " AREA:inbits_max#aDEB7B:";
$rrd_options .= " AREA:inbits#CDEB8B:";
$rrd_options .= " COMMENT:BPS\ \ \ \ Now\ \ \ \ \ \ \ Ave\ \ \ \ \ \ Max\ \ \ \ \ \ 95th\ %\\\\n";
$rrd_options .= " LINE1.25:inbits#006600:In\ ";
$rrd_options .= " GPRINT:inbits:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:inbits:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:inbits_max:MAX:%6.2lf%s";
$rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n";
$rrd_options .= " AREA:doutbits_max#a3b9FF:";
$rrd_options .= " AREA:doutbits#C3D9FF:";
$rrd_options .= " LINE1.25:doutbits#000099:Out";
$rrd_options .= " GPRINT:outbits:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:outbits:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:outbits_max:MAX:%6.2lf%s";
$rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n";
$rrd_options .= " GPRINT:tot:Total\ %6.2lf%s";
$rrd_options .= " GPRINT:totin:\(In\ %6.2lf%s";
$rrd_options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l";
$rrd_options .= " LINE1:95thin#aa0000";
$rrd_options .= " LINE1:d95thout#aa0000";
#echo("<pre> [ rrdtool graph $graphfile $rrd_options ] </pre> /n $rrd_filename");
?>
@@ -0,0 +1,68 @@
<?php
/// Draw generic bits graph
/// args: rra_in, rra_out, rrd_filename, bg, legend, from, to, width, height, inverse, $percentile
include("common.inc.php");
if(!$unit_text) {$unit_text = "\ \ \ \ \ \ \ ";}
$rrd_options .= " DEF:".$out."=".$rrd_filename.":".$rra_out.":AVERAGE";
$rrd_options .= " DEF:".$in."=".$rrd_filename.":".$rra_in.":AVERAGE";
$rrd_options .= " DEF:".$out."_max=".$rrd_filename.":".$rra_out.":MAX";
$rrd_options .= " DEF:".$in."_max=".$rrd_filename.":".$rra_in.":MAX";
$rrd_options .= " CDEF:dout_max=out_max,-1,*";
$rrd_options .= " CDEF:dout=out,-1,*";
$rrd_options .= " CDEF:both=in,out,+";
if($print_total) {
$rrd_options .= " VDEF:totin=in,TOTAL";
$rrd_options .= " VDEF:totout=out,TOTAL";
$rrd_options .= " VDEF:tot=both,TOTAL";
}
if($percentile) {
$rrd_options .= " VDEF:percentile_in=in,".$percentile.",PERCENT";
$rrd_options .= " VDEF:percentile_out=out,".$percentile.",PERCENT";
$rrd_options .= " VDEF:dpercentile_out=dout,".$percentile.",PERCENT";
}
if($graph_max) {
$rrd_options .= " AREA:in_max#".$colour_area_in_max.":";
$rrd_options .= " AREA:dout_max#".$colour_area_out_max.":";
}
$rrd_options .= " AREA:in#".$colour_area_in.":";
$rrd_options .= " COMMENT:".$unit_text."Now\ \ \ \ \ \ \ Ave\ \ \ \ \ \ Max";
if($percentile) {
$rrd_options .= "\ \ \ \ \ \ ".$percentile."th\ %\\\\n";
}
$rrd_options .= "\\\\n";
$rrd_options .= " LINE1.25:in#".$colour_line_in.":In\ ";
$rrd_options .= " GPRINT:in:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:in:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:in_max:MAX:%6.2lf%s";
if($percentile) {
$rrd_options .= " GPRINT:percentile_in:%6.2lf%s";
}
$rrd_options .= " COMMENT:\\\\n";
$rrd_options .= " AREA:dout#".$colour_area_out.":";
$rrd_options .= " LINE1.25:dout#".$colour_line_out.":Out";
$rrd_options .= " GPRINT:out:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:out:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:out_max:MAX:%6.2lf%s";
if($percentile) {
$rrd_options .= " GPRINT:percentile_out:%6.2lf%s";
}
$rrd_options .= " COMMENT:\\\\n";
if($print_total) {
$rrd_options .= " GPRINT:tot:Total\ %6.2lf%s";
$rrd_options .= " GPRINT:totin:\(In\ %6.2lf%s";
$rrd_options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l";
}
if($percentile) {
$rrd_options .= " LINE1:percentile_in#aa0000";
$rrd_options .= " LINE1:dpercentile_out#aa0000";
}
?>
@@ -0,0 +1,46 @@
<?php
/// Draws aggregate bits graph from multiple RRDs
/// Variables : colour_[line|area]_[in|out], rrd_filenames
include("common.inc.php");
$i=0;
foreach($rrd_filenames as $rrd_filename) {
$rrd_options .= " DEF:inoctets" . $i . "=".$rrd_filename.":".$rra_in.":AVERAGE";
$rrd_options .= " DEF:outoctets" . $i . "=".$rrd_filename.":".$rra_out.":AVERAGE";
$in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF";
$out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF";
$pluses .= $plus;
$seperator = ",";
$plus = ",+";
$i++;
}
if($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; }
$rrd_options .= " CDEF:".$in."octets=" . $in_thing . $pluses;
$rrd_options .= " CDEF:".$out."octets=" . $out_thing . $pluses;
$rrd_options .= " CDEF:doutoctets=outoctets,-1,*";
$rrd_options .= " CDEF:inbits=inoctets,8,*";
$rrd_options .= " CDEF:outbits=outoctets,8,*";
$rrd_options .= " CDEF:doutbits=doutoctets,8,*";
if($legend == 'no' || $legend == '1') {
$rrd_options .= " AREA:inbits#".$colour_area_in.":";
$rrd_options .= " LINE1.25:inbits#".$colour_line_in.":";
$rrd_options .= " AREA:doutbits#".$colour_area_out.":";
$rrd_options .= " LINE1.25:doutbits#".$colour_line_out.":";
} else {
$rrd_options .= " AREA:inbits#".$colour_area_in.":";
$rrd_options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\\\\n";
$rrd_options .= " LINE1.25:inbits#".$colour_line_in.":In\ ";
$rrd_options .= " GPRINT:inbits:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:inbits:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:inbits:MAX:%6.2lf%s\\\\l";
$rrd_options .= " AREA:doutbits#".$colour_area_out.":";
$rrd_options .= " LINE1.25:doutbits#".$colour_line_out.":Out";
$rrd_options .= " GPRINT:outbits:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:outbits:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:outbits:MAX:%6.2lf%s\\\l";
}
?>
@@ -0,0 +1,46 @@
<?php
include("common.inc.php");
$i = 0;
$rrd_options .= " COMMENT:' In\: Current Maximum '";
if(!$nototal) {$rrd_options .= " COMMENT:'Total '";}
$rrd_options .= " COMMENT:'Out\: Current Maximum'";
if(!$nototal) {$rrd_options .= " COMMENT:' Total'";}
$rrd_options .= " COMMENT:'\\\\n'";
foreach($rrd_list as $rrd) {
if(!$config['graph_colours'][$colours_in][$iter] || !$config['graph_colours'][$colours_out][$iter]) { $iter = 0; }
$colour_in=$config['graph_colours'][$colours_in][$iter];
$colour_out=$config['graph_colours'][$colours_out][$iter];
$rrd_options .= " DEF:".$in.$i."=".$rrd['filename'].":".$rra_in.":AVERAGE ";
$rrd_options .= " DEF:".$out.$i."=".$rrd['filename'].":".$rra_out.":AVERAGE ";
$rrd_options .= " CDEF:inB".$i."=in".$i.",$multiplier,* ";
$rrd_options .= " CDEF:outB".$i."=out".$i.",$multiplier,*";
$rrd_options .= " CDEF:outB".$i."_neg=outB".$i.",-1,*";
$rrd_options .= " CDEF:octets".$i."=inB".$i.",outB".$i.",+";
if(!$args['nototal']) {
$rrd_options .= " VDEF:totin".$i."=inB".$i.",TOTAL";
$rrd_options .= " VDEF:totout".$i."=outB".$i.",TOTAL";
$rrd_options .= " VDEF:tot".$i."=octets".$i.",TOTAL";
}
$rrd_options .= " HRULE:999999999999999#" . $colour_out . ":\\\s:";
if($i) {$stack="STACK";}
$rrd_options .= " AREA:inB".$i."#" . $colour_in . ":'" . substr(str_pad($rrd['descr'], 18),0,18) . "':$stack";
$rrd_optionsb .= " AREA:outB".$i."_neg#" . $colour_out . "::$stack";
$rrd_options .= " GPRINT:inB".$i.":LAST:%6.2lf%s$units";
$rrd_options .= " GPRINT:inB".$i.":MAX:%6.2lf%s$units";
if(!$nototal) { $rrd_options .= " GPRINT:totin".$i.":%6.2lf%s$total_units"; }
$rrd_options .= " COMMENT:' '";
$rrd_options .= " GPRINT:outB".$i.":LAST:%6.2lf%s$units";
$rrd_options .= " GPRINT:outB".$i.":MAX:%6.2lf%s$units";
if(!$nototal) { $rrd_options .= " GPRINT:totout".$i.":%6.2lf%s$total_unit"; }
$rrd_options .= " COMMENT:\\\\n";
$i++; $iter++;
}
$rrd_options .= $rrd_optionsb;
$rrd_options .= " HRULE:0#999999";
?>
@@ -0,0 +1,33 @@
<?php
include("common.inc.php");
$unit_text = str_pad($unit_text, 10);
$unit_text = substr($unit_text,0,10);
$i = 0;
$iter = 0;
$rrd_options .= " COMMENT:'".$unit_text." Last Min Max Avg\\n'";
foreach($rrd_list as $rrd) {
if(!$config['graph_colours'][$colours][$iter]) { $iter = 0; }
$colour=$config['graph_colours'][$colours][$iter];
$rra = $rrd['rra'];
$filename = $rrd['filename'];
$descr = $rrd['descr'];
$id = $rra."_".$i;
$rrd_options .= " DEF:".$id."=$filename:$rra:AVERAGE";
$rrd_options .= " LINE1.25:".$id."#".$colour.":'$descr'";
$rrd_options .= " GPRINT:".$id.":LAST:%6.2lf GPRINT:".$id.":AVERAGE:%6.2lf";
$rrd_options .= " GPRINT:".$id.":MAX:%6.2lf GPRINT:".$id.":AVERAGE:%6.2lf\\\\n";
$i++; $iter++;
}
?>
@@ -0,0 +1,46 @@
<?php
/// Draw generic bits graph
/// args: rra_in, rra_out, rrd_filename, bg, legend, from, to, width, height, inverse, $percentile
include("common.inc.php");
if(!$unit_text) {$unit_text = "\ \ \ \ \ \ \ ";}
$rrd_options .= " DEF:".$in."=".$rrd_filename.":".$rra_in.":AVERAGE";
$rrd_options .= " DEF:".$in."_max=".$rrd_filename.":".$rra_out.":MAX";
if($print_total) {
$rrd_options .= " VDEF:totin=in,TOTAL";
}
if($percentile) {
$rrd_options .= " VDEF:percentile_in=in,".$percentile.",PERCENT";
}
if($graph_max) {
$rrd_options .= " AREA:in_max#".$colour_area_in_max.":";
}
$rrd_options .= " AREA:in#".$colour_area_in.":";
$rrd_options .= " COMMENT:".$unit_text."Now\ \ \ \ \ \ \ Ave\ \ \ \ \ \ Max";
if($percentile) {
$rrd_options .= "\ \ \ \ \ \ ".$percentile."th\ %\\\\n";
}
$rrd_options .= "\\\\n";
$rrd_options .= " LINE1.25:in#".$colour_line_in.":In\ ";
$rrd_options .= " GPRINT:in:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:in:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:in_max:MAX:%6.2lf%s";
if($percentile) {
$rrd_options .= " GPRINT:percentile_in:%6.2lf%s";
}
$rrd_options .= "\\\\n";
$rrd_options .= " COMMENT:\\\\n";
if($print_total) {
$rrd_options .= " GPRINT:tot:Total\ %6.2lf%s\)\\\\l";
}
if($percentile) {
$rrd_options .= " LINE1:percentile_in#aa0000";
}
?>
+9 -6
View File
@@ -1,13 +1,16 @@
<?php
function graph_mac_acc_bits ($id, $graph, $from, $to, $width, $height) {
global $config;
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".$id."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id");
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".mres($_GET['id'])."'
AND I.interface_id = M.interface_id AND I.device_id = D.device_id");
$acc = mysql_fetch_array($query);
$database = $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd";
return graph_bits ($database, $graph, $from, $to, $width, $height, $title, $vertical);
if(is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")) {
$rrd_filename = $config['rrd_dir'] . "/" . $acc['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd";
}
$rra_in = "IN";
$rra_out = "OUT";
include("generic_bits.inc.php");
?>
+27
View File
@@ -0,0 +1,27 @@
<?php
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".mres($_GET['id'])."'
AND I.interface_id = M.interface_id AND I.device_id = D.device_id");
$acc = mysql_fetch_array($query);
if(is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")) {
$rrd_filename = $config['rrd_dir'] . "/" . $acc['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd";
}
$rra_in = "PIN";
$rra_out = "POUT";
$colour_area_in = "AA66AA";
$colour_line_in = "330033";
$colour_area_out = "FFDD88";
$colour_line_out = "FF6600";
$colour_area_in_max = "CC88CC";
$colour_area_out_max = "FFEFAA";
$graph_max = 1;
$unit_text = "Pkts\ \ \ ";
include("generic_duplex.inc.php");
?>
+75 -52
View File
@@ -1,76 +1,99 @@
<?php
function graph_mac_acc_total ($args) {
$port = mres($_GET['port']);
if($_GET['stat']) { $stat = mres($_GET['stat']); } else { $stat = "bits"; }
$sort = mres($_GET['sort']);
if(is_numeric($_GET['topn'])) { $topn = $_GET['topn']; } else { $topn = '10'; }
include("common.inc.php");
include("../includes/rewrites.php");
if($args['sort'] == "in" || $args['sort'] == "out") { $sort = "bps_" . $args['sort']; } else { $sort = "bps"; }
$sql = "SELECT *, (bps_in + bps_out) AS bps FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.interface_id = '".$args['port']."'
AND I.interface_id = M.interface_id AND I.device_id = D.device_id ORDER BY $sort DESC LIMIT 0," . $args['topn'];
$query = mysql_query($sql);
if($args['width'] <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$pluses = ""; $iter = '0';
$options .= " COMMENT:' In\: Current Maximum Total Out\: Current Maximum Total\\\\n'";
while($acc = mysql_fetch_array($query)) {
if($args['stat'] == "pkts") {
$this_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['mac'] . "-pkts.rrd";
if($stat == "pkts") {
$units='pps'; $unit = 'p'; $multiplier = '1';
$colours = 'purples';
} elseif ($args['stat'] == "bits") {
$this_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd";
$prefix = "P";
if($sort == "in") {
$sort = "cipMacHCSwitchedPkts_input_rate";
} elseif($sort == "out") {
$sort = "cipMacHCSwitchedPkts_output_rate";
} else {
$sort = "bps";
}
} elseif ($stat == "bits") {
$units='bps'; $unit='B'; $multiplier='8';
$colours='greens';
if($sort == "in") {
$sort = "cipMacHCSwitchedBytes_input_rate";
} elseif($sort == "out") {
$sort = "cipMacHCSwitchedBytes_output_rate";
} else {
$sort = "bps";
}
}
$sql = "SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) AS bps,
(M.cipMacHCSwitchedPkts_input_rate + M.cipMacHCSwitchedPkts_output_rate) AS pps
FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.interface_id = '".$port."'
AND I.interface_id = M.interface_id AND D.device_id = I.device_id ORDER BY $sort DESC LIMIT 0," . $topn;
$query = mysql_query($sql);
$pluses = ""; $iter = '0';
$rrd_options .= " COMMENT:' In\: Current Maximum Total Out\: Current Maximum Total\\\\n'";
while($acc = mysql_fetch_array($query)) {
$this_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd";
if(is_file($this_rrd)) {
$name = $acc['mac'];
$addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."'"));
$addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."' AND interface_id = '".$acc['interface_id']."'"));
if($addy) {
$name = @gethostbyaddr($addy['ipv4_address']);
$name = $addy['ipv4_address'];
$peer = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_addresses AS A, interfaces AS I, devices AS D
WHERE A.ipv4_address = '".$addy['ipv4_address']."'
AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
if($peer) {
$name = $peer['hostname'] . " " . $peer['ifDescr'];
}
if(mysql_result(mysql_query("SELECT count(*) FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".
$addy['ipv4_address']."'"),0)) {
$peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'");
$peer_info = mysql_fetch_array($peer_query);
$name .= " - AS".$peer_info['bgpPeerRemoteAs'];
}
if($peer_info) { $asn = "AS".$peer_info['bgpPeerRemoteAs']; $astext = $peer_info['astext']; } else {
unset ($as); unset ($astext); unset($asn);
}
}
$this_id = str_replace(".", "", $acc['mac']);
if(!$config['graph_colours'][$colours][$iter]) { $iter = 0; }
$colour=$config['graph_colours'][$colours][$iter];
$descr = str_pad($name, 36);
$descr = substr($descr,0,36);
$options .= " DEF:in".$this_id."=$this_rrd:IN:AVERAGE ";
$options .= " DEF:out".$this_id."temp=$this_rrd:OUT:AVERAGE ";
$options .= " CDEF:inB".$this_id."=in".$this_id.",$multiplier,* ";
$options .= " CDEF:outB".$this_id."temp=out".$this_id."temp,$multiplier,*";
$options .= " CDEF:outB".$this_id."=outB".$this_id."temp,-1,*";
$options .= " CDEF:octets".$this_id."=inB".$this_id.",outB".$this_id."temp,+";
$options .= " VDEF:totin".$this_id."=inB".$this_id.",TOTAL";
$options .= " VDEF:totout".$this_id."=outB".$this_id."temp,TOTAL";
$options .= " VDEF:tot".$this_id."=octets".$this_id.",TOTAL";
$options .= " AREA:inB".$this_id."#" . $colour . ":'" . $descr . "':STACK";
if($optionsb) {$stack="STACK";}
$optionsb .= " AREA:outB".$this_id."#" . $colour . "::$stack";
$options .= " GPRINT:inB".$this_id.":LAST:%6.2lf%s$units";
$options .= " GPRINT:inB".$this_id.":MAX:%6.2lf%s$units";
$options .= " GPRINT:totin".$this_id.":%6.2lf%s$unit";
$options .= " COMMENT:' '";
$options .= " GPRINT:outB".$this_id."temp:LAST:%6.2lf%s$units";
$options .= " GPRINT:outB".$this_id."temp:MAX:%6.2lf%s$units";
$options .= " GPRINT:totout".$this_id.":%6.2lf%s$unit\\\\n";
$rrd_options .= " DEF:in".$this_id."=$this_rrd:".$prefix."IN:AVERAGE ";
$rrd_options .= " DEF:out".$this_id."temp=$this_rrd:".$prefix."OUT:AVERAGE ";
$rrd_options .= " CDEF:inB".$this_id."=in".$this_id.",$multiplier,* ";
$rrd_options .= " CDEF:outB".$this_id."temp=out".$this_id."temp,$multiplier,*";
$rrd_options .= " CDEF:outB".$this_id."=outB".$this_id."temp,-1,*";
$rrd_options .= " CDEF:octets".$this_id."=inB".$this_id.",outB".$this_id."temp,+";
$rrd_options .= " VDEF:totin".$this_id."=inB".$this_id.",TOTAL";
$rrd_options .= " VDEF:totout".$this_id."=outB".$this_id."temp,TOTAL";
$rrd_options .= " VDEF:tot".$this_id."=octets".$this_id.",TOTAL";
$rrd_options .= " AREA:inB".$this_id."#" . $colour . ":'" . $descr . "':STACK";
if($rrd_optionsb) {$stack="STACK";}
$rrd_optionsb .= " AREA:outB".$this_id."#" . $colour . "::$stack";
$rrd_options .= " GPRINT:inB".$this_id.":LAST:%6.2lf%s$units";
$rrd_options .= " GPRINT:inB".$this_id.":MAX:%6.2lf%s$units";
$rrd_options .= " GPRINT:totin".$this_id.":%6.2lf%s$unit";
$rrd_options .= " COMMENT:' '";
$rrd_options .= " GPRINT:outB".$this_id."temp:LAST:%6.2lf%s$units";
$rrd_options .= " GPRINT:outB".$this_id."temp:MAX:%6.2lf%s$units";
$rrd_options .= " GPRINT:totout".$this_id.":%6.2lf%s$unit\\\\n";
$iter++;
}
}
$options .= $optionsb;
# echo($config['rrdtool'] . " graph $graphfile $options");
$thing = shell_exec($config['rrdtool'] . " graph $graphfile $options");
return $graphfile;
}
$args['port'] = $_GET['port'];
$args['stat'] = $_GET['stat'];
$args['sort'] = $_GET['sort'];
$args['graphfile'] = $graphfile;
$args['from'] = $from;
$args['to'] = $to;
$args['width'] = $width;
$args['height'] = $height;
if(is_numeric($_GET['topn'])) { $args['topn'] = $_GET['topn']; } else { $args['topn'] = '10'; }
$graph = graph_mac_acc_total ($args);
$rrd_options .= $rrd_optionsb;
$rrd_options .= " HRULE:0#999999";
?>
+19 -57
View File
@@ -1,65 +1,27 @@
<?php
function graph_multi_bits ($args) {
include("common.inc.php");
$i = 1;
foreach(explode(",", $args['interfaces']) as $ifid) {
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
$int = mysql_fetch_row($query);
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) {
$options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE";
$options .= " DEF:outoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE";
$in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF";
$out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF";
$pluses .= $plus;
$seperator = ",";
$plus = ",+";
$i++;
}
}
if($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; }
$options .= " CDEF:".$in."octets=" . $in_thing . $pluses;
$options .= " CDEF:".$out."octets=" . $out_thing . $pluses;
$options .= " CDEF:doutoctets=outoctets,-1,*";
$options .= " CDEF:inbits=inoctets,8,*";
$options .= " CDEF:outbits=outoctets,8,*";
$options .= " CDEF:doutbits=doutoctets,8,*";
if($args['legend'] == 'no' || $args['legend'] == '1') {
$options .= " AREA:inbits#CDEB8B:";
$options .= " LINE1.25:inbits#006600:";
$options .= " AREA:doutbits#C3D9FF:";
$options .= " LINE1.25:doutbits#000099:";
} else {
$options .= " AREA:inbits#CDEB8B:";
$options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\\\\n";
$options .= " LINE1.25:inbits#006600:In\ ";
$options .= " GPRINT:inbits:LAST:%6.2lf%s";
$options .= " GPRINT:inbits:AVERAGE:%6.2lf%s";
$options .= " GPRINT:inbits:MAX:%6.2lf%s\\\\l";
$options .= " AREA:doutbits#C3D9FF:";
$options .= " LINE1.25:doutbits#000099:Out";
$options .= " GPRINT:outbits:LAST:%6.2lf%s";
$options .= " GPRINT:outbits:AVERAGE:%6.2lf%s";
$options .= " GPRINT:outbits:MAX:%6.2lf%s\\\l";
}
$thing = shell_exec($config['rrdtool'] . " graph $graphfile $options");
return $graphfile;
}
if($_GET['if']) { $interfaces = $_GET['if']; }
if($_GET['interfaces']) { $interfaces = $_GET['interfaces']; }
$args['interfaces'] = $interfaces;
$args['graphfile'] = $graphfile;
$args['from'] = $from;
$args['to'] = $to;
$args['width'] = $width;
$args['height'] = $height;
if($_GET['legend']) {
$args['legend'] = $_GET['legend'];
$i = 1;
foreach(explode(",", $interfaces) as $ifid) {
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
$int = mysql_fetch_row($query);
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) {
$rrd_filenames[] = $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd";
$i++;
}
$graph = graph_multi_bits ($args);
}
$rra_in = "INOCTETS";
$rra_out = "OUTOCTETS";
$colour_line_in = "006600";
$colour_line_out = "000099";
$colour_area_in = "CDEB8B";
$colour_area_out = "C3D9FF";
include ("generic_multi_bits.inc.php");
?>
+18 -8
View File
@@ -2,20 +2,30 @@
## Generate a list of interfaces and then call the multi_bits grapher to generate from the list
$parent = mysql_fetch_array(mysql_query("SELECT * FROM `interfaces` WHERE interface_id = '".$_GET['port']."'"));
$parent = mysql_fetch_array(mysql_query("SELECT * FROM `interfaces` WHERE interface_id = '".mres($_GET['port'])."'"));
$query = mysql_query("SELECT `ifIndex`,`interface_id` FROM `interfaces` WHERE `device_id` = '".$parent['device_id']."' AND `pagpGroupIfIndex` = '".$parent['ifIndex']."'");
$query = mysql_query("SELECT * FROM `interfaces` WHERE `device_id` = '".$parent['device_id']."' AND `pagpGroupIfIndex` = '".$parent['ifIndex']."'");
while($int = mysql_fetch_row($query)) {
if(is_file($config['rrd_dir'] . "/" . $hostname . "/" . $int[0] . ".rrd")) {
$interfaces .= $seperator . $int[1];
$seperator = ",";
$i=0;
while($int = mysql_fetch_array($query)) {
if(is_file($config['rrd_dir'] . "/" . $hostname . "/" . $int['ifIndex'] . ".rrd")) {
$rrd_list[$i]['filename'] = $config['rrd_dir'] . "/" . $hostname . "/" . $int['ifIndex'] . ".rrd";
$rrd_list[$i]['descr'] = $int['ifDescr'];
$i++;
}
}
$args['nototal'] = 1;
$units='bps';
$total_units='B';
$colours_in='greens';
$multiplier = "8";
$colours_out = 'blues';
include ("multi_bits_separate.inc.php");
$nototal = 1;
$rra_in = "INOCTETS";
$rra_out = "OUTOCTETS";
include ("generic_multi_bits_separated.inc.php");
+21
View File
@@ -0,0 +1,21 @@
<?php
if($_GET['id']) { $interface = $_GET['id'];
} elseif($_GET['port']) { $interface = $_GET['port'];
} elseif($_GET['if']) { $interface = $_GET['if'];
} elseif($_GET['interface']) { $interface = $_GET['interface']; }
$query = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.interface_id = '".$interface."'
AND I.device_id = D.device_id");
$port = mysql_fetch_array($query);
if(is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/" . $port['ifIndex'] . ".rrd")) {
$rrd_filename = $config['rrd_dir'] . "/" . $port['hostname'] . "/" . $port['ifIndex'] . ".rrd";
}
$rra_in = "INOCTETS";
$rra_out = "OUTOCTETS";
include("generic_bits.inc.php");
?>
+33
View File
@@ -0,0 +1,33 @@
<?php
if($_GET['id']) { $interface = $_GET['id'];
} elseif($_GET['port']) { $interface = $_GET['port'];
} elseif($_GET['if']) { $interface = $_GET['if'];
} elseif($_GET['interface']) { $interface = $_GET['interface']; }
$query = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.interface_id = '".$interface."'
AND I.device_id = D.device_id");
$port = mysql_fetch_array($query);
if(is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/" . $port['ifIndex'] . ".rrd")) {
$rrd_filename = $config['rrd_dir'] . "/" . $port['hostname'] . "/" . $port['ifIndex'] . ".rrd";
}
$rra_in = "INERRORS";
$rra_out = "OUTERRORS";
$colour_area_in = "FF3300";
$colour_line_in = "FF0000";
$colour_area_out = "FF6633";
$colour_line_out = "CC3300";
$colour_area_in_max = "FF6633";
$colour_area_out_max = "FF9966";
$graph_max = 1;
$unit_text = "Errors\ ";
include("generic_duplex.inc.php");
?>
+33
View File
@@ -0,0 +1,33 @@
<?php
if($_GET['id']) { $interface = $_GET['id'];
} elseif($_GET['port']) { $interface = $_GET['port'];
} elseif($_GET['if']) { $interface = $_GET['if'];
} elseif($_GET['interface']) { $interface = $_GET['interface']; }
$query = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.interface_id = '".$interface."'
AND I.device_id = D.device_id");
$port = mysql_fetch_array($query);
if(is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/" . $port['ifIndex'] . ".rrd")) {
$rrd_filename = $config['rrd_dir'] . "/" . $port['hostname'] . "/" . $port['ifIndex'] . ".rrd";
}
$rra_in = "INNUCASTPKTS";
$rra_out = "OUTNUCASTPKTS";
$colour_area_in = "AA66AA";
$colour_line_in = "330033";
$colour_area_out = "FFDD88";
$colour_line_out = "FF6600";
$colour_area_in_max = "cc88cc";
$colour_area_out_max = "FFefaa";
$unit_text = "NUPkts\ ";
$graph_max = 1;
include("generic_duplex.inc.php");
?>
+32
View File
@@ -0,0 +1,32 @@
<?php
if($_GET['id']) { $interface = $_GET['id'];
} elseif($_GET['port']) { $interface = $_GET['port'];
} elseif($_GET['if']) { $interface = $_GET['if'];
} elseif($_GET['interface']) { $interface = $_GET['interface']; }
$query = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.interface_id = '".$interface."'
AND I.device_id = D.device_id");
$port = mysql_fetch_array($query);
if(is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/" . $port['ifIndex'] . ".rrd")) {
$rrd_filename = $config['rrd_dir'] . "/" . $port['hostname'] . "/" . $port['ifIndex'] . ".rrd";
}
$rra_in = "INUCASTPKTS";
$rra_out = "OUTUCASTPKTS";
$colour_area_in = "AA66AA";
$colour_line_in = "330033";
$colour_area_out = "FFDD88";
$colour_line_out = "FF6600";
$colour_area_in_max = "cc88cc";
$colour_area_out_max = "FFefaa";
$graph_max = 1;
$unit_text = "Pkts\ \ \ ";
include("generic_duplex.inc.php");
?>
+25
View File
@@ -0,0 +1,25 @@
<?php
include("common.inc.php");
$sql = mysql_query("SELECT * FROM temperature where temp_id = '$temp'");
$temperature = mysql_fetch_array(mysql_query("SELECT * FROM temperature where temp_id = '".mres($_GET['id'])."'"));
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $temperature['temp_host'] . "'"),0);
$temperature['temp_descr_fixed'] = str_pad($temperature['temp_descr'], 28);
$temperature['temp_descr_fixed'] = substr($temperature['temp_descr_fixed'],0,28);
$filename = str_replace(")", "_", str_replace("(", "_", str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr']))));
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/temp-" . $filename . ".rrd";
$rrd_options .= " DEF:temp=$rrd_filename:temp:AVERAGE";
$rrd_options .= " CDEF:tempwarm=temp,".$temperature[temp_limit].",GT,temp,UNKN,IF";
$rrd_options .= " LINE1.5:temp#cc0000:'" . quotemeta($temperature[temp_descr_fixed]."'");
$rrd_options .= " LINE1.5:tempwarm#660000";
$rrd_options .= " GPRINT:temp:LAST:%3.0lfC";
$rrd_options .= " GPRINT:temp:MAX:%3.0lfC\\\\l";
?>