mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
more fixes for new sensor setup. more to come no doubt. also started making graphs which can 'widen'
git-svn-id: http://www.observium.org/svn/observer/trunk@1534 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -33,11 +33,19 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
|
||||
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");
|
||||
$descr = snmp_get($device, "entPhysicalName.".$index, "-Oqv", "ENTITY-MIB");
|
||||
if(is_numeric($entry['entSensorMeasuredEntity']) && $entry['entSensorMeasuredEntity']) {
|
||||
$measured_descr = snmp_get($device, "entPhysicalName.".$entry['entSensorMeasuredEntity'],"-Oqv", "ENTITY-MIB");
|
||||
$descr = $measured_descr . " - " . $descr;
|
||||
}
|
||||
|
||||
### Bit dirty also, clean later
|
||||
$descr = str_replace("Temp: ", "", $descr);
|
||||
$descr = str_replace("temperature ", "", $descr);
|
||||
$descr = str_replace("Temperature ", "", $descr);
|
||||
|
||||
$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']."|");
|
||||
@@ -51,7 +59,6 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
|
||||
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;
|
||||
|
||||
@@ -2,16 +2,19 @@
|
||||
|
||||
$query = "SELECT * FROM sensors WHERE sensor_class='voltage' AND device_id = '" . $device['device_id'] . "'";
|
||||
$volt_data = mysql_query($query);
|
||||
while($voltage = mysql_fetch_array($volt_data)) {
|
||||
while($sensor = mysql_fetch_array($volt_data)) {
|
||||
|
||||
echo("Checking voltage " . $voltage['sensor_descr'] . "... ");
|
||||
echo("Checking voltage " . $sensor['sensor_descr'] . "... ");
|
||||
|
||||
$volt = snmp_get($device, $voltage['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
|
||||
$volt = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
|
||||
|
||||
if ($voltage['sensor_divisor']) { $volt = $volt / $voltage['sensor_divisor']; }
|
||||
if ($voltage['sensor_multiplier']) { $volt = $volt * $voltage['sensor_multiplier']; }
|
||||
if ($sensor['sensor_divisor']) { $volt = $volt / $sensor['sensor_divisor']; }
|
||||
if ($sensor['sensor_multiplier']) { $volt = $volt * $sensor['sensor_multiplier']; }
|
||||
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("volt-" . $voltage['sensor_descr'] . ".rrd");
|
||||
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("volt-" . $sensor['sensor_descr'] . ".rrd");
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/volt-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
|
||||
|
||||
if(is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
|
||||
|
||||
if (!is_file($rrd_file)) {
|
||||
`rrdtool create $rrd_file \
|
||||
@@ -27,25 +30,25 @@ while($voltage = mysql_fetch_array($volt_data)) {
|
||||
|
||||
rrdtool_update($rrd_file,"N:$volt");
|
||||
|
||||
if($voltage['sensor_current'] > $voltage['sensor_limit_low'] && $volt <= $voltage['sensor_limit_low'])
|
||||
if($sensor['sensor_current'] > $sensor['sensor_limit_low'] && $volt <= $sensor['sensor_limit_low'])
|
||||
{
|
||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'] . " is " . $volt . "V (Limit " . $voltage['sensor_limit'];
|
||||
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit'];
|
||||
$msg .= "V) at " . date($config['timestamp_format']);
|
||||
notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'], $msg);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $voltage['sensor_descr'] . "\n");
|
||||
log_event('Voltage ' . $voltage['sensor_descr'] . " under threshold: " . $volt . " V (< " . $voltage['sensor_limit_low'] . " V)", $device['device_id'], 'voltage', $voltage['sensor_id']);
|
||||
notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
|
||||
log_event('Voltage ' . $sensor['sensor_descr'] . " under threshold: " . $volt . " V (< " . $sensor['sensor_limit_low'] . " V)", $device['device_id'], 'voltage', $sensor['sensor_id']);
|
||||
}
|
||||
else if($voltage['sensor_current'] < $voltage['sensor_limit'] && $volt >= $voltage['sensor_limit'])
|
||||
else if($sensor['sensor_current'] < $sensor['sensor_limit'] && $volt >= $sensor['sensor_limit'])
|
||||
{
|
||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'] . " is " . $volt . "V (Limit " . $voltage['sensor_limit'];
|
||||
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit'];
|
||||
$msg .= "V) at " . date($config['timestamp_format']);
|
||||
notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'], $msg);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $voltage['sensor_descr'] . "\n");
|
||||
log_event('Voltage ' . $voltage['sensor_descr'] . " above threshold: " . $volt . " V (> " . $voltage['sensor_limit'] . " V)", $device['device_id'], 'voltage', $voltage['sensor_id']);
|
||||
notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
|
||||
log_event('Voltage ' . $sensor['sensor_descr'] . " above threshold: " . $volt . " V (> " . $sensor['sensor_limit'] . " V)", $device['device_id'], 'voltage', $sensor['sensor_id']);
|
||||
}
|
||||
mysql_query("UPDATE sensors SET sensor_current = '$volt' WHERE sensor_class='voltage' AND sensor_id = '" . $voltage['sensor_id'] . "'");
|
||||
mysql_query("UPDATE sensors SET sensor_current = '$volt' WHERE sensor_class='voltage' AND sensor_id = '" . $sensor['sensor_id'] . "'");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user