allow disabling of alerting per device, allow override of syscontact, minor cleanups

git-svn-id: http://www.observium.org/svn/observer/trunk@1995 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-30 16:28:24 +00:00
parent d302d1a4ce
commit 9fd77cd884
17 changed files with 126 additions and 63 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ if ($os != $device['os'])
{
$sql = mysql_query("UPDATE `devices` SET `os` = '$os' WHERE `device_id` = '".$device['device_id']."'");
echo("Changed OS! : $os\n");
eventlog("Device OS changed ".$device['os']." => $os", $device['device_id']);
log_event("Device OS changed ".$device['os']." => $os", $device, 'system');
$device['os'] = $os;
}
+16 -14
View File
@@ -33,11 +33,11 @@ foreach (explode("\n", $ports) as $entry)
{
foreach ($config['bad_if_regexp'] as $bi)
{
if (preg_match($bi ."i", $if))
{
$nullintf = 1;
if (preg_match($bi ."i", $if))
{
$nullintf = 1;
if($debug) { echo("ignored : $bi : $if"); }
}
}
}
}
@@ -48,23 +48,25 @@ foreach (explode("\n", $ports) as $entry)
if ($debug) echo("\n $if ");
if ($nullintf == 0)
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') {
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','".mres($ifDescr)."')");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0')
{
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','".mres($ifDescr)."')");
# Add Interface
echo("+");
echo("+");
} else {
mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
echo(".");
mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
echo(".");
}
$int_exists[] = "$ifIndex";
} else {
# Ignored Interface
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0') {
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0')
{
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
# Delete Interface
echo("-"); ## Deleted Interface
echo("-"); ## Deleted Interface
} else {
echo("X"); ## Ignored Interface
echo("X"); ## Ignored Interface
}
}
}
@@ -93,4 +95,4 @@ while ($test_if = mysql_fetch_array($query))
unset($temp_exists);
echo("\n");
?>
?>
+20 -13
View File
@@ -222,7 +222,7 @@ function renamehost($id, $new, $source = 'console')
rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new");
mysql_query("UPDATE devices SET hostname = '$new' WHERE device_id = '$id'");
eventlog("Hostname changed -> $new ($source)", $id);
log_event("Hostname changed -> $new ($source)", $id, 'system');
}
function delete_port($int_id)
@@ -650,7 +650,7 @@ function get_astext($asn)
}
}
# DEPRECATED
# FIXME DEPRECATED -- only used in dead file includes/polling/interfaces.inc.php - if we no longer need that one, this can go too.
function eventlog($eventtext,$device_id = "", $interface_id = "")
{
$event_query = "INSERT INTO eventlog (host, interface, datetime, message) VALUES (" . ($device_id ? $device_id : "NULL");
@@ -677,20 +677,27 @@ function notify($device,$title,$message)
if ($config['alerts']['email']['enable'])
{
if ($config['alerts']['email']['default_only'])
if (!get_dev_attrib($device,'disable_notify'))
{
$email = $config['alerts']['email']['default'];
} else {
if ($device['sysContact'])
if ($config['alerts']['email']['default_only'])
{
$email = $device['sysContact'];
} else {
$email = $config['alerts']['email']['default'];
} else {
if (get_dev_attrib($device,'override_sysContact_bool'))
{
$email = get_dev_attrib($device,'override_sysContact_string');
}
elseif ($device['sysContact'])
{
$email = $device['sysContact'];
} else {
$email = $config['alerts']['email']['default'];
}
}
if ($email)
{
mail($email, $title, $message, $config['email_headers']);
}
}
if ($email)
{
mail($email, $title, $message, $config['email_headers']);
}
}
}
@@ -780,4 +787,4 @@ function include_dir($dir, $regex = "")
}
}
?>
?>
+5 -8
View File
@@ -17,10 +17,10 @@ if ($device['os'] == "linux")
$features = str_replace("\"", "", $features);
if (!$features) // No "extend" support, try "exec" support
{
$features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB");
$features = str_replace("\"", "", $features);
}
{
$features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB");
$features = str_replace("\"", "", $features);
}
// Detect Dell hardware via OpenManage SNMP
$hw = snmp_get($device, ".1.3.6.1.4.1.674.10892.1.300.10.1.9.1", "-Oqv", "MIB-Dell-10892");
@@ -63,12 +63,9 @@ elseif ($device['os'] == "monowall" || $device['os'] == "Voswall")
}
elseif ($device['os'] == "qnap")
{
$hardware = snmp_get($device, "ENTITY-MIB::entPhysicalName.1", "-Osqnv");
$version = snmp_get($device, "ENTITY-MIB::entPhysicalFirmwareRev.1", "-Osqnv");
$serial = snmp_get($device, "ENTITY-MIB::entPhysicalSerial.1", "-Osqnv");
}
?>
?>
+1 -3
View File
@@ -46,8 +46,6 @@ if ($config['enable_ports_adsl'])
$device['adsl_count'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifType` = 'adsl'"),0);
}
if ($device['adsl_count'] > "0")
{
echo("ADSL ");
@@ -321,4 +319,4 @@ while ($port = mysql_fetch_array($port_query))
#### Clear Variables Here
unset($port_stats);
?>
?>
+1 -2
View File
@@ -950,8 +950,6 @@ function array_preg_replace($array, $string)
return $string;
}
function rewrite_adslLineType($adslLineType)
{
$adslLineTypes = array ('noChannel' => 'No Channel',
@@ -967,6 +965,7 @@ function rewrite_adslLineType($adslLineType)
$adslLineType = $text;
}
}
return($adslLineType);
}