mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
add some complex graphtypes useful for fancy frontpage stuff (code sucks, though)
git-svn-id: http://www.observium.org/svn/observer/trunk@1064 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
116
html/includes/graphs/multi_bits_duo.inc.php
Normal file
116
html/includes/graphs/multi_bits_duo.inc.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
$ports_a = $_GET['ports'];
|
||||
$ports_b = $_GET['ports_b'];
|
||||
|
||||
$rrd_options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height";
|
||||
$rrd_options .= $config['rrdgraph_def_text'];
|
||||
if($height < "99") { $rrd_options .= " --only-graph"; }
|
||||
$i = 1;
|
||||
foreach(explode(",", $ports_a) as $ifid) {
|
||||
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` 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_options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE";
|
||||
$rrd_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++;
|
||||
}
|
||||
}
|
||||
unset($seperator); unset($plus);
|
||||
foreach(explode(",", $ports_b) as $ifid) {
|
||||
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` 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_options .= " DEF:inoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE";
|
||||
$rrd_options .= " DEF:outoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE";
|
||||
$in_thingb .= $seperator . "inoctetsb" . $i . ",UN,0," . "inoctetsb" . $i . ",IF";
|
||||
$out_thingb .= $seperator . "outoctetsb" . $i . ",UN,0," . "outoctetsb" . $i . ",IF";
|
||||
$plusesb .= $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:".$in."octetsb=" . $in_thingb . $plusesb;
|
||||
$rrd_options .= " CDEF:".$out."octetsb=" . $out_thingb . $plusesb;
|
||||
$rrd_options .= " CDEF:doutoctets=outoctets,-1,*";
|
||||
$rrd_options .= " CDEF:inbits=inoctets,8,*";
|
||||
$rrd_options .= " CDEF:outbits=outoctets,8,*";
|
||||
$rrd_options .= " CDEF:doutbits=doutoctets,8,*";
|
||||
$rrd_options .= " CDEF:doutoctetsb=outoctetsb,-1,*";
|
||||
$rrd_options .= " CDEF:inbitsb=inoctetsb,8,*";
|
||||
$rrd_options .= " CDEF:outbitsb=outoctetsb,8,*";
|
||||
$rrd_options .= " CDEF:doutbitsb=doutoctetsb,8,*";
|
||||
$rrd_options .= " CDEF:inbits_tot=inbits,inbitsb,+";
|
||||
$rrd_options .= " CDEF:outbits_tot=outbits,outbitsb,+";
|
||||
$rrd_options .= " CDEF:doutbits_tot=outbits_tot,-1,*";
|
||||
$rrd_options .= " CDEF:nothing=outbits_tot,outbits_tot,-";
|
||||
if($legend == "no") {
|
||||
$rrd_options .= " AREA:inbits_tot#cdeb8b:";
|
||||
$rrd_options .= " AREA:inbits#ffcc99:";
|
||||
$rrd_options .= " AREA:doutbits_tot#cdeb8b:";
|
||||
$rrd_options .= " AREA:doutbits#ffcc99:";
|
||||
$rrd_options .= " LINE1:inbits#aa9966:";
|
||||
$rrd_options .= " LINE1:doutbits#aa9966:";
|
||||
$rrd_options .= " LINE1:inbitsb#006600:";
|
||||
$rrd_options .= " LINE1:doutbitsb#006600:";
|
||||
$rrd_options .= " LINE1.25:inbits_tot#006600:";
|
||||
$rrd_options .= " LINE1.25:doutbits_tot#006600:";
|
||||
$rrd_options .= " LINE0.5:nothing#555555:";
|
||||
} else {
|
||||
$rrd_options .= " COMMENT:BPS\ \ \ \ \ \ \ \ \ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Min\ \ \ \ \ \ Max\\\\n";
|
||||
$rrd_options .= " AREA:inbits_tot#cdeb8b:Peering\ In\ ";
|
||||
$rrd_options .= " GPRINT:inbitsb:LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inbitsb:AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inbitsb:MIN:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inbitsb:MAX:%6.2lf%s\\\\l";
|
||||
$rrd_options .= " AREA:doutbits_tot#cdeb8b:";
|
||||
$rrd_options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Out";
|
||||
$rrd_options .= " GPRINT:outbitsb:LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outbitsb:AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outbitsb:MIN:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outbitsb:MAX:%6.2lf%s\\\\l";
|
||||
|
||||
$rrd_options .= " AREA:inbits#ffcc99:Transit\ In\ ";
|
||||
$rrd_options .= " GPRINT:inbits:LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inbits:AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inbits:MIN:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inbits:MAX:%6.2lf%s\\\\l";
|
||||
$rrd_options .= " AREA:doutbits#ffcc99:";
|
||||
$rrd_options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Out";
|
||||
$rrd_options .= " GPRINT:outbits:LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outbits:AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outbits:MIN:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outbits:MAX:%6.2lf%s\\\\l";
|
||||
|
||||
$rrd_options .= " COMMENT:Total\ \ \ \ \ In\ ";
|
||||
$rrd_options .= " GPRINT:inbits_tot:LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inbits_tot:AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inbits_tot:MIN:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inbits_tot:MAX:%6.2lf%s\\\\l";
|
||||
$rrd_options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Out";
|
||||
$rrd_options .= " GPRINT:outbits_tot:LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outbits_tot:AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outbits_tot:MIN:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outbits_tot:MAX:%6.2lf%s\\\\l";
|
||||
|
||||
$rrd_options .= " LINE1:inbits#aa9966:";
|
||||
$rrd_options .= " LINE1:doutbits#aa9966:";
|
||||
$rrd_options .= " LINE1.25:inbitsb#006600:";
|
||||
$rrd_options .= " LINE1.25:doutbitsb#006600:";
|
||||
$rrd_options .= " LINE1.25:inbits_tot#006600:";
|
||||
$rrd_options .= " LINE1.25:doutbits_tot#006600:";
|
||||
$rrd_options .= " LINE0.5:nothing#555555:";
|
||||
|
||||
}
|
||||
if($width <= "300") { $rrd_options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; }
|
||||
|
||||
?>
|
Reference in New Issue
Block a user