From a914dfd482ff81853cb59a8f37f4e9d979ba2a6d Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Sun, 3 Apr 2011 19:36:32 +0000 Subject: [PATCH] remove DEVELOPING file, moved to wiki now (see Developing); minor layout fixes; remove some sql queries upon eventlog, as log_event actually prefers to receive a device array in the first place git-svn-id: http://www.observium.org/svn/observer/trunk@2011 61d68cd4-352d-0410-923a-c4978735b2b8 --- DEVELOPING | 39 --------------------- includes/discovery/functions.inc.php | 18 +++++----- includes/polling/applications/mysql.inc.php | 14 ++++---- includes/polling/bgp-peers.inc.php | 6 ++-- includes/polling/current.inc.php | 4 +-- includes/polling/fanspeeds.inc.php | 4 +-- includes/polling/frequencies.inc.php | 4 +-- includes/polling/humidity.inc.php | 4 +-- includes/polling/os/vmware.inc.php | 2 +- includes/polling/ports.inc.php | 8 ++--- includes/polling/temperatures.inc.php | 2 +- includes/polling/voltages.inc.php | 4 +-- poller.php | 20 +++++------ 13 files changed, 47 insertions(+), 82 deletions(-) delete mode 100644 DEVELOPING diff --git a/DEVELOPING b/DEVELOPING deleted file mode 100644 index 956feaad4..000000000 --- a/DEVELOPING +++ /dev/null @@ -1,39 +0,0 @@ - -Adding a new device class (os type) -=================================== - -Create a file in includes/discovery/os, which fills the OS type variable if -you can identify the device as such (sysDescr, sysObjectId or similar). Please use a -meaningful name! - -Adjust discovery.php, running specific command based on OS type, if needed. - -Create includes/polling/os/$osname.inc.php, for device specific polling. - -Add an OS text name and possibly other settings in includes/static-config.php - -If desired, create a 32x32 logo, in html/images/os/$osname.png. - -When tested and satisfied, please submit a patch to the development team! ;-) - -Adding a new Application -======================== - -The applications system is quite simple, and just involves including files based on entries in the database - -Applications are 'polled' by scripts in includes/polling/applications/.inc.php - -Applications are 'displayed' by scripts in html/pages/device/apps/.inc.php - -Graph types can be created in html/includes/graphs/.inc.php - -The application name corresponds to the app_type field in the applications database table. - -for example, apache is polled by includes/polling/applications/apache.inc.php - -This populates an rrd file with data via SNMP (but could easily parse the www output, or ssh, or anything) - -the graph types have been defined as html/includes/graphs/apache_*.inc.php - -the graphs are loaded with a bit of descriptive text by html/pages/device/apps/apache.inc.php - diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 3e9fe768f..c9dca5daf 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -17,7 +17,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, mysql_query($query); if ($debug) { echo("$query\n". mysql_affected_rows() . " inserted\n"); } echo("+"); - log_event("Sensor Added: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr), $device['device_id'], 'sensor', mysql_insert_id()); + log_event("Sensor Added: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr), $device, 'sensor', mysql_insert_id()); } else { @@ -39,7 +39,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, mysql_query($query); if ($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); } echo("H"); - log_event("Sensor High Limit Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr)." (".$high_limit.")", $device['device_id'], 'sensor', $sensor_id); + log_event("Sensor High Limit Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr)." (".$high_limit.")", $device, 'sensor', $sensor_id); } if (!$low_limit) @@ -58,7 +58,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, mysql_query($query); if ($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); } echo("L"); - log_event("Sensor Low Limit Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr)." (".$low_limit.")", $device['device_id'], 'sensor', $sensor_id); + log_event("Sensor Low Limit Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr)." (".$low_limit.")", $device, 'sensor', $sensor_id); } if ($oid == $sensor_entry['sensor_oid'] && $descr == $sensor_entry['sensor_descr'] && $multiplier == $sensor_entry['sensor_multiplier'] && $divisor == $sensor_entry['sensor_divisor']) @@ -70,7 +70,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $query = "UPDATE sensors SET `sensor_descr` = '$descr', `sensor_oid` = '$oid', `sensor_multiplier` = '$multiplier', `sensor_divisor` = '$divisor' WHERE `sensor_class` = '" . mres($class) . "' AND `device_id` = '" . $device['device_id'] . "' AND sensor_type = '$type' AND `sensor_index` = '$index'"; mysql_query($query); echo("U"); - log_event("Sensor Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr), $device['device_id'], 'sensor', $sensor_id); + log_event("Sensor Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr), $device, 'sensor', $sensor_id); if ($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); } } } @@ -148,7 +148,7 @@ function check_valid_sensors($device, $class, $valid) { echo("-"); 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); + log_event("Sensor Deleted: ".$test['sensor_class']." ".$test['sensor_type']." ". $test['sensor_index']." ".$test['sensor_descr'], $device, 'sensor', $sensor_id); } unset($oid); unset($type); } @@ -165,6 +165,7 @@ function discover_juniAtmVp(&$valid, $interface_id, $vp_id, $vp_descr) $sql = "INSERT INTO `juniAtmVp` (`interface_id`,`vp_id`,`vp_descr`) VALUES ('".$interface_id."','".$vp_id."','".$vp_descr."')"; mysql_query($sql); echo("+"); if ($debug) { echo($sql . " - " . mysql_affected_rows() . "inserted "); } + #FIXME vv no $device! log_event("Juniper ATM VP Added: port ".mres($interface_id)." vp ".mres($vp_id)." descr". mres($vp_descr), 'juniAtmVp', mysql_insert_id()); } else @@ -247,8 +248,7 @@ function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $prec mysql_query($query); if ($debug) { print $query . "\n"; } echo("+"); - log_event("Processor added: type ".mres($type)." index ".mres($index)." descr ". mres($descr), 'processor', mysql_insert_id()); - + log_event("Processor added: type ".mres($type)." index ".mres($index)." descr ". mres($descr), $device, 'processor', mysql_insert_id()); } else { @@ -277,6 +277,7 @@ function discover_mempool(&$valid, $device, $index, $type, $descr, $precision = mysql_query($query); if ($debug) { print $query . "\n"; } echo("+"); + log_event("Memory pool added: type ".mres($type)." index ".mres($index)." descr ". mres($descr), $device, 'mempool', mysql_insert_id()); } else { @@ -303,6 +304,7 @@ function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity $query .= " VALUES ('".$device['device_id']."', '$oid', '$index', '$type', '$descr', '$capacity', '$current')"; mysql_query($query); echo("+"); + log_event("Toner added: type ".mres($type)." index ".mres($index)." descr ". mres($descr), $device, 'toner', mysql_insert_id()); } else { @@ -320,4 +322,4 @@ function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity $valid[$type][$index] = 1; } -?> +?> \ No newline at end of file diff --git a/includes/polling/applications/mysql.inc.php b/includes/polling/applications/mysql.inc.php index c2c28f616..bc8999077 100644 --- a/includes/polling/applications/mysql.inc.php +++ b/includes/polling/applications/mysql.inc.php @@ -14,16 +14,17 @@ $data = explode("\n", $mysql); for ($a=0,$n=count($data);$a<$n;$a++) { - $elements = explode(":",$data[$a]); - $nstring .= (float)trim($elements[1]).":"; - unset($elements); + $elements = explode(":",$data[$a]); + $nstring .= (float)trim($elements[1]).":"; + unset($elements); } #$data = explode("\n", $mysql); #$nstring = trim(implode(':',$data),':'); -if (!is_file($mysql_rrd)) { - rrdtool_create ($mysql_rrd, "--step 300 \ +if (!is_file($mysql_rrd)) +{ + rrdtool_create ($mysql_rrd, "--step 300 \ DS:IDBLBSe:GAUGE:600:0:125000000000 \ DS:IBLFh:DERIVE:600:0:125000000000 \ DS:IBLWn:DERIVE:600:0:125000000000 \ @@ -119,4 +120,5 @@ if (!is_file($mysql_rrd)) { rrdtool_update($mysql_rrd, "N:$nstring"); echo("done "); -?> + +?> \ No newline at end of file diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index e2eb659d3..922c29541 100755 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -87,17 +87,17 @@ else if ($peer['bgpPeerState'] == $bgpPeerState) { notify($device, "BGP Session flapped: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session flapped " . formatUptime($bgpPeerFsmEstablishedTime) . " ago.\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')'); - log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id); + log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device, 'bgpPeer', $bgpPeer_id); } else if ($bgpPeerState == "established") { notify($device, "BGP Session up: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session up since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')'); - log_event('BGP Session Up: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id); + log_event('BGP Session Up: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device, 'bgpPeer', $bgpPeer_id); } else if ($peer['bgpPeerState'] == "established") { notify($device, "BGP Session down: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session down since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')'); - log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id); + log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device, 'bgpPeer', $bgpPeer_id); } } } diff --git a/includes/polling/current.inc.php b/includes/polling/current.inc.php index 6f17725ab..781a64f41 100644 --- a/includes/polling/current.inc.php +++ b/includes/polling/current.inc.php @@ -34,7 +34,7 @@ while ($dbcurrent = mysql_fetch_array($current_data)) $msg .= "A) at " . date($config['timestamp_format']); notify($device, "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'], $msg); echo("Alerting for " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . "\n"); - log_event('Current ' . $dbcurrent['sensor_descr'] . " under threshold: " . $current . " A (< " . $dbcurrent['sensor_limit_low'] . " A)", $device['device_id'], 'current', $current['sensor_id']); + log_event('Current ' . $dbcurrent['sensor_descr'] . " under threshold: " . $current . " A (< " . $dbcurrent['sensor_limit_low'] . " A)", $device, 'current', $current['sensor_id']); } else if ($dbcurrent['sensor_current'] < $dbcurrent['sensor_limit'] && $current >= $dbcurrent['sensor_limit']) { @@ -42,7 +42,7 @@ while ($dbcurrent = mysql_fetch_array($current_data)) $msg .= "A) at " . date($config['timestamp_format']); notify($device, "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'], $msg); echo("Alerting for " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . "\n"); - log_event('Current ' . $dbcurrent['sensor_descr'] . " above threshold: " . $current . " A (> " . $dbcurrent['sensor_limit'] . " A)", $device['device_id'], 'current', $current['sensor_id']); + log_event('Current ' . $dbcurrent['sensor_descr'] . " above threshold: " . $current . " A (> " . $dbcurrent['sensor_limit'] . " A)", $device, 'current', $current['sensor_id']); } mysql_query("UPDATE sensors SET sensor_current = '$current' WHERE sensor_class='current' AND sensor_id = '" . $dbcurrent['sensor_id'] . "'"); diff --git a/includes/polling/fanspeeds.inc.php b/includes/polling/fanspeeds.inc.php index fbc79521d..62e00bfaa 100755 --- a/includes/polling/fanspeeds.inc.php +++ b/includes/polling/fanspeeds.inc.php @@ -37,7 +37,7 @@ while ($fanspeed = mysql_fetch_array($fan_data)) $msg .= "rpm) at " . date($config['timestamp_format']); notify($device, "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['sensor_descr'], $msg); echo("Alerting for " . $device['hostname'] . " " . $fanspeed['sensor_descr'] . "\n"); - log_event('Fan speed ' . $fanspeed['sensor_descr'] . " under threshold: " . $fanspeed['sensor_current'] . " rpm (<= " . $fanspeed['sensor_limit_low'] . " rpm)", $device['device_id'], 'fanspeed', $fanspeed['sensor_id']); + log_event('Fan speed ' . $fanspeed['sensor_descr'] . " under threshold: " . $fanspeed['sensor_current'] . " rpm (<= " . $fanspeed['sensor_limit_low'] . " rpm)", $device, 'fanspeed', $fanspeed['sensor_id']); } else if ($fanspeed['sensor_limit_low_warn'] && $fanspeed['sensor_current'] > $fanspeed['sensor_limit_warn'] && $fan <= $fanspeed['sensor_limit_low_warn']) { @@ -45,7 +45,7 @@ while ($fanspeed = mysql_fetch_array($fan_data)) $msg .= "rpm) at " . date($config['timestamp_format']); notify($device, "Fan Warning: " . $device['hostname'] . " " . $fanspeed['sensor_descr'], $msg); echo("Alerting for " . $device['hostname'] . " " . $fanspeed['sensor_descr'] . "\n"); - log_event('Fan speed ' . $fanspeed['sensor_descr'] . " under warning threshold: " . $fanspeed['sensor_current'] . " rpm (<= " . $fanspeed['sensor_limit_low_warn'] . " rpm)", $device['device_id'], 'fanspeed', $fanspeed['sensor_id']); + log_event('Fan speed ' . $fanspeed['sensor_descr'] . " under warning threshold: " . $fanspeed['sensor_current'] . " rpm (<= " . $fanspeed['sensor_limit_low_warn'] . " rpm)", $device, 'fanspeed', $fanspeed['sensor_id']); } mysql_query("UPDATE sensors SET sensor_current = '$fan' WHERE sensor_class='fanspeed' AND sensor_id = '" . $fanspeed['sensor_id'] . "'"); diff --git a/includes/polling/frequencies.inc.php b/includes/polling/frequencies.inc.php index 14f58862d..d706c0f36 100644 --- a/includes/polling/frequencies.inc.php +++ b/includes/polling/frequencies.inc.php @@ -34,7 +34,7 @@ while ($sensor = mysql_fetch_array($sensor_data)) $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['device_id'] , 'frequency', $sensor['sensor_id']); + 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']) { @@ -42,7 +42,7 @@ while ($sensor = mysql_fetch_array($sensor_data)) $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['device_id'], 'frequency', $sensor['sensor_id']); + 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'] . "'"); diff --git a/includes/polling/humidity.inc.php b/includes/polling/humidity.inc.php index a67c751e7..fc10315f6 100644 --- a/includes/polling/humidity.inc.php +++ b/includes/polling/humidity.inc.php @@ -33,7 +33,7 @@ while ($humidity = mysql_fetch_array($hum_data)) $msg .= "%) at " . date($config['timestamp_format']); notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'], $msg); echo("Alerting for " . $device['hostname'] . " " . $humidity['sensor_descr'] . "\n"); - log_event('Frequency ' . $humidity['sensor_descr'] . " under threshold: " . $hum . " % (< " . $humidity['sensor_limit_low'] . " %)", $device['device_id'] , 'humidity', $humidity['sensor_id']); + log_event('Frequency ' . $humidity['sensor_descr'] . " under threshold: " . $hum . " % (< " . $humidity['sensor_limit_low'] . " %)", $device, 'humidity', $humidity['sensor_id']); } else if ($humidity['sensor_current'] < $humidity['sensor_limit'] && $hum >= $humidity['sensor_limit']) { @@ -41,7 +41,7 @@ while ($humidity = mysql_fetch_array($hum_data)) $msg .= "%) at " . date($config['timestamp_format']); notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'], $msg); echo("Alerting for " . $device['hostname'] . " " . $humidity['sensor_descr'] . "\n"); - log_event('Humidity ' . $humidity['sensor_descr'] . " above threshold: " . $hum . " % (> " . $humidity['sensor_limit'] . " %)", $device['device_id'], 'humidity', $humidity['sensor_id']); + log_event('Humidity ' . $humidity['sensor_descr'] . " above threshold: " . $hum . " % (> " . $humidity['sensor_limit'] . " %)", $device, 'humidity', $humidity['sensor_id']); } mysql_query("UPDATE sensors SET sensor_current = '$hum' WHERE sensor_class='humidity' AND sensor_id = '" . $humidity['sensor_id'] . "'"); diff --git a/includes/polling/os/vmware.inc.php b/includes/polling/os/vmware.inc.php index a83cb4d5e..a2107c82c 100644 --- a/includes/polling/os/vmware.inc.php +++ b/includes/polling/os/vmware.inc.php @@ -85,7 +85,7 @@ while ($db_info = mysql_fetch_array($db_info_list)) if ($vm_info[$property] != $db_info[$property]) { mysql_query("UPDATE vmware_vminfo SET " . $property ." = '" . mres($vm_info[$property]) ."' WHERE id = '" . $db_info["id"] . "'"); - log_event($db_info["vmwVmDisplayName"] . " (" . preg_replace("/^vmwVm/", "", $property) . ") -> " . $vm_info[$property], $device['device_id']); + log_event($db_info["vmwVmDisplayName"] . " (" . preg_replace("/^vmwVm/", "", $property) . ") -> " . $vm_info[$property], $device); } } } diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index a2fd5caad..21831295b 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -152,11 +152,11 @@ while ($port = mysql_fetch_array($port_query)) if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid])) { $update .= ", `$oid` = NULL"; - log_event($oid . ": ".$port[$oid]." -> NULL", $device['device_id'], 'interface', $port['interface_id']); + log_event($oid . ": ".$port[$oid]." -> NULL", $device, 'interface', $port['interface_id']); if ($debug) { echo($oid . ": ".$port[$oid]." -> NULL "); } else { echo($oid . " "); } } elseif ($port[$oid] != $this_port[$oid]) { $update .= ", `$oid` = '".mres($this_port[$oid])."'"; - log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device['device_id'], 'interface', $port['interface_id']); + log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device, 'interface', $port['interface_id']); if ($debug) { echo($oid . ": ".$port[$oid]." -> " . $this_port[$oid]." "); } else { echo($oid . " "); } } } @@ -174,7 +174,7 @@ while ($port = mysql_fetch_array($port_query)) if ($port_ifAlias[$attrib] != $port[$attrib_key]) { $update .= ", `".$attrib_key."` = '".$port_ifAlias[$attrib]."'"; - log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device['device_id'], 'interface', $port['interface_id']); + log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device, 'interface', $port['interface_id']); } } } @@ -255,7 +255,7 @@ while ($port = mysql_fetch_array($port_query)) { // If data has changed, build a query $update .= ", `$oid` = '".mres($this_port[$oid])."'"; echo("PAgP "); - log_event("$oid -> ".$this_port[$oid], $device['device_id'], 'interface', $port['interface_id']); + log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['interface_id']); } } } diff --git a/includes/polling/temperatures.inc.php b/includes/polling/temperatures.inc.php index 089f73218..919933581 100755 --- a/includes/polling/temperatures.inc.php +++ b/includes/polling/temperatures.inc.php @@ -52,7 +52,7 @@ while ($temperature = mysql_fetch_array($temp_data)) $msg .= ") at " . date($config['timestamp_format']); notify($device, "Temp Alarm: " . $device['hostname'] . " " . $temperature['sensor_descr'], $msg); echo("Alerting for " . $device['hostname'] . " " . $temperature['sensor_descr'] . "\n"); - log_event('Temperature ' . $temperature['sensor_descr'] . " over threshold: " . $temp . " " . html_entity_decode('°') . "C (>= " . $temperature['sensor_limit'] . " " . html_entity_decode('°') . 'C)', $device['device_id'], 'temperature', $temperature['sensor_id']); + log_event('Temperature ' . $temperature['sensor_descr'] . " over threshold: " . $temp . " " . html_entity_decode('°') . "C (>= " . $temperature['sensor_limit'] . " " . html_entity_decode('°') . 'C)', $device, 'temperature', $temperature['sensor_id']); } mysql_query("UPDATE sensors SET sensor_current = '$temp' WHERE sensor_class='temperature' AND sensor_id = '" . $temperature['sensor_id'] . "'"); diff --git a/includes/polling/voltages.inc.php b/includes/polling/voltages.inc.php index 81f719528..5f775d650 100755 --- a/includes/polling/voltages.inc.php +++ b/includes/polling/voltages.inc.php @@ -37,7 +37,7 @@ while ($sensor = mysql_fetch_array($volt_data)) $msg .= "V) 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['device_id'], 'voltage', $sensor['sensor_id']); + log_event('Voltage ' . $sensor['sensor_descr'] . " under threshold: " . $volt . " V (< " . $sensor['sensor_limit_low'] . " V)", $device, 'voltage', $sensor['sensor_id']); } else if ($sensor['sensor_current'] < $sensor['sensor_limit'] && $volt >= $sensor['sensor_limit']) { @@ -45,7 +45,7 @@ while ($sensor = mysql_fetch_array($volt_data)) $msg .= "V) 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['device_id'], 'voltage', $sensor['sensor_id']); + log_event('Voltage ' . $sensor['sensor_descr'] . " above threshold: " . $volt . " V (> " . $sensor['sensor_limit'] . " V)", $device, 'voltage', $sensor['sensor_id']); } mysql_query("UPDATE sensors SET sensor_current = '$volt' WHERE sensor_class='voltage' AND sensor_id = '" . $sensor['sensor_id'] . "'"); } diff --git a/poller.php b/poller.php index 6bedc2825..fe8f81e68 100755 --- a/poller.php +++ b/poller.php @@ -121,7 +121,7 @@ while ($device = mysql_fetch_assoc($device_query)) $poll_separator = ", "; mysql_query("UPDATE `devices` SET `status` = '".$status."' WHERE `device_id` = '".$device['device_id']."'"); mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is " .($status == '1' ? 'up' : 'down') . "')"); - log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device['device_id'], ($status == '1' ? 'up' : 'down')); + log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device, ($status == '1' ? 'up' : 'down')); notify($device, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " at " . date($config['timestamp_format'])); } @@ -173,7 +173,7 @@ while ($device = mysql_fetch_assoc($device_query)) if ($uptime < $device['uptime']) { notify($device,"Device rebooted: " . $device['hostname'], "Device Rebooted : " . $device['hostname'] . " " . formatUptime($uptime) . " ago."); - log_event('Device rebooted after '.formatUptime($device['uptime']), $device['device_id'], 'reboot', $device['uptime']); + log_event('Device rebooted after '.formatUptime($device['uptime']), $device, 'reboot', $device['uptime']); } $uptimerrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd"; @@ -246,28 +246,28 @@ while ($device = mysql_fetch_assoc($device_query)) { $poll_update .= $poll_separator . "`serial` = '".mres($serial)."'"; $poll_separator = ", "; - log_event("Serial -> $serial", $device['device_id'], 'system'); + log_event("Serial -> $serial", $device, 'system'); } if ($sysContact && $sysContact != $device['sysContact']) { $poll_update .= $poll_separator . "`sysContact` = '".mres($sysContact)."'"; $poll_separator = ", "; - log_event("Contact -> $sysContact", $device['device_id'], 'system'); + log_event("Contact -> $sysContact", $device, 'system'); } if ($sysName && $sysName != $device['sysName']) { $poll_update .= $poll_separator . "`sysName` = '$sysName'"; $poll_separator = ", "; - log_event("sysName -> $sysName", $device['device_id'], 'system'); + log_event("sysName -> $sysName", $device, 'system'); } if ($sysDescr && $sysDescr != $device['sysDescr']) { $poll_update .= $poll_separator . "`sysDescr` = '$sysDescr'"; $poll_separator = ", "; - log_event("sysDescr -> $sysDescr", $device['device_id'], 'system'); + log_event("sysDescr -> $sysDescr", $device, 'system'); } if ($sysLocation && $device['location'] != $sysLocation) @@ -277,28 +277,28 @@ while ($device = mysql_fetch_assoc($device_query)) $poll_update .= $poll_separator . "`location` = '$sysLocation'"; $poll_separator = ", "; } - log_event("Location -> $sysLocation", $device['device_id'], 'system'); + log_event("Location -> $sysLocation", $device, 'system'); } if ($version && $device['version'] != $version) { $poll_update .= $poll_separator . "`version` = '$version'"; $poll_separator = ", "; - log_event("OS Version -> $version", $device['device_id'], 'system'); + log_event("OS Version -> $version", $device, 'system'); } if ($features != $device['features']) { $poll_update .= $poll_separator . "`features` = '$features'"; $poll_separator = ", "; - log_event("OS Features -> $features", $device['device_id'], 'system'); + log_event("OS Features -> $features", $device, 'system'); } if ($hardware && $hardware != $device['hardware']) { $poll_update .= $poll_separator . "`hardware` = '$hardware'"; $poll_separator = ", "; - log_event("Hardware -> $hardware", $device['device_id'], 'system'); + log_event("Hardware -> $hardware", $device, 'system'); } $poll_update .= $poll_separator . "`last_polled` = NOW()";