mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
adding SNMP trap handling capability (yes it is horrible horrible right now!)
git-svn-id: http://www.observium.org/svn/observer/trunk@880 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -817,6 +817,14 @@ function eventlog($eventtext,$device_id = "", $interface_id = "")
|
||||
mysql_query($event_query);
|
||||
}
|
||||
|
||||
function log_event($text, $device = NULL, $type = NULL, $reference = NULL) {
|
||||
$event_query = "INSERT INTO eventlog (host, reference, type, datetime, message) VALUES (" . ($device['device_id'] ? $device['device_id'] : "NULL");
|
||||
$event_query .= ", " . ($reference ? $reference : "NULL") . ", " . ($type ? $type : "NULL") . ", NOW(), '" . mres($text) . "')";
|
||||
echo($event_query . "\n");
|
||||
mysql_query($event_query);
|
||||
}
|
||||
|
||||
|
||||
function notify($device,$title,$message)
|
||||
{
|
||||
global $config;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `interfaces` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$entry[2]."'"));
|
||||
|
||||
if(!$interface) {exit;}
|
||||
|
||||
$ifOperStatus = "down";
|
||||
#$ifAdminStatus = "down";
|
||||
|
||||
log_event("SNMP Trap: linkDown " . $interface['ifDescr'], $device, "interface", $interface['interface_id']);
|
||||
|
||||
#if($ifAdminStatus != $interface['ifAdminStatus']) {
|
||||
# log_event("Interface Disabled : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']);
|
||||
#}
|
||||
if($ifOperStatus != $interface['ifOperStatus']) {
|
||||
log_event("Interface went Down : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']);
|
||||
mysql_query("UPDATE `interfaces` SET ifOperStatus = 'down' WHERE `interface_id` = '".$interface['interface_id']."'");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `interfaces` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$entry[2]."'"));
|
||||
|
||||
if(!$interface) {exit;}
|
||||
|
||||
$ifOperStatus = "up";
|
||||
$ifAdminStatus = "up";
|
||||
|
||||
log_event("SNMP Trap: linkUp $ifAdminStatus/$ifOperStatus " . $interface['ifDescr'], $device, "interface", $interface['interface_id']);
|
||||
|
||||
if($ifAdminStatus != $interface['ifAdminStatus']) {
|
||||
log_event("Interface Enabled : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']);
|
||||
mysql_query("UPDATE `interfaces` SET ifAdminStatus = 'up' WHERE `interface_id` = '".$interface['interface_id']."'");
|
||||
}
|
||||
if($ifOperStatus != $interface['ifOperStatus']) {
|
||||
log_event("Interface went Up : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']);
|
||||
mysql_query("UPDATE `interfaces` SET ifOperStatus = 'up' WHERE `interface_id` = '".$interface['interface_id']."'");
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -82,7 +82,6 @@ if(!$config['graph_colours']['mixed']) {
|
||||
$config['version'] = "0.10.0";
|
||||
|
||||
$config['rrd_opts_array'] = explode(" ", trim($config['rrdgraph_def_text']));
|
||||
# print_r($config['rrd_opts_array']);
|
||||
|
||||
if($config['enable_nagios']) {
|
||||
$nagios_link = mysql_connect($config['nagios_db_host'], $config['nagios_db_user'], $config['nagios_db_pass']);
|
||||
|
||||
Reference in New Issue
Block a user