mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
voltages without thresholds will now be set +/- 5%. i expect this will cause a shitstorm amongst cheap hardware, but lets see how it goes. need some means of tuning these (it only sets if a limit isn't passed to the function, and there isn't already a limit in the database)
git-svn-id: http://www.observium.org/svn/observer/trunk@1152 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -216,6 +216,10 @@ function discover_volt($device, $oid, $index, $type, $descr, $precision = 1, $lo
|
||||
|
||||
if (mysql_result(mysql_query("SELECT count(volt_id) FROM `voltage` WHERE device_id = '".$device['device_id']."' AND volt_type = '$type' AND `volt_index` = '$index'"),0) == '0')
|
||||
{
|
||||
|
||||
if(!$high_limit && isset($current)) { $high_limit = round($current * 1.05, 2); }
|
||||
if(!$low_limit && isset($current)) { $low_limit = round($current * 0.95, 2); }
|
||||
|
||||
$query = "INSERT INTO voltage (`device_id`, `volt_oid`, `volt_index`, `volt_type`, `volt_descr`, `volt_precision`, `volt_limit`, `volt_limit_low`, `volt_current`) ";
|
||||
$query .= " VALUES ('".$device['device_id']."', '$oid', '$index', '$type', '$descr', '$precision', '$high_limit', '$low_limit', '$current')";
|
||||
mysql_query($query);
|
||||
@@ -224,16 +228,25 @@ function discover_volt($device, $oid, $index, $type, $descr, $precision = 1, $lo
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$volt_entry = mysql_fetch_array(mysql_query("SELECT * FROM `voltage` WHERE device_id = '".$device['device_id']."' AND volt_type = '$type' AND `volt_index` = '$index'"));
|
||||
if($oid == $volt_entry['volt_oid'] && $descr == $volt_entry['volt_descr'] && $precision == $volt_entry['volt_precision'])
|
||||
|
||||
if(!isset($current) && isset($volt_entry['current'])) { $current = $volt_entry['current']; }
|
||||
|
||||
|
||||
if(!$high_limit && !$volt_entry['volt_limit'] && $current) { $high_limit = round($current * 1.05, 2); } elseif (!$high_limit && $volt_entry['volt_limit']) { $high_limit = $volt_entry['volt_limit']; }
|
||||
if(!$low_limit && !$volt_entry['volt_limit_low'] && $current) { $low_limit = round($current * 0.95, 2); } elseif (!$low_limit && $volt_entry['volt_limit_low']) { $low_limit = $volt_entry['volt_limit_low']; }
|
||||
|
||||
if($oid == $volt_entry['volt_oid'] && $descr == $volt_entry['volt_descr'] && $precision == $volt_entry['volt_precision'] && $volt_entry['volt_limit'] == $high_limit && $volt_entry['volt_limit_low'] == $low_limit)
|
||||
{
|
||||
echo(".");
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_query("UPDATE voltage SET `volt_descr` = '$descr', `volt_oid` = '$oid', `volt_precision` = '$precision' WHERE `device_id` = '" . $device['device_id'] . "' AND volt_type = '$type' AND `volt_index` = '$index' ");
|
||||
$sql = "UPDATE voltage SET `volt_descr` = '$descr', `volt_oid` = '$oid', `volt_precision` = '$precision', `volt_limit_low` = '$low_limit', `volt_limit` = '$high_limit' WHERE `device_id` = '" . $device['device_id'] . "' AND volt_type = '$type' AND `volt_index` = '$index'";
|
||||
$query = mysql_query($sql);
|
||||
echo("U");
|
||||
if($debug) { echo("$query ". mysql_affected_rows() . " updated"); }
|
||||
if($debug) { echo("$sql ". mysql_affected_rows() . " updated"); }
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user