diff --git a/database-update.sql b/database-update.sql index adff9bae21..092ccff9ff 100644 --- a/database-update.sql +++ b/database-update.sql @@ -35,3 +35,4 @@ ALTER TABLE `vminfo` ADD `vm_type` VARCHAR(16) NOT NULL DEFAULT 'vmware' AFTER ` CREATE TABLE IF NOT EXISTS `cef_switching` ( `device_id` int(11) NOT NULL, `entPhysicalIndex` int(11) NOT NULL, `afi` varchar(4) COLLATE utf8_unicode_ci NOT NULL, `cef_index` int(11) NOT NULL, `cef_path` varchar(16) COLLATE utf8_unicode_ci NOT NULL, `drop` int(11) NOT NULL, `punt` int(11) NOT NULL, `punt2host` int(11) NOT NULL, `drop_prev` int(11) NOT NULL, `punt_prev` int(11) NOT NULL, `punt2host_prev` int(11) NOT NULL,`updated` INT NOT NULL , `updated_prev` INT NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `mac_accounting` CHANGE `peer_mac` `mac` VARCHAR( 32 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ALTER TABLE `mac_accounting` DROP `peer_ip`, DROP `peer_desc`, DROP `peer_asn`; +UPDATE sensors SET sensor_class='frequency' WHERE sensor_class='freq'; diff --git a/html/includes/graphs/device/frequency.inc.php b/html/includes/graphs/device/frequency.inc.php index 283b95ddb6..4f055ec44a 100644 --- a/html/includes/graphs/device/frequency.inc.php +++ b/html/includes/graphs/device/frequency.inc.php @@ -6,7 +6,7 @@ $device = device_by_id_cache($id); $rrd_options .= " -l 0 -E "; $iter = "1"; -$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='freq' AND device_id = '$id'"); +$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)) diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index 5c3947df8e..4a3af577e1 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -53,11 +53,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id']) mysql_result(mysql_query("select count(sensor_id) from sensors WHERE device_id = '" . $device['device_id'] . "'"), 0) + mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0) + mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0) + - mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0) + - mysql_result(mysql_query("select count(current_id) from current WHERE device_id = '" . $device['device_id'] . "'"), 0) + - mysql_result(mysql_query("select count(freq_id) from frequencies WHERE device_id = '" . $device['device_id'] . "'"), 0) + - mysql_result(mysql_query("select count(volt_id) from voltage WHERE device_id = '" . $device['device_id'] . "'"), 0) + - mysql_result(mysql_query("select count(fan_id) from fanspeed WHERE device_id = '" . $device['device_id'] . "'"), 0); + mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0); if ($health) { diff --git a/html/pages/device/health.inc.php b/html/pages/device/health.inc.php index a976519ded..9eede00b84 100644 --- a/html/pages/device/health.inc.php +++ b/html/pages/device/health.inc.php @@ -10,7 +10,7 @@ $humidity = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_ $fans = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='fanspeed' AND device_id = '" . $device['device_id'] . "'"), 0); $volts = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='voltage' AND device_id = '" . $device['device_id'] . "'"), 0); $current = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='current' AND device_id = '" . $device['device_id'] . "'"), 0); -$freqs = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='freq' AND device_id = '" . $device['device_id'] . "'"), 0); +$freqs = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='frequency' AND device_id = '" . $device['device_id'] . "'"), 0); $datas[] = 'overview'; if ($processor) { $datas[] = 'processor'; } diff --git a/html/pages/device/health/frequency.inc.php b/html/pages/device/health/frequency.inc.php index dffb79c938..4ad62f40d4 100644 --- a/html/pages/device/health/frequency.inc.php +++ b/html/pages/device/health/frequency.inc.php @@ -1,6 +1,6 @@ = '5') { - $sql = "SELECT * FROM `sensors` AS V, `devices` AS D WHERE V.sensor_class='freq' AND V.device_id = D.device_id ORDER BY D.hostname, V.sensor_descr"; + $sql = "SELECT * FROM `sensors` AS V, `devices` AS D WHERE V.sensor_class='frequency' AND V.device_id = D.device_id ORDER BY D.hostname, V.sensor_descr"; } else { - $sql = "SELECT * FROM `sensors` AS V, `devices` AS D, devices_perms as P WHERE V.sensor_class='freq' V.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, V.sensor_descr"; + $sql = "SELECT * FROM `sensors` AS V, `devices` AS D, devices_perms as P WHERE V.sensor_class='frequency' V.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, V.sensor_descr"; } $query = mysql_query($sql); diff --git a/includes/polling/current.inc.php b/includes/polling/current.inc.php deleted file mode 100644 index 3a207d2f9d..0000000000 --- a/includes/polling/current.inc.php +++ /dev/null @@ -1,51 +0,0 @@ - $sensor['sensor_limit_low'] && $current <= $sensor['sensor_limit_low']) - { - $msg = "Current Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is under threshold: " . $current . "A (< " . $sensor['sensor_limit']; - $msg .= "A) at " . date($config['timestamp_format']); - notify($device, "Current Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); - echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); - log_event('Current ' . $sensor['sensor_descr'] . " under threshold: " . $current . " A (< " . $sensor['sensor_limit_low'] . " A)", $device, 'current', $current['sensor_id']); - } - else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $current >= $sensor['sensor_limit']) - { - $msg = "Current Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is over threshold: " . $current . "A (> " . $sensor['sensor_limit']; - $msg .= "A) at " . date($config['timestamp_format']); - notify($device, "Current Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); - echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); - log_event('Current ' . $sensor['sensor_descr'] . " above threshold: " . $current . " A (> " . $sensor['sensor_limit'] . " A)", $device, 'current', $current['sensor_id']); - } - - mysql_query("UPDATE sensors SET sensor_current = '$current' WHERE sensor_class='current' AND sensor_id = '" . $sensor['sensor_id'] . "'"); -} - -?> \ No newline at end of file diff --git a/includes/polling/fanspeeds.inc.php b/includes/polling/fanspeeds.inc.php deleted file mode 100755 index cab43daf9a..0000000000 --- a/includes/polling/fanspeeds.inc.php +++ /dev/null @@ -1,54 +0,0 @@ - $sensor['sensor_limit_low'] && $fan <= $sensor['sensor_limit_low']) - { - $msg = "Fan Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $fan . "rpm (Limit " . $sensor['sensor_limit_low']; - $msg .= "rpm) at " . date($config['timestamp_format']); - notify($device, "Fan Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); - echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); - log_event('Fan speed ' . $sensor['sensor_descr'] . " under threshold: " . $sensor['sensor_current'] . " rpm (<= " . $sensor['sensor_limit_low'] . " rpm)", $device, 'fanspeed', $sensor['sensor_id']); - } - else if ($sensor['sensor_limit_low_warn'] != "" && $sensor['sensor_limit_low_warn'] && $sensor['sensor_current'] > $sensor['sensor_limit_warn'] && $fan <= $sensor['sensor_limit_low_warn']) - { - $msg = "Fan Warning: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $fan . "rpm (Warning limit " . $sensor['sensor_limit_low_warn']; - $msg .= "rpm) at " . date($config['timestamp_format']); - notify($device, "Fan Warning: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); - echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); - log_event('Fan speed ' . $sensor['sensor_descr'] . " under warning threshold: " . $sensor['sensor_current'] . " rpm (<= " . $sensor['sensor_limit_low_warn'] . " rpm)", $device, 'fanspeed', $sensor['sensor_id']); - } - - mysql_query("UPDATE sensors SET sensor_current = '$fan' WHERE sensor_class='fanspeed' AND sensor_id = '" . $sensor['sensor_id'] . "'"); -} - -?> \ No newline at end of file diff --git a/includes/polling/frequencies.inc.php b/includes/polling/frequencies.inc.php deleted file mode 100644 index 0cd552eeba..0000000000 --- a/includes/polling/frequencies.inc.php +++ /dev/null @@ -1,51 +0,0 @@ - $sensor['sensor_limit_low'] && $freq <= $sensor['sensor_limit_low']) - { - $msg = "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $freq . "Hz (Limit " . $sensor['sensor_limit']; - $msg .= "Hz) at " . date($config['timestamp_format']); - notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); - echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); - log_event('Frequency ' . $sensor['sensor_descr'] . " under threshold: " . $freq . " Hz (< " . $sensor['sensor_limit_low'] . " Hz)", $device, 'frequency', $sensor['sensor_id']); - } - else if ($sensor['sensor_current'] < $sensor['sensor_limit'] && $freq >= $sensor['sensor_limit']) - { - $msg = "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $freq . "Hz (Limit " . $sensor['sensor_limit']; - $msg .= "Hz) at " . date($config['timestamp_format']); - notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); - echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); - log_event('Frequency ' . $sensor['sensor_descr'] . " above threshold: " . $freq . " Hz (> " . $sensor['sensor_limit'] . " Hz)", $device, 'frequency', $sensor['sensor_id']); - } - - mysql_query("UPDATE frequency SET sensor_current = '$freq' WHERE sensor_id = '" . $sensor['sensor_id'] . "'"); -} - -?> \ No newline at end of file diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php new file mode 100644 index 0000000000..f1f42ddaa9 --- /dev/null +++ b/includes/polling/functions.inc.php @@ -0,0 +1,57 @@ + $sensor['sensor_limit_low'] && $sensor_value <= $sensor['sensor_limit_low']) + { + $msg = ucfirst($class) . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is under threshold: " . $sensor_value . "$unit (< " . $sensor['sensor_limit']; + $msg .= "$unit) at " . date($config['timestamp_format']); + notify($device, ucfirst($class) . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); + echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); + log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . " under threshold: " . $sensor_value . " $unit (< " . $sensor['sensor_limit_low'] . " $unit)", $device, $class, $sensor['sensor_id']); + } + else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit']) + { + $msg = ucfirst($class) . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is over threshold: " . $sensor_value . "$unit (> " . $sensor['sensor_limit']; + $msg .= "$unit) at " . date($config['timestamp_format']); + notify($device, ucfirst($class) . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); + echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); + log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']); + } + + mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'"); + } +} + +?> diff --git a/includes/polling/humidity.inc.php b/includes/polling/humidity.inc.php deleted file mode 100644 index db33c6cb32..0000000000 --- a/includes/polling/humidity.inc.php +++ /dev/null @@ -1,50 +0,0 @@ - $sensor['sensor_limit_low'] && $hum <= $sensor['sensor_limit_low']) - { - $msg = "Humidity Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $hum . "% (Limit " . $sensor['sensor_limit']; - $msg .= "%) at " . date($config['timestamp_format']); - notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); - echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); - log_event('Frequency ' . $sensor['sensor_descr'] . " under threshold: " . $hum . " % (< " . $sensor['sensor_limit_low'] . " %)", $device, 'humidity', $sensor['sensor_id']); - } - else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $hum >= $sensor['sensor_limit']) - { - $msg = "Humidity Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $hum . "% (Limit " . $sensor['sensor_limit']; - $msg .= "%) at " . date($config['timestamp_format']); - notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); - echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); - log_event('Humidity ' . $sensor['sensor_descr'] . " above threshold: " . $hum . " % (> " . $sensor['sensor_limit'] . " %)", $device, 'humidity', $sensor['sensor_id']); - } - - mysql_query("UPDATE sensors SET sensor_current = '$hum' WHERE sensor_class='humidity' AND sensor_id = '" . $sensor['sensor_id'] . "'"); -} - -?> \ No newline at end of file diff --git a/includes/polling/temperatures.inc.php b/includes/polling/temperatures.inc.php index cf5df2015a..d085bbabc4 100755 --- a/includes/polling/temperatures.inc.php +++ b/includes/polling/temperatures.inc.php @@ -1,26 +1,30 @@ = $sensor['sensor_limit']) + if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit']) { - $msg = "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $temp . " (Limit " . $sensor['sensor_limit']; + $msg = "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . " (Limit " . $sensor['sensor_limit']; $msg .= ") at " . date($config['timestamp_format']); notify($device, "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg); echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); - log_event('Temperature ' . $sensor['sensor_descr'] . " over threshold: " . $temp . " " . html_entity_decode('°') . "C (>= " . $sensor['sensor_limit'] . " " . html_entity_decode('°') . 'C)', $device, 'temperature', $sensor['sensor_id']); + log_event('Temperature ' . $sensor['sensor_descr'] . " over threshold: " . $sensor_value . " " . html_entity_decode('°') . "$unit (>= " . $sensor['sensor_limit'] . " " . html_entity_decode('°') . "$unit)", $device, $class, $sensor['sensor_id']); } - mysql_query("UPDATE sensors SET sensor_current = '$temp' WHERE sensor_class='temperature' AND sensor_id = '" . $sensor['sensor_id'] . "'"); + mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'"); } ?> \ No newline at end of file diff --git a/includes/polling/voltages.inc.php b/includes/polling/voltages.inc.php index 59d0fc3348..61d0db889c 100755 --- a/includes/polling/voltages.inc.php +++ b/includes/polling/voltages.inc.php @@ -1,19 +1,22 @@ $sensor['sensor_limit_low'] && $volt <= $sensor['sensor_limit_low']) + if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $sensor_value <= $sensor['sensor_limit_low']) { - $msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit']; - $msg .= "V) at " . date($config['timestamp_format']); + $msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . "$unit (Limit " . $sensor['sensor_limit']; + $msg .= "$unit) at " . date($config['timestamp_format']); 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, 'voltage', $sensor['sensor_id']); + log_event('Voltage ' . $sensor['sensor_descr'] . " under threshold: " . $sensor_value . " $unit (< " . $sensor['sensor_limit_low'] . " $unit)", $device, $class, $sensor['sensor_id']); } - else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $volt >= $sensor['sensor_limit']) + else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit']) { - $msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit']; - $msg .= "V) at " . date($config['timestamp_format']); + $msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . "$unit (Limit " . $sensor['sensor_limit']; + $msg .= "$unit) at " . date($config['timestamp_format']); 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, 'voltage', $sensor['sensor_id']); + log_event('Voltage ' . $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']); } - mysql_query("UPDATE sensors SET sensor_current = '$volt' WHERE sensor_class='voltage' AND sensor_id = '" . $sensor['sensor_id'] . "'"); + mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'"); } ?> \ No newline at end of file diff --git a/poller.php b/poller.php index 7bcaf6038d..c3e79191fd 100755 --- a/poller.php +++ b/poller.php @@ -15,6 +15,7 @@ include("includes/defaults.inc.php"); include("config.php"); include("includes/functions.php"); +include("includes/polling/functions.inc.php"); $poller_start = utime(); echo("Observium Poller v".$config['version']."\n\n"); @@ -222,12 +223,7 @@ while ($device = mysql_fetch_assoc($device_query)) } } else { include("includes/polling/ipmi.inc.php"); - include("includes/polling/temperatures.inc.php"); - include("includes/polling/humidity.inc.php"); - include("includes/polling/fanspeeds.inc.php"); - include("includes/polling/voltages.inc.php"); - include("includes/polling/frequencies.inc.php"); - include("includes/polling/current.inc.php"); + include("includes/polling/sensors.inc.php"); include("includes/polling/processors.inc.php"); include("includes/polling/mempools.inc.php"); include("includes/polling/storage.inc.php");