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

View File

@ -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 ";

View File

@ -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";

View File

@ -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");
}
?>

View File

@ -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");
}
?>

View File

@ -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");
}
?>

View File

@ -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");
}
?>

View File

@ -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");
}
?>

View File

@ -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");
}
?>

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");

View File

@ -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>

View File

@ -0,0 +1,64 @@
<?php
global $valid_sensor;
if ($device['os'] == "ios" || $device['os_group'] == "ios")
{
echo("CISCO-ENTITY-SENSOR");
$oids = array();
$oids = snmpwalk_cache_multi_oid($device, "entSensorType", $oids, "CISCO-ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entSensorScale", $oids, "CISCO-ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entSensorValue", $oids, "CISCO-ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entSensorMeasuredEntity", $oids, "CISCO-ENTITY-SENSOR-MIB");
if($debug) { print_r($oids); }
$entitysensor['voltsDC'] = "voltage";
$entitysensor['voltsAC'] = "voltage";
$entitysensor['amperes'] = "current";
$entitysensor['watt'] = "power";
$entitysensor['hertz'] = "freq";
$entitysensor['percentRH'] = "humidity";
$entitysensor['rpm'] = "fanspeed";
$entitysensor['celsius'] = "temperature";
if(is_array($oids[$device['device_id']]))
{
foreach($oids[$device['device_id']] as $index => $entry)
{
#echo("[" . $entry['entSensorType'] . "|" . $entry['entSensorValue']. "|" . $index . "]");
if($entitysensor[$entry['entSensorType']] && is_numeric($entry['entSensorValue']) && is_numeric($index))
{
$entPhysicalIndex = $index;
$entPhysicalIndex_measured = $entry['entSensorMeasuredEntity'];
$descr = snmp_get($device, "entPhysicalDescr.".$index, "-Oqv", "ENTITY-MIB");
$oid = ".1.3.6.1.4.1.9.9.91.1.1.1.1.4.".$index;
$current = $entry['entSensorValue'];
$type = $entitysensor[$entry['entSensorType']];
#echo("$index : ".$entry['entSensorScale']."|");
### FIXME this stuff is foul
if($entry['entSensorScale'] == "nano") { $divisor = "1000000000"; $multiplier = "1"; }
if($entry['entSensorScale'] == "micro") { $divisor = "1000000"; $multiplier = "1"; }
if($entry['entSensorScale'] == "milli") { $divisor = "1000"; $multiplier = "1"; }
if($entry['entSensorScale'] == "units") { $divisor = "1"; $multiplier = "1"; }
if($entry['entSensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; }
if($entry['entSensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; }
if($entry['entSensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; }
$current = $current * $multiplier / $divisor;
discover_sensor($valid_sensor, $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, NULL, NULL, NULL, NULL, $temperature);
$cisco_entity_temperature = 1;
}
}
}
}
?>

View File

@ -0,0 +1,66 @@
<?php
global $valid_sensor;
echo("ENTITY-SENSOR ");
$oids = array();
$oids = snmpwalk_cache_multi_oid($device, "entPhySensorType", $oids, "ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entPhySensorScale", $oids, "ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entPhySensorPrecision", $oids, "ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entPhySensorValue", $oids, "ENTITY-SENSOR-MIB");
$entitysensor['voltsDC'] = "voltage";
$entitysensor['voltsAC'] = "voltage";
$entitysensor['amperes'] = "current";
$entitysensor['watt'] = "power";
$entitysensor['hertz'] = "freq";
$entitysensor['percentRH'] = "humidity";
$entitysensor['rpm'] = "fanspeed";
$entitysensor['celsius'] = "temperature";
if(is_array($oids[$device['device_id']]))
{
foreach($oids[$device['device_id']] as $index => $entry)
{
#echo("[" . $entry['entPhySensorType'] . "|" . $entry['entPhySensorValue']. "|" . $index . "]");
if($entitysensor[$entry['entPhySensorType']] && is_numeric($entry['entPhySensorValue']) && is_numeric($index))
{
$entPhysicalIndex = $index;
$descr = snmp_get($device, "entPhysicalDescr.".$index, "-Oqv", "ENTITY-SENSOR-MIB");
$oid = ".1.3.6.1.2.1.99.1.1.1.4.".$index;
$current = $entry['entPhySensorValue'];
#ENTITY-SENSOR-MIB::entPhySensorUnitsDisplay.11 = STRING: "C"
$type = $entitysensor[$entry['entPhySensorType']];
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("sensor", "", $descr);
### FIXME this stuff is foul
if($entry['entPhySensorScale'] == "nano") { $divisor = "1000000000"; $multiplier = "1"; }
if($entry['entPhySensorScale'] == "micro") { $divisor = "1000000"; $multiplier = "1"; }
if($entry['entPhySensorScale'] == "milli") { $divisor = "1000"; $multiplier = "1"; }
if($entry['entPhySensorScale'] == "units") { $divisor = "1"; $multiplier = "1"; }
if($entry['entPhySensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; }
if($entry['entPhySensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; }
if($entry['entPhySensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; }
if(is_numeric($entry['entPhySensorPrecision']) && $entry['entPhySensorPrecision'] > "0") { $multiplier = $multiplier . str_pad('', $entry['entPhySensorPrecision'], "0"); }
#echo("|".$entry['entPhySensorScale']."|".$entry['entPhySensorPrecision']."|".$divisor."|".$multiplier."|");
$current = $current * $multiplier / $divisor;
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = '".$device['device_id']."' AND `sensor_class` = '".$type."' AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = '".$index."'"),0) == "0")
## Check to make sure we've not already seen this sensor via cisco's entity sensor mib
{
discover_sensor($valid_sensor, $type, $device, $oid, $index, 'entity-sensor', $descr, $divisor, $multiplier, NULL, NULL, NULL, NULL, $current);
}
}
}
}
?>

View File

@ -48,7 +48,7 @@ function check_valid_sensors($device, $class, $valid) {
if(!$valid[$class][$type][$index])
{
echo("-");
mysql_query("DELETE FROM `sensors` WHERE sensor_class='humidity' AND sensor_id = '" . $test['sensor_id'] . "'");
mysql_query("DELETE FROM `sensors` WHERE sensor_class='".$class."' AND sensor_id = '" . $test['sensor_id'] . "'");
log_event("Sensor Deleted: ".$test['sensor_class']." ".$test['sensor_type']." ". $test['sensor_index']." ".$test['sensor_descr'], $device['device_id'], 'sensor', $sensor_id);
}
unset($oid); unset($type);

View File

@ -0,0 +1,27 @@
<?php
global $valid_processor;
##
## Hardcoded discovery of cpu usage on HP Procurve devices.
##
## STATISTICS-MIB::hpSwitchCpuStat.0 = INTEGER: 10
if($device['os'] == "procurve")
{
echo("Procurve : ");
$descr = "Processor";
$usage = snmp_get($device, ".1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "-OQUvs", "STATISTICS-MIB", $config['mib_dir'].":".$config['mib_dir']."/hp");
if(is_numeric($usage))
{
discover_processor($valid_processor, $device, "1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0", "0", "procurve-fixed", $descr, "1", $usage, NULL, NULL);
}
}
unset ($processors_array);
?>

View File

@ -0,0 +1,19 @@
<?php
$valid_sensor = array();
echo("Sensors: ");
include("includes/discovery/cisco-entity-sensor.inc.php");
include("includes/discovery/entity-sensor.inc.php");
include("includes/discovery/temperatures.inc.php");
include("includes/discovery/humidity.inc.php");
include("includes/discovery/voltages.inc.php");
include("includes/discovery/frequencies.inc.php");
include("includes/discovery/current.inc.php");
include("includes/discovery/fanspeeds.inc.php");
unset($valid_sensor);
?>

View File

@ -1,42 +0,0 @@
<?php
global $valid_sensor;
if ($device['os'] == "ios" || $device['os_group'] == "ios")
{
echo("CISCO-ENTITY-SENSOR");
$oids = array();
$oids = snmpwalk_cache_multi_oid($device, "entSensorType", $oids, "CISCO-ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entSensorScale", $oids, "CISCO-ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entSensorValue", $oids, "CISCO-ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entSensorMeasuredEntity", $oids, "CISCO-ENTITY-SENSOR-MIB");
if(is_array($oids[$device['device_id']]))
{
foreach($oids[$device['device_id']] as $index => $entry)
{
#echo("[" . $entry['entSensorType'] . "|" . $entry['entSensorValue']. "|" . $index . "]");
if($entry['entSensorType'] == "celsius" && is_numeric($entry['entSensorValue']) && is_numeric($index) && $entry['entSensorValue'] > "0" && $entry['entSensorValue'] < "1000")
{
$entPhysicalIndex = $index;
$entPhysicalIndex_measured = $entry['entSensorMeasuredEntity'];
$descr = snmp_get($device, "entPhysicalDescr.".$index, "-Oqv", "ENTITY-MIB");
$oid = ".1.3.6.1.4.1.9.9.91.1.1.1.1.4.".$index;
$current = $entry['entSensorValue'];
## FIXME this sucks
if($entry['entSensorScale'] == "milli") { $divisor = "1000"; } else { $divisor = "1"; }
discover_sensor($valid_sensor, 'temperature', $device, $oid, $index, 'cisco-entity-sensor', $descr, '1', '1', NULL, NULL, NULL, NULL, $temperature);
$cisco_entity_temperature = 1;
}
}
}
}
?>

View File

@ -1,45 +0,0 @@
<?php
global $valid_sensor;
echo("ENTITY-SENSOR ");
$oids = array();
$oids = snmpwalk_cache_multi_oid($device, "entPhySensorType", $oids, "ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entPhySensorScale", $oids, "ENTITY-SENSOR-MIB");
$oids = snmpwalk_cache_multi_oid($device, "entPhySensorValue", $oids, "ENTITY-SENSOR-MIB");
if(is_array($oids[$device['device_id']]))
{
foreach($oids[$device['device_id']] as $index => $entry)
{
#echo("[" . $entry['entPhySensorType'] . "|" . $entry['entPhySensorValue']. "|" . $index . "]");
if($entry['entPhySensorType'] == "celsius" && is_numeric($entry['entPhySensorValue']) && is_numeric($index) && $entry['entPhySensorValue'] > "0" && $entry['entPhySensorValue'] < "1000")
{
$entPhysicalIndex = $index;
$descr = snmp_get($device, "entPhysicalDescr.".$index, "-Oqv", "ENTITY-SENSOR-MIB");
$oid = ".1.3.6.1.2.1.99.1.1.1.4.".$index;
$current = $entry['entPhySensorValue'];
#ENTITY-SENSOR-MIB::entPhySensorUnitsDisplay.11 = STRING: "C"
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("sensor", "", $descr);
### FIXME this stuff is foul
if($entry['entPhySensorScale'] == "milli") { $divisor = "1000"; } else { $divisor = "1"; }
if($entry['entPhySensorPrecision'] == "1") { $multiplier = "10"; } else { $multiplier = "1"; }
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = '".$device['device_id']."' AND `sensor_class` = 'temperature' AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = '".$index."'"),0) == "0")
## Check to make sure we've not already seen this sensor via cisco's entity sensor mib
{
discover_sensor($valid_sensor, 'temperature', $device, $oid, $index, 'entity-sensor', $descr, $divisor, $multiplier, NULL, NULL, NULL, NULL, $current);
}
}
}
}
?>

View File

@ -20,7 +20,7 @@ if ($device['os'] == "linux")
$index = $split_oid[count($split_oid)-1];
$oid = "1.3.6.1.4.1.2021.13.16.4.1.3." . $index;
$current = snmp_get($device, $oid, "-Oqv", "LM-SENSORS-MIB") / $divisor;
echo discover_sensor($valid_sensor, 'volt', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
}
}
@ -45,7 +45,7 @@ if ($device['os'] == "areca")
$current = snmp_get($device, $oid, "-Oqv", "") / $divisor;
if ($descr != '"Battery Status"' || $current != 0.255) # FIXME not sure if this is supposed to be a voltage, but without BBU it's 225, then ignore.
{
echo discover_sensor($valid_sensor, 'volt', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
}
}
@ -69,7 +69,7 @@ if ($device['os'] == "apc")
$index = $split_oid[count($split_oid)-3];
$oid = "1.3.6.1.4.1.318.1.1.8.5.3.3.1.3." . $index . ".1.1";
$descr = "Input Feed " . chr(64+$index);
echo discover_sensor($valid_sensor, 'volt', $device, $oid, "3.3.1.3.$index", $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $oid, "3.3.1.3.$index", $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
}
@ -89,7 +89,7 @@ if ($device['os'] == "apc")
$index = $split_oid[count($split_oid)-3];
$oid = "1.3.6.1.4.1.318.1.1.8.5.4.3.1.3." . $index . ".1.1";
$descr = "Output Feed"; if (count(explode("\n", $oids)) > 1) { $descr .= " $index"; }
echo discover_sensor($valid_sensor, 'volt', $device, $oid, "4.3.1.3.$index", $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $oid, "4.3.1.3.$index", $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
}
@ -103,7 +103,7 @@ if ($device['os'] == "apc")
$type = "apc";
$index = "3.2.1.0";
$descr = "Input";
echo discover_sensor($valid_sensor, 'volt', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
$oids = snmp_get($device, "1.3.6.1.4.1.318.1.1.1.4.2.1.0", "-OsqnU", "");
@ -116,7 +116,7 @@ if ($device['os'] == "apc")
$type = "apc";
$index = "4.2.1.0";
$descr = "Output";
echo discover_sensor($valid_sensor, 'volt', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
}
@ -154,7 +154,7 @@ if ($device['os'] == "linux")
if ($monitor == 'true')
{
echo discover_sensor($valid_sensor, 'volt', $device, $volt_oid, $index, $type, $descr, $divisor, '1', $lowlimit, NULL, $limit, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', $lowlimit, NULL, $limit, NULL, $current);
}
}
}
@ -182,7 +182,7 @@ if ($device['os'] == "mgeups")
$type = "mge-ups";
$divisor = 10;
$index = $i;
echo discover_sensor($valid_sensor, 'volt', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
$oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.6.1", "-OsqnU"));
if ($debug) { echo($oids."\n"); }
@ -201,7 +201,7 @@ if ($device['os'] == "mgeups")
$type = "mge-ups";
$divisor = 10;
$index = 100+$i;
echo discover_sensor($valid_sensor, 'volt', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
}
@ -228,7 +228,7 @@ if ($device['os'] == "netmanplus")
$descr = "Battery" . (count(explode("\n",$oids)) == 1 ? '' : ' ' . ($volt_id+1));
$type = "netmanplus";
$index = 500+$volt_id;
echo discover_sensor($valid_sensor, 'volt', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $volt);
echo discover_sensor($valid_sensor, 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $volt);
}
}
@ -243,7 +243,7 @@ if ($device['os'] == "netmanplus")
$type = "netmanplus";
$divisor = 1;
$index = $i;
echo discover_sensor($valid_sensor, 'volt', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.3.2.0", "-OsqnU"));
@ -257,7 +257,7 @@ if ($device['os'] == "netmanplus")
$type = "netmanplus";
$divisor = 1;
$index = 100+$i;
echo discover_sensor($valid_sensor, 'volt', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.5.2.0", "-OsqnU"));
@ -271,7 +271,7 @@ if ($device['os'] == "netmanplus")
$type = "netmanplus";
$divisor = 1;
$index = 200+$i;
echo discover_sensor($valid_sensor, 'volt', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
echo discover_sensor($valid_sensor, 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current);
}
}
@ -287,7 +287,7 @@ if ($device['os'] == "gamatronicups")
$index = $i;
$lowlimit = 0;
$limit = NULL;
echo discover_sensor($valid_sensor, 'volt', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $volt);
echo discover_sensor($valid_sensor, 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $volt);
}
for($i = 1; $i <= 3 ;$i++)
@ -300,14 +300,14 @@ if ($device['os'] == "gamatronicups")
$index = 100+$i;
$lowlimit = 0;
$limit = NULL;
echo discover_sensor($valid_sensor, 'volt', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $volt);
echo discover_sensor($valid_sensor, 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $volt);
}
}
if($debug) { print_r($valid['volt']); }
if($debug) { print_r($valid['voltage']); }
check_valid_sensors($device, 'volt', $valid_sensor);
check_valid_sensors($device, 'voltage', $valid_sensor);
echo("\n");

View File

@ -11,7 +11,6 @@ while($dbcurrent = mysql_fetch_array($current_data)) {
if ($dbcurrent['sensor_divisor']) { $current = $current / $dbcurrent['sensor_divisor']; }
if ($dbcurrent['sensor_multplier']) { $current = $current * $dbcurrent['sensor_multiplier']; }
$currentrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("current-" . $dbcurrent['sensor_descr'] . ".rrd");
if (!is_file($currentrrd)) {

View File

@ -11,7 +11,6 @@ while($fanspeed = mysql_fetch_array($fan_data)) {
if ($fanspeed['sensor_divisor']) { $fan = $fan / $fanspeed['sensor_divisor']; }
if ($fanspeed['sensor_multiplier']) { $fan = $fan * $fanspeed['sensor_multiplier']; }
$fanrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("fan-" . $fanspeed['sensor_descr'] . ".rrd");
if (!is_file($fanrrd)) {

View File

@ -1,22 +1,22 @@
<?php
$query = "SELECT * FROM frequency WHERE device_id = '" . $device['device_id'] . "'";
$freq_data = mysql_query($query);
while($frequency = mysql_fetch_array($freq_data)) {
$query = "SELECT * FROM `sensors` WHERE device_id = '" . $device['device_id'] . "' AND `sensor_class` = 'freq'";
$sensor_data = mysql_query($query);
while($frequency = mysql_fetch_array($sensor_data)) {
echo("Checking frequency " . $frequency['freq_descr'] . "... ");
echo("Checking frequency " . $frequency['sensor_descr'] . "... ");
$freq = snmp_get($device, $frequency['freq_oid'], "-OUqnv", "SNMPv2-MIB");
$freq = snmp_get($device, $frequency['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
if ($frequency['freq_precision'])
if ($frequency['sensor_precision'])
{
$freq = $freq / $frequency['freq_precision'];
$freq = $freq / $frequency['sensor_precision'];
}
$freqrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("freq-" . $frequency['freq_descr'] . ".rrd");
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("freq-" . $frequency['sensor_descr'] . ".rrd");
if (!is_file($freqrrd)) {
`rrdtool create $freqrrd \
if (!is_file($rrd_file)) {
`rrdtool create $rrd_file \
--step 300 \
DS:freq:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
@ -27,28 +27,28 @@ while($frequency = mysql_fetch_array($freq_data)) {
echo($freq . " Hz\n");
rrdtool_update($freqrrd,"N:$freq");
rrdtool_update($rrd_file,"N:$freq");
if($frequency['freq_current'] > $frequency['freq_limit_low'] && $freq <= $frequency['freq_limit_low'])
if($frequency['sensor_current'] > $frequency['sensor_limit_low'] && $freq <= $frequency['sensor_limit_low'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['sensor_descr'] . " is " . $freq . "Hz (Limit " . $frequency['sensor_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
log_event('Frequency ' . $frequency['freq_descr'] . " under threshold: " . $freq . " Hz (< " . $frequency['freq_limit_low'] . " Hz)", $device['device_id'] , 'frequency', $frequency['freq_id']);
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $frequency['sensor_descr'] . "\n");
log_event('Frequency ' . $frequency['sensor_descr'] . " under threshold: " . $freq . " Hz (< " . $frequency['sensor_limit_low'] . " Hz)", $device['device_id'] , 'frequency', $frequency['sensor_id']);
}
else if($frequency['freq_current'] < $frequency['freq_limit'] && $freq >= $frequency['freq_limit'])
else if($frequency['sensor_current'] < $frequency['sensor_limit'] && $freq >= $frequency['sensor_limit'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['sensor_descr'] . " is " . $freq . "Hz (Limit " . $frequency['sensor_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
log_event('Frequency ' . $frequency['freq_descr'] . " above threshold: " . $freq . " Hz (> " . $frequency['freq_limit'] . " Hz)", $device['device_id'], 'frequency', $frequency['freq_id']);
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $frequency['sensor_descr'] . "\n");
log_event('Frequency ' . $frequency['sensor_descr'] . " above threshold: " . $freq . " Hz (> " . $frequency['sensor_limit'] . " Hz)", $device['device_id'], 'frequency', $frequency['sensor_id']);
}
mysql_query("UPDATE frequency SET freq_current = '$freq' WHERE freq_id = '" . $frequency['freq_id'] . "'");
mysql_query("UPDATE frequency SET sensor_current = '$freq' WHERE sensor_id = '" . $frequency['sensor_id'] . "'");
}
?>

View File

@ -14,7 +14,6 @@ while($humidity = mysql_fetch_array($hum_data)) {
if ($humidity['sensor_divisor']) { $hum = $hum / $humidity['sensor_divisor']; }
if ($humidity['sensor_multiplier']) { $hum = $hum / $humidity['sensor_multiplier']; }
$humrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("humidity-" . $humidity['sensor_descr'] . ".rrd");
if (!is_file($humrrd)) {

View File

@ -0,0 +1,6 @@
<?
list(,,,,$version,,,,,,$hardware) = explode (" ", $sysDescr);
?>

View File

@ -19,21 +19,32 @@ while($temperature = mysql_fetch_array($temp_data)) {
if ($temperature['sensor_divisor']) { $temp = $temp / $temperature['sensor_divisor']; }
if ($temperature['sensor_multiplier']) { $temp = $temp * $temperature['sensor_multiplier']; }
$temprrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("temp-" . $temperature['sensor_descr'] . ".rrd");
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("temp-" . $temperature['sensor_descr'] . ".rrd");
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . safename($temperature['sensor_type']."-".$temperature['sensor_index']) . ".rrd";
if (!is_file($temprrd)) {
`rrdtool create $temprrd \
if(is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
if (!is_file($rrd_file)) {
`rrdtool create $rrd_file \
--step 300 \
DS:temp:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797\
RRA:MIN:0.5:1:600 \
RRA:MIN:0.5:6:700 \
RRA:MIN:0.5:24:775 \
RRA:MIN:0.5:288:797`;
}
echo($temp . "C\n");
rrdtool_update($temprrd,"N:$temp");
rrdtool_update($rrd_file,"N:$temp");
if($temperature['sensor_current'] < $temperature['sensor_limit'] && $temp >= $temperature['sensor_limit']) {
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }

View File

@ -11,10 +11,10 @@ while($voltage = mysql_fetch_array($volt_data)) {
if ($voltage['sensor_divisor']) { $volt = $volt / $voltage['sensor_divisor']; }
if ($voltage['sensor_multiplier']) { $volt = $volt * $voltage['sensor_multiplier']; }
$voltrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("volt-" . $voltage['sensor_descr'] . ".rrd");
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("volt-" . $voltage['sensor_descr'] . ".rrd");
if (!is_file($voltrrd)) {
`rrdtool create $voltrrd \
if (!is_file($rrd_file)) {
`rrdtool create $rrd_file \
--step 300 \
DS:volt:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
@ -25,7 +25,7 @@ while($voltage = mysql_fetch_array($volt_data)) {
echo($volt . " V\n");
rrdtool_update($voltrrd,"N:$volt");
rrdtool_update($rrd_file,"N:$volt");
if($voltage['sensor_current'] > $voltage['sensor_limit_low'] && $volt <= $voltage['sensor_limit_low'])
{

View File

@ -40,36 +40,6 @@ $rewrite_entSensorType = array (
'truthvalue' => '',
);
function entPhysical_scale($value, $scale) {
switch ($scale) {
case "nano":
$value = $value / 1000000000;
break;
case "micro":
$value = $value / 1000000;
break;
case "milli":
$value = $value / 1000;
break;
case "units":
break;
case "kilo":
$value = $value * 1000;
break;
case "mega":
$value = $value * 1000000;
break;
case "giga":
$value = $value * 1000000000;
break;
}
return $value;
}
$translate_ifOperStatus = array(
"1" => "up",
"2" => "down",

View File

@ -44,13 +44,14 @@ $devices_polled = 0;
echo("includes/discovery/".$type.".php \n");
$debug = 1;
#$debug = 1;
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id ASC");
while ($device = mysql_fetch_array($device_query)) {
echo($device['hostname'] . "(".$device['sysName']."|".$device['device_id'].")\n");
if($config['os'][$device['os']]['group']) {$device['os_group'] = $config['os'][$device['os']]['group']; echo "(".$device['os_group'].")";}
include("includes/discovery/".$type);