mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 18:38:25 +00:00
fixing some graphing and other stuff
git-svn-id: http://www.observium.org/svn/observer/trunk@61 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
parent
6e1a7bbd6b
commit
e7868e6124
@ -29,7 +29,7 @@
|
||||
echo("</span>");
|
||||
echo("</td><td width=70>");
|
||||
if($speed && $speed != "") { echo("<span class=box-desc>$speed</span>"); }
|
||||
echo("</td><td width=110>");
|
||||
echo("</td><td width=150>");
|
||||
if($iftype && $iftype != "") { echo("<span class=box-desc>$iftype</span>"); } else { echo("-"); }
|
||||
echo("</td><td width=80>");
|
||||
if($mac && $mac != "") { echo("<span class=box-desc>$mac</span>"); } else { echo("-"); }
|
||||
|
@ -12,7 +12,7 @@ if($_POST['addsrv']) {
|
||||
|
||||
if ($handle = opendir($installdir . "/includes/services/")) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != "..") {
|
||||
if ($file != "." && $file != ".." && !strstr($file, ".")) {
|
||||
$servicesform .= "<option value='$file'>$file</option>";
|
||||
}
|
||||
}
|
||||
|
@ -40,91 +40,6 @@ 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("<pre>");
|
||||
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;
|
||||
@ -137,7 +52,7 @@ function graph_device_bits ($device, $graph, $from, $to, $width, $height)
|
||||
|
||||
$hostname = gethostbyid($device);
|
||||
|
||||
$query = mysql_query("SELECT `ifIndex` FROM `interfaces` WHERE `host` = '$device' AND ifType LIKE '%ethernet%' OR `ifType` LIKE '%erial%'");
|
||||
$query = mysql_query("SELECT `ifIndex` FROM `interfaces` WHERE `host` = '$device' AND `ifType` NOT LIKE '%oopback%' AND `ifType` NOT LIKE '%SVI%'");
|
||||
|
||||
while($int = mysql_fetch_row($query)) {
|
||||
|
||||
|
@ -184,10 +184,6 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('$id', NULL, NOW(), 'Changed hardware from $hardware to $newhardware')");
|
||||
}
|
||||
if ( $newuptime && $uptime != $newuptime ) {
|
||||
$update .= $seperator . "`uptime` = '$newuptime'";
|
||||
$seperator = ", ";
|
||||
}
|
||||
|
||||
if( $status != $newstatus ) {
|
||||
$update .= $seperator . "`status` = '$newstatus'";
|
||||
@ -201,7 +197,14 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('$id', NULL, NOW(), 'Device status changed to $stat')");
|
||||
}
|
||||
|
||||
if ( $newuptime ) {
|
||||
if ($newuptime) {
|
||||
echo("Uptime : $newuptime\n");
|
||||
|
||||
$update_uptime_attrib = mysql_query("UPDATE devices_attribs SET attrib_value = '$newuptime' WHERE `device_id` = '$id' AND `attrib_type` = 'uptime'");
|
||||
if(mysql_affected_rows() == '0') {
|
||||
$insert_uptime_attrib = mysql_query("INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('$id', 'uptime', '$newuptime')");
|
||||
}
|
||||
|
||||
$update_uptime = mysql_query("UPDATE device_uptime SET device_uptime = '$newuptime' WHERE `device_id` = '$id'");
|
||||
if(mysql_affected_rows() == '0') {
|
||||
$insert_uptime = mysql_query("INSERT INTO device_uptime (`device_uptime`, `device_id`) VALUES ('$newuptime','$id')");
|
||||
|
Loading…
Reference in New Issue
Block a user