mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
genericify sensors graphs
git-svn-id: http://www.observium.org/svn/observer/trunk@2171 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,54 +1,9 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$device = device_by_id_cache($id);
|
||||
$class = "current";
|
||||
$unit = "A";
|
||||
$unit_long = "Ampere";
|
||||
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='current' AND device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
while ($current = mysql_fetch_assoc($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$hostname = gethostbyid($current['device_id']);
|
||||
|
||||
$descr = substr(str_pad($current['sensor_descr'], 15),0,15);
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("current-" . $current['sensor_descr'] . ".rrd");
|
||||
|
||||
$rrd_options .= " DEF:sensor" . $current['sensor_id'] . "=$rrd_filename:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1:sensor" . $current['sensor_id'] . "#".$colour.":'" . $descr . "'";
|
||||
$rrd_options .= " GPRINT:sensor" . $current['sensor_id'] . ":AVERAGE:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:sensor" . $current['sensor_id'] . ":MIN:%5.2lfA";
|
||||
$rrd_options .= " GPRINT:sensor" . $current['sensor_id'] . ":MAX:%5.2lfA\\\\l";
|
||||
|
||||
$iter++;
|
||||
}
|
||||
include("includes/graphs/device/sensor.inc.php");
|
||||
|
||||
?>
|
||||
@@ -1,56 +1,9 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$class = "fanspeed";
|
||||
$unit = "";
|
||||
$unit_long = "RPM";
|
||||
|
||||
$device = device_by_id_cache($id);
|
||||
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='fanspeed' AND device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:'RPM Cur Min Max\\n'";
|
||||
|
||||
# FIXME generic colour function
|
||||
while ($fanspeed = mysql_fetch_assoc($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$descr = substr(str_pad($fanspeed['sensor_descr'], 17),0,17);
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("fanspeed-" . safename($fanspeed['sensor_type']."-".$fanspeed['sensor_index']) . ".rrd");
|
||||
$fan_id = $fanspeed['sensor_id'];
|
||||
|
||||
$rrd_options .= " DEF:sensor$fan_id=$rrd_filename:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1:sensor$fan_id#".$colour.":'" . $descr . "'";
|
||||
$rrd_options .= " GPRINT:sensor$fan_id:AVERAGE:%5.0lf\ ";
|
||||
$rrd_options .= " GPRINT:sensor$fan_id:MIN:%5.0lf\ ";
|
||||
$rrd_options .= " GPRINT:sensor$fan_id:MAX:%5.0lf\\\\l";
|
||||
|
||||
$iter++;
|
||||
}
|
||||
include("includes/graphs/device/sensor.inc.php");
|
||||
|
||||
?>
|
||||
@@ -1,57 +1,9 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$device = device_by_id_cache($id);
|
||||
$class = "freqquency";
|
||||
$unit = "Hz";
|
||||
$unit_long = "Hertz";
|
||||
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='frequency' AND device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
|
||||
while ($frequency = mysql_fetch_assoc($sql))
|
||||
{
|
||||
# FIXME generic colour function
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$hostname = gethostbyid($frequency['device_id']);
|
||||
|
||||
$descr = substr(str_pad($frequency['sensor_descr'], 15),0,15);
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("frequency-" . $frequency['sensor_descr'] . ".rrd");
|
||||
$sensor_id = $frequency['sensor_id'];
|
||||
|
||||
$rrd_options .= " DEF:freq$sensor_id=$rrd_filename:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1:freq$sensor_id#".$colour.":'" . $descr . "'";
|
||||
$rrd_options .= " GPRINT:freq$sensor_id:AVERAGE:%5.2lfHz";
|
||||
$rrd_options .= " GPRINT:freq$sensor_id:MIN:%5.2lfHz";
|
||||
$rrd_options .= " GPRINT:freq$sensor_id:MAX:%5.2lfHz\\\\l";
|
||||
|
||||
$iter++;
|
||||
}
|
||||
include("includes/graphs/device/sensor.inc.php");
|
||||
|
||||
?>
|
||||
@@ -1,51 +1,9 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$device = device_by_id_cache($id);
|
||||
$class = "humidity";
|
||||
$unit = "%";
|
||||
$unit_long = "Percent";
|
||||
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='humidity' AND device_id = '$id' ORDER BY sensor_index");
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
while ($humidity = mysql_fetch_assoc($sql))
|
||||
{
|
||||
# FIXME generic colour function
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$humidity['sensor_descr_fixed'] = substr(str_pad($humidity['sensor_descr'], 22),0,22);
|
||||
$humidityrrd = $config['rrd_dir'] . "/".$device['hostname']."/".safename("humidity-" . safename($humidity['sensor_descr']) . ".rrd");
|
||||
$rrd_options .= " DEF:sensor" . $humidity['sensor_id'] . "=$humidityrrd:sensor:AVERAGE ";
|
||||
$rrd_options .= " LINE1:sensor" . $humidity['sensor_id'] . "#" . $colour . ":'" . str_replace(':','\:',str_replace('\*','*',quotemeta($humidity['sensor_descr_fixed']))) . "' ";
|
||||
$rrd_options .= " GPRINT:sensor" . $humidity['sensor_id'] . ":LAST:%3.0lf%% ";
|
||||
$rrd_options .= " GPRINT:sensor" . $humidity['sensor_id'] . ":MIN:%3.0lf%% ";
|
||||
$rrd_options .= " GPRINT:sensor" . $humidity['sensor_id'] . ":MAX:%3.0lf%%\\\l ";
|
||||
$iter++;
|
||||
}
|
||||
include("includes/graphs/device/sensor.inc.php");
|
||||
|
||||
?>
|
||||
@@ -1,52 +1,9 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$device = device_by_id_cache($id);
|
||||
$class = "temperature";
|
||||
$unit = "C";
|
||||
$unit_long = "Degree C";
|
||||
|
||||
if ($_GET['width'] > "300") { $descr_len = "40"; } else { $descr_len = "22"; }
|
||||
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='temperature' AND device_id = '$id' ORDER BY sensor_index");
|
||||
$rrd_options .= " COMMENT:'".str_pad('',$descr_len)." Cur Min Max\\n'";
|
||||
while ($temperature = mysql_fetch_assoc($sql))
|
||||
{
|
||||
# FIXME generic colour function
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$temperature['sensor_descr_fixed'] = substr(str_pad($temperature['sensor_descr'], $descr_len),0,$descr_len);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/temperature-" . safename($temperature['sensor_type']."-".$temperature['sensor_index']) . ".rrd";
|
||||
$rrd_options .= " DEF:sensor" . $temperature['sensor_id'] . "=$rrd_file:sensor:AVERAGE ";
|
||||
$rrd_options .= " LINE1:sensor" . $temperature['sensor_id'] . "#" . $colour . ":'" . str_replace(':','\:',str_replace('\*','*',$temperature['sensor_descr_fixed'])) . "'";
|
||||
$rrd_options .= " GPRINT:sensor" . $temperature['sensor_id'] . ":LAST:%4.1lfC ";
|
||||
$rrd_options .= " GPRINT:sensor" . $temperature['sensor_id'] . ":MIN:%4.1lfC ";
|
||||
$rrd_options .= " GPRINT:sensor" . $temperature['sensor_id'] . ":MAX:%4.1lfC\\\l ";
|
||||
$iter++;
|
||||
}
|
||||
include("includes/graphs/device/sensor.inc.php");
|
||||
|
||||
?>
|
||||
@@ -1,57 +1,9 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$device = device_by_id_cache($id);
|
||||
$class = "voltage";
|
||||
$unit = "V";
|
||||
$unit_long = "Volts";
|
||||
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
|
||||
if ($_GET['width'] > "300") { $descr_len = "38"; } else { $descr_len = "18"; }
|
||||
$rrd_options .= " COMMENT:'".str_pad('',$descr_len)." Cur Min Max\\n'";
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='voltage' AND device_id = '$id'");
|
||||
while ($sensor = mysql_fetch_assoc($sql))
|
||||
{
|
||||
# FIXME generic colour function
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], $descr_len),0,$descr_len);
|
||||
$sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed']));
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/voltage-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
|
||||
|
||||
$rrd_options .= " DEF:sensor" . $sensor['sensor_id'] . "=$rrd_filename:sensor:AVERAGE";
|
||||
$rrd_options .= " LINE1:sensor" . $sensor['sensor_id'] . "#".$colour.":'" . $sensor['sensor_descr_fixed'] . "'";
|
||||
$rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":AVERAGE:%5.2lfV";
|
||||
$rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":MIN:%5.2lfV";
|
||||
$rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":MAX:%5.2lfV\\\\l";
|
||||
|
||||
$iter++;
|
||||
}
|
||||
include("includes/graphs/device/sensor.inc.php");
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user