fixes to new sensors setup

git-svn-id: http://www.observium.org/svn/observer/trunk@1533 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-07-29 20:34:31 +00:00
parent 1cddb998eb
commit 7b2fc2dbe1
28 changed files with 326 additions and 190 deletions
@@ -38,8 +38,8 @@ while($temperature = mysql_fetch_array($sql))
}
$temperature['sensor_descr_fixed'] = substr(str_pad($temperature['sensor_descr'], 22),0,22);
$temprrd = $config['rrd_dir'] . "/".$device['hostname']."/".safename("temp-" . $temperature['sensor_descr'] . ".rrd");
$rrd_options .= " DEF:temp" . $temperature['sensor_id'] . "=$temprrd:temp:AVERAGE ";
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . safename($temperature['sensor_type']."-".$temperature['sensor_index']) . ".rrd";
$rrd_options .= " DEF:temp" . $temperature['sensor_id'] . "=$rrd_file:temp:AVERAGE ";
$rrd_options .= " LINE1:temp" . $temperature['sensor_id'] . "#" . $colour . ":'" . str_replace(':','\:',str_replace('\*','*',$temperature['sensor_descr_fixed'])) . "'";
$rrd_options .= " GPRINT:temp" . $temperature['sensor_id'] . ":LAST:%4.1lfC ";
$rrd_options .= " GPRINT:temp" . $temperature['sensor_id'] . ":MIN:%4.1lfC ";
@@ -7,19 +7,18 @@ include("includes/graphs/common.inc.php");
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
$temperature = mysql_fetch_array(mysql_query("SELECT * FROM sensors where sensor_id = '".mres($_GET['id'])."'"));
$sensor = mysql_fetch_array(mysql_query("SELECT * FROM sensors where sensor_id = '".mres($_GET['id'])."'"));
$device = device_by_id_cache($sensor['device_id']);
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $temperature['device_id'] . "'"),0);
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 22),0,22);
$temperature['sensor_descr_fixed'] = substr(str_pad($temperature['sensor_descr'], 22),0,22);
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("temp-" . $temperature['sensor_descr'] . ".rrd");
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
$rrd_options .= " DEF:temp=$rrd_filename:temp:AVERAGE";
$rrd_options .= " DEF:temp_max=$rrd_filename:temp:MAX";
$rrd_options .= " DEF:temp_min=$rrd_filename:temp:MIN";
$rrd_options .= " CDEF:tempwarm=temp_max,".$temperature['sensor_limit'].",GT,temp,UNKN,IF";
$rrd_options .= " CDEF:tempwarm=temp_max,".$sensor['sensor_limit'].",GT,temp,UNKN,IF";
$rrd_options .= " CDEF:tempcold=temp_min,20,LT,temp,UNKN,IF";
$rrd_options .= " AREA:temp_max#c5c5c5";
$rrd_options .= " AREA:temp_min#ffffffff";
@@ -29,8 +28,8 @@ include("includes/graphs/common.inc.php");
# $rrd_options .= " AREA:temp#bbd392";
# $rrd_options .= " AREA:tempwarm#FFCCCC";
# $rrd_options .= " AREA:tempcold#CCCCFF";
# $rrd_options .= " LINE1:temp#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($temperature['sensor_descr_fixed'])))."'"; # Ugly hack :(
$rrd_options .= " LINE1:temp#cc0000:'" . str_replace(':','\:',str_replace('\*','*',$temperature['sensor_descr_fixed']))."'"; # Ugly hack :(
# $rrd_options .= " LINE1:temp#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($sensor['sensor_descr_fixed'])))."'"; # Ugly hack :(
$rrd_options .= " LINE1:temp#cc0000:'" . str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed']))."'"; # Ugly hack :(
$rrd_options .= " LINE1:tempwarm#660000";
$rrd_options .= " GPRINT:temp:LAST:%4.1lfC";
$rrd_options .= " GPRINT:temp:MIN:%4.1lfC";
@@ -0,0 +1,9 @@
<?php
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-icmp.rrd")) {
$graph_title = "ICMP Informational Statistics";
$graph_type = "device_icmp_informational";
include ("includes/print-device-graph.php");
}
?>
@@ -0,0 +1,9 @@
<?php
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-icmp.rrd")) {
$graph_title = "ICMP Statistics";
$graph_type = "device_icmp";
include ("includes/print-device-graph.php");
}
?>
@@ -0,0 +1,13 @@
<?php
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-ip.rrd")) {
$graph_title = "IP Statistics";
$graph_type = "device_ip";
include ("includes/print-device-graph.php");
$graph_title = "IP Fragmented Statistics";
$graph_type = "device_ip_fragmented";
include ("includes/print-device-graph.php");
}
?>
@@ -0,0 +1,13 @@
<?php
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-snmp.rrd")) {
$graph_title = "SNMP Packets Statistics";
$graph_type = "device_snmp_packets";
include ("includes/print-device-graph.php");
$graph_title = "SNMP Message Type Statistics";
$graph_type = "device_snmp_statistics";
include ("includes/print-device-graph.php");
}
?>
@@ -0,0 +1,9 @@
<?php
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-tcp.rrd")) {
$graph_title = "TCP Statistics";
$graph_type = "device_tcp";
include ("includes/print-device-graph.php");
}
?>
@@ -0,0 +1,9 @@
<?php
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-udp.rrd")) {
$graph_title = "UDP Statistics";
$graph_type = "device_udp";
include ("includes/print-device-graph.php");
}
?>
+7 -7
View File
@@ -1,27 +1,27 @@
<?php
$sql = "SELECT * FROM `frequency` WHERE device_id = '" . mres($_GET['id']- . "' ORDER BY freq_descr";
$sql = "SELECT * FROM `sensors` WHERE device_id = '" . mres($_GET['id']- . "' AND `sensor_class` = 'freq' ORDER BY sensor_descr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=5 width=100%>");
$row = 1;
while($freq = mysql_fetch_array($query)) {
while($sensor = mysql_fetch_array($query)) {
if(!is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo("<tr class=list-large style=\"background-color: $row_colour; padding: 5px;\">
<td width=350>" . $freq['freq_descr'] . "</td>
<td>" . $freq['freq_current'] . "Hz</td>
<td>" . $freq['freq_limit_low'] . 'Hz - ' . $freq['freq_limit'] . "Hz</td>
<td>" . $freq['freq_notes'] . "</td>
<td width=350>" . $sensor['sensor_descr'] . "</td>
<td>" . $sensor['sensor_current'] . "Hz</td>
<td>" . $sensor['sensor_limit_low'] . 'Hz - ' . $sensor['sensor_limit'] . "Hz</td>
<td>" . $sensor['sensor_notes'] . "</td>
</tr>\n");
echo("<tr bgcolor=$row_colour><td colspan='4'>");
$graph_type = "sensor_frequency";
$graph_array['id'] = $freq['sensor_id'];
$graph_array['id'] = $sensor['sensor_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
@@ -13,6 +13,7 @@ while($temp = mysql_fetch_array($query)) {
echo("<tr class=list-large style=\"background-color: $row_colour; padding: 5px;\">
<td width=350>" . $temp['sensor_descr'] . "</td>
<td width=350>" . $temp['sensor_type'] . "</td>
<td>" . print_temperature($temp['sensor_current'], $temp['sensor_limit']) . " &deg;C</td>
<td>" . $temp['sensor_limit'] . " &deg;C</td>
<td>" . $temp['sensor_notes'] . "</td>