mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
first steps to new architecture! (new-poller.php and new-mac.php!)
git-svn-id: http://www.observium.org/svn/observer/trunk@487 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
13
html/includes/graphs/mac_acc_bits.inc.php
Normal file
13
html/includes/graphs/mac_acc_bits.inc.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?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");
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
?>
|
76
html/includes/graphs/multi_bits_separate.inc.php
Normal file
76
html/includes/graphs/multi_bits_separate.inc.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
function graph_multi_bits ($args) {
|
||||
|
||||
include("common.inc.php");
|
||||
$i = 1;
|
||||
$options .= " COMMENT:' In\: Current Maximum '";
|
||||
if(!$args['nototal']) {$options .= " COMMENT:'Total '";}
|
||||
$options .= " COMMENT:'Out\: Current Maximum'";
|
||||
if(!$args['nototal']) {$options .= " COMMENT:' Total'";}
|
||||
$options .= " COMMENT:'\\\\n'";
|
||||
|
||||
foreach(explode(",", $args['interfaces']) as $ifid) {
|
||||
$query = mysql_query("SELECT * FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
|
||||
$int = mysql_fetch_array($query);
|
||||
$this_rrd = $config['rrd_dir'] . "/" . $int['hostname'] . "/" . $int['ifIndex'] . ".rrd";
|
||||
$units='bps'; $unit='B'; $colours='greens'; $multiplier = "8"; $coloursb = 'blues';
|
||||
if(is_file($this_rrd)) {
|
||||
$name = $int['ifDescr'];
|
||||
if(!$config['graph_colours'][$colours][$iter] || !$config['graph_colours'][$coloursb][$iter]) { $iter = 0; }
|
||||
$colour=$config['graph_colours'][$colours][$iter];
|
||||
$colourb=$config['graph_colours'][$coloursb][$iter];
|
||||
$descr = str_pad($name, 30);
|
||||
$descr = substr($descr,0,30);
|
||||
$options .= " DEF:in".$ifid."=$this_rrd:INOCTETS:AVERAGE ";
|
||||
$options .= " DEF:out".$ifid."temp=$this_rrd:OUTOCTETS:AVERAGE ";
|
||||
$options .= " CDEF:inB".$ifid."=in".$ifid.",$multiplier,* ";
|
||||
$options .= " CDEF:outB".$ifid."temp=out".$ifid."temp,$multiplier,*";
|
||||
$options .= " CDEF:outB".$ifid."=outB".$ifid."temp,-1,*";
|
||||
$options .= " CDEF:octets".$ifid."=inB".$ifid.",outB".$ifid."temp,+";
|
||||
if(!$args['nototal']) {
|
||||
$options .= " VDEF:totin".$ifid."=inB".$ifid.",TOTAL";
|
||||
$options .= " VDEF:totout".$ifid."=outB".$ifid."temp,TOTAL";
|
||||
$options .= " VDEF:tot".$ifid."=octets".$ifid.",TOTAL";
|
||||
}
|
||||
$options .= " HRULE:999999999999999#" . $colourb . ":\\\s:";
|
||||
$options .= " AREA:inB".$ifid."#" . $colour . ":'" . $descr . "':STACK";
|
||||
if($optionsb) {$stack="STACK";}
|
||||
$optionsb .= " AREA:outB".$ifid."#" . $colourb . "::$stack";
|
||||
$options .= " GPRINT:inB".$ifid.":LAST:%6.2lf%s$units";
|
||||
$options .= " GPRINT:inB".$ifid.":MAX:%6.2lf%s$units";
|
||||
if(!$args['nototal']) {
|
||||
$options .= " GPRINT:totin".$ifid.":%6.2lf%s$unit";
|
||||
}
|
||||
$options .= " COMMENT:' '";
|
||||
$options .= " GPRINT:outB".$ifid."temp:LAST:%6.2lf%s$units";
|
||||
$options .= " GPRINT:outB".$ifid."temp:MAX:%6.2lf%s$units";
|
||||
if(!$args['nototal']) {
|
||||
$options .= " GPRINT:totout".$ifid.":%6.2lf%s$unit";
|
||||
}
|
||||
$options .= " COMMENT:\\\\n";
|
||||
$iter++;
|
||||
}
|
||||
}
|
||||
$options .= $optionsb;
|
||||
$options .= " HRULE:0#999999";
|
||||
#echo($config['rrdtool'] . " graph $graphfile $options");
|
||||
$thing = shell_exec($config['rrdtool'] . " graph $graphfile $options");
|
||||
return $graphfile;
|
||||
}
|
||||
|
||||
if($_GET['if']) { $args['interfaces'] = $_GET['if']; }
|
||||
if($_GET['interfaces']) { $args['interfaces'] = $_GET['interfaces']; }
|
||||
if($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'];
|
||||
}
|
||||
$graph = graph_multi_bits ($args);
|
||||
|
||||
?>
|
22
html/includes/graphs/pagp_bits.inc.php
Normal file
22
html/includes/graphs/pagp_bits.inc.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
## 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']."'"));
|
||||
|
||||
$query = mysql_query("SELECT `ifIndex`,`interface_id` 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 = ",";
|
||||
}
|
||||
}
|
||||
|
||||
$args['nototal'] = 1;
|
||||
|
||||
include ("multi_bits_separate.inc.php");
|
||||
|
||||
|
||||
|
||||
?>
|
Reference in New Issue
Block a user