mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
- Send email alerts on interface flaps when $config['warn']['ifdown'] is true.
- Added the setting timestamp_format: Description: The timestamp format to use in logs or emails. Default: d-m-Y H:i:s - Modified timestamp dates. git-svn-id: http://www.observium.org/svn/observer/trunk@952 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -23,11 +23,11 @@ while ($service = mysql_fetch_array($query)) {
|
|||||||
if($service['sysContact']) { $email = $service['sysContact']; } else { $email = $config['email_default']; }
|
if($service['sysContact']) { $email = $service['sysContact']; } else { $email = $config['email_default']; }
|
||||||
if($status == "1") {
|
if($status == "1") {
|
||||||
$msg = "Service Up: " . $service['service_type'] . " on " . $service['hostname'];
|
$msg = "Service Up: " . $service['service_type'] . " on " . $service['hostname'];
|
||||||
$msg .= " at " . date('l dS F Y h:i:s A');
|
$msg .= " at " . date($config['timestamp_format']);
|
||||||
mail($email, "Service Up: " . $service['service_type'] . " on " . $service['hostname'], $msg, $config['email_headers']);
|
mail($email, "Service Up: " . $service['service_type'] . " on " . $service['hostname'], $msg, $config['email_headers']);
|
||||||
} elseif ($status == "0") {
|
} elseif ($status == "0") {
|
||||||
$msg = "Service Down: " . $service['service_type'] . " on " . $service['hostname'];
|
$msg = "Service Down: " . $service['service_type'] . " on " . $service['hostname'];
|
||||||
$msg .= " at " . date('l dS F Y h:i:s A');
|
$msg .= " at " . date($config['timestamp_format']);
|
||||||
mail($email, "Service Down: " . $service['service_type'] . " on " . $service['hostname'], $msg, $config['email_headers']);
|
mail($email, "Service Down: " . $service['service_type'] . " on " . $service['hostname'], $msg, $config['email_headers']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,15 +17,16 @@ $config['nagios_plugins'] = "/usr/lib/nagios/plugins";
|
|||||||
|
|
||||||
### Local Specifics
|
### Local Specifics
|
||||||
|
|
||||||
$config['title_image'] = "images/observer-logo.gif";
|
$config['title_image'] = "images/observer-logo.gif";
|
||||||
$config['stylesheet'] = "css/styles.css";
|
$config['stylesheet'] = "css/styles.css";
|
||||||
$config['mono_font'] = "DejaVuSansMono";
|
$config['mono_font'] = "DejaVuSansMono";
|
||||||
$config['favicon'] = "favicon.ico";
|
$config['favicon'] = "favicon.ico";
|
||||||
$config['header_color'] = "#1F334E";
|
$config['header_color'] = "#1F334E";
|
||||||
$config['page_refresh'] = "30"; ## Refresh the page every xx seconds
|
$config['page_refresh'] = "30"; ## Refresh the page every xx seconds
|
||||||
$config['frong_page'] = "default.php";
|
$config['frong_page'] = "default.php";
|
||||||
$config['page_title'] = "ObserverNMS";
|
$config['page_title'] = "ObserverNMS";
|
||||||
$config['syslog_age'] = "1 month";
|
$config['syslog_age'] = "1 month";
|
||||||
|
$config['timestamp_format'] = 'd-m-Y H:i:s';
|
||||||
|
|
||||||
### Cosmetics
|
### Cosmetics
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ while($fanspeed = mysql_fetch_array($fan_data)) {
|
|||||||
if($fanspeed['fan_current'] > $fanspeed['fan_limit'] && $fan <= $fanspeed['fan_limit']) {
|
if($fanspeed['fan_current'] > $fanspeed['fan_limit'] && $fan <= $fanspeed['fan_limit']) {
|
||||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||||
$msg = "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['fan_descr'] . " is " . $fan . "rpm (Limit " . $fanspeed['fan_limit'];
|
$msg = "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['fan_descr'] . " is " . $fan . "rpm (Limit " . $fanspeed['fan_limit'];
|
||||||
$msg .= "rpm) at " . date('l dS F Y h:i:s A');
|
$msg .= "rpm) at " . date($config['timestamp_format']);
|
||||||
mail($email, "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['fan_descr'], $msg, $config['email_headers']);
|
mail($email, "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['fan_descr'], $msg, $config['email_headers']);
|
||||||
echo("Alerting for " . $device['hostname'] . " " . $fanspeed['fan_descr'] . "\n");
|
echo("Alerting for " . $device['hostname'] . " " . $fanspeed['fan_descr'] . "\n");
|
||||||
eventlog('Fan speed ' . $fanspeed['fan_descr'] . " under threshold: " . $fanspeed['fan_current'] . " rpm (> " . $fanspeed['fan_limit'] . " rpm)", $device['device_id']);
|
eventlog('Fan speed ' . $fanspeed['fan_descr'] . " under threshold: " . $fanspeed['fan_current'] . " rpm (> " . $fanspeed['fan_limit'] . " rpm)", $device['device_id']);
|
||||||
|
@@ -38,7 +38,7 @@ while ($dr = mysql_fetch_array($dq)) {
|
|||||||
if (!is_numeric($dr['storage_perc_warn'])) { $dr['storage_perc_warn'] = 60; }
|
if (!is_numeric($dr['storage_perc_warn'])) { $dr['storage_perc_warn'] = 60; }
|
||||||
if($dr['storage_perc'] < $dr['storage_perc_warn'] && $perc >= $dr['storage_perc_warn'])
|
if($dr['storage_perc'] < $dr['storage_perc_warn'] && $perc >= $dr['storage_perc_warn'])
|
||||||
{
|
{
|
||||||
$msg = "Disk Alarm: " . $device['hostname'] . " " . $dr['storage_descr'] . " is " . $perc . "% at " . date('l dS F Y h:i:s A');
|
$msg = "Disk Alarm: " . $device['hostname'] . " " . $dr['storage_descr'] . " is " . $perc . "% at " . date($config['timestamp_format']);
|
||||||
notify($device, "Disk Alarm: " . $device['hostname'] . " " . $dr['storage_descr'], $msg);
|
notify($device, "Disk Alarm: " . $device['hostname'] . " " . $dr['storage_descr'], $msg);
|
||||||
echo("Alerting for " . $device['hostname'] . " " . $dr['storage_descr'] . "\n");
|
echo("Alerting for " . $device['hostname'] . " " . $dr['storage_descr'] . "\n");
|
||||||
}
|
}
|
||||||
|
@@ -162,6 +162,20 @@
|
|||||||
// End Update MySQL
|
// End Update MySQL
|
||||||
|
|
||||||
unset($update_query); unset($update);
|
unset($update_query); unset($update);
|
||||||
|
|
||||||
|
// Send alerts for interface flaps.
|
||||||
|
if ($config['warn']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus'])) {
|
||||||
|
if ($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||||
|
if ($this_port['ifAlias']) { $falias = preg_replace('/^"/', '', $this_port['ifAlias']); $falias = preg_replace('/"$/', '', $falias); $full = $this_port['ifDescr'] . " (" . $falias . ")"; } else { $full = $this_port['ifDescr']; }
|
||||||
|
switch ($this_port['ifOperStatus']) {
|
||||||
|
case "up":
|
||||||
|
mail($email, "Interface UP - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']), $config['email_headers']);
|
||||||
|
break;
|
||||||
|
case "down":
|
||||||
|
mail($email, "Interface DOWN - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']), $config['email_headers']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
echo("Port Deleted?"); // Port missing from SNMP cache?
|
echo("Port Deleted?"); // Port missing from SNMP cache?
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ while($temperature = mysql_fetch_array($temp_data)) {
|
|||||||
if($temperature['temp_current'] < $temperature['temp_limit'] && $temp >= $temperature['temp_limit']) {
|
if($temperature['temp_current'] < $temperature['temp_limit'] && $temp >= $temperature['temp_limit']) {
|
||||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||||
$msg = "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'] . " is " . $temp . " (Limit " . $temperature['temp_limit'];
|
$msg = "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'] . " is " . $temp . " (Limit " . $temperature['temp_limit'];
|
||||||
$msg .= ") at " . date('l dS F Y h:i:s A');
|
$msg .= ") at " . date($config['timestamp_format']);
|
||||||
mail($email, "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'], $msg, $config['email_headers']);
|
mail($email, "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'], $msg, $config['email_headers']);
|
||||||
echo("Alerting for " . $device['hostname'] . " " . $temperature['temp_descr'] . "\n");
|
echo("Alerting for " . $device['hostname'] . " " . $temperature['temp_descr'] . "\n");
|
||||||
eventlog('Temperature ' . $temperature['temp_descr'] . " over threshold: " . $temperature['temp_current'] . " °C (> " . $temperature['temp_limit'] . " °C)", $device['device_id']);
|
eventlog('Temperature ' . $temperature['temp_descr'] . " over threshold: " . $temperature['temp_current'] . " °C (> " . $temperature['temp_limit'] . " °C)", $device['device_id']);
|
||||||
|
@@ -34,7 +34,7 @@ while($voltage = mysql_fetch_array($volt_data)) {
|
|||||||
{
|
{
|
||||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||||
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'] . " is " . $volt . "V (Limit " . $voltage['volt_limit'];
|
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'] . " is " . $volt . "V (Limit " . $voltage['volt_limit'];
|
||||||
$msg .= "V) at " . date('l dS F Y h:i:s A');
|
$msg .= "V) at " . date($config['timestamp_format']);
|
||||||
mail($email, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'], $msg, $config['email_headers']);
|
mail($email, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'], $msg, $config['email_headers']);
|
||||||
echo("Alerting for " . $device['hostname'] . " " . $voltage['volt_descr'] . "\n");
|
echo("Alerting for " . $device['hostname'] . " " . $voltage['volt_descr'] . "\n");
|
||||||
eventlog('Voltage ' . $voltage['volt_descr'] . " under threshold: " . $voltage['volt_current'] . " V (> " . $voltage['volt_limit'] . " V)", $device['device_id']);
|
eventlog('Voltage ' . $voltage['volt_descr'] . " under threshold: " . $voltage['volt_current'] . " V (> " . $voltage['volt_limit'] . " V)", $device['device_id']);
|
||||||
@@ -43,7 +43,7 @@ while($voltage = mysql_fetch_array($volt_data)) {
|
|||||||
{
|
{
|
||||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||||
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'] . " is " . $volt . "V (Limit " . $voltage['volt_limit'];
|
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'] . " is " . $volt . "V (Limit " . $voltage['volt_limit'];
|
||||||
$msg .= "V) at " . date('l dS F Y h:i:s A');
|
$msg .= "V) at " . date($config['timestamp_format']);
|
||||||
mail($email, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'], $msg, $config['email_headers']);
|
mail($email, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'], $msg, $config['email_headers']);
|
||||||
echo("Alerting for " . $device['hostname'] . " " . $voltage['volt_descr'] . "\n");
|
echo("Alerting for " . $device['hostname'] . " " . $voltage['volt_descr'] . "\n");
|
||||||
eventlog('Voltage ' . $voltage['volt_descr'] . " above threshold: " . $voltage['volt_current'] . " V (> " . $voltage['volt_limit'] . " V)", $device['device_id']);
|
eventlog('Voltage ' . $voltage['volt_descr'] . " above threshold: " . $voltage['volt_current'] . " V (> " . $voltage['volt_limit'] . " V)", $device['device_id']);
|
||||||
|
@@ -45,11 +45,11 @@ while ($device = mysql_fetch_array($device_query)) {
|
|||||||
if ($status == '1') {
|
if ($status == '1') {
|
||||||
$stat = "Up";
|
$stat = "Up";
|
||||||
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is up\n')");
|
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is up\n')");
|
||||||
mail($email, "DeviceUp: " . $device['hostname'], "Device Up: " . $device['hostname'] . " at " . date('l dS F Y h:i:s A'), $config['email_headers']);
|
mail($email, "DeviceUp: " . $device['hostname'], "Device Up: " . $device['hostname'] . " at " . date($config['timestamp_format']), $config['email_headers']);
|
||||||
} else {
|
} else {
|
||||||
$stat = "Down";
|
$stat = "Down";
|
||||||
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('9', '" . $device['device_id'] . "', 'Device is down\n')");
|
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('9', '" . $device['device_id'] . "', 'Device is down\n')");
|
||||||
mail($email, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname'] . " at " . date('l dS F Y h:i:s A'), $config['email_headers']);
|
mail($email, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname'] . " at " . date($config['timestamp_format']), $config['email_headers']);
|
||||||
}
|
}
|
||||||
eventlog("Device status changed to $stat", $device['device_id']);
|
eventlog("Device status changed to $stat", $device['device_id']);
|
||||||
echo("Status Changed!\n");
|
echo("Status Changed!\n");
|
||||||
|
Reference in New Issue
Block a user