2009-04-24 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Core.pm: Generate an event when executing a SNMP alert. Small fixes. * lib/PandoraFMS/ReconServer.pm: Enabled OS filtering. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1652 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4fd6d10359
commit
aa07cc7ecd
|
@ -1,3 +1,10 @@
|
|||
2009-04-24 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* lib/PandoraFMS/SNMPServer.pm, lib/PandoraFMS/Core.pm: Generate
|
||||
an event when executing a SNMP alert. Small fixes.
|
||||
|
||||
* lib/PandoraFMS/ReconServer.pm: Enabled OS filtering.
|
||||
|
||||
2009-04-23 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* lib/PandoraFMS/SNMPServer.pm: Add a newline character after
|
||||
|
|
|
@ -826,9 +826,9 @@ sub pandora_module_keep_alive_nd {
|
|||
##########################################################################
|
||||
# Execute alerts that apply to the given SNMP trap.
|
||||
##########################################################################
|
||||
sub pandora_evaluate_snmp_alerts ($$$$$$$) {
|
||||
sub pandora_evaluate_snmp_alerts ($$$$$$$$) {
|
||||
my ($pa_config, $trap_id, $trap_agent, $trap_oid,
|
||||
$trap_oid_text, $trap_custom_value, $dbh) = @_;
|
||||
$trap_oid_text, $trap_custom_oid, $trap_custom_value, $dbh) = @_;
|
||||
|
||||
# Get all SNMP alerts
|
||||
my @snmp_alerts = get_db_rows ($dbh, 'SELECT * FROM talert_snmp');
|
||||
|
@ -844,10 +844,10 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$) {
|
|||
my $oid = $alert->{'oid'};
|
||||
($fire_alert, $alert_data) = (1, 'SNMP/OID:' . $oid) if ($trap_oid =~ m/$oid/i ||
|
||||
$trap_oid_text =~ m/$oid/i);
|
||||
# Custom value
|
||||
# Custom OID/value
|
||||
} elsif ($alert_type == 1){ # type 1 is custom value
|
||||
my $custom_oid = $alert->{'custom_oid'};
|
||||
($fire_alert, $alert_data) = (1, 'SNMP/VALUE:' . $custom_oid) if ($trap_custom_value =~ m/$custom_oid/i);
|
||||
($fire_alert, $alert_data) = (1, 'SNMP/VALUE:' . $custom_oid) if ($trap_custom_value =~ m/$custom_oid/i || $trap_custom_oid =~ m/$custom_oid/i);
|
||||
# Agent IP
|
||||
} else {
|
||||
my $agent = $alert->{'agent'};
|
||||
|
@ -893,8 +893,11 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$) {
|
|||
FROM talert_actions, talert_commands
|
||||
WHERE talert_actions.id_alert_command = talert_commands.id
|
||||
AND talert_actions.id = ?', $alert->{'id_alert'});
|
||||
if (defined ($action)) {
|
||||
pandora_execute_action ($pa_config, '', undef, \%alert, 1, $action, $dbh);
|
||||
if (defined ($action) && pandora_execute_action ($pa_config, '', undef, \%alert, 1, $action, $dbh) == 1) {
|
||||
|
||||
# Generate an event
|
||||
pandora_event ($pa_config, "SNMP alert fired (" . $alert->{'description'} . ")",
|
||||
0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', $dbh);
|
||||
}
|
||||
|
||||
# Update alert status
|
||||
|
|
|
@ -150,12 +150,13 @@ sub data_consumer ($$) {
|
|||
|
||||
next unless ($alive == 1);
|
||||
|
||||
# Guess the OS and filter
|
||||
my $id_os = guess_os ($pa_config, $addr);
|
||||
next if ($task->{'id_os'} > 0 && $task->{'id_os'} != $id_os);
|
||||
|
||||
$hosts_found++;
|
||||
$addr_found .= $addr . " ";
|
||||
|
||||
# Guess the OS
|
||||
my $id_os = guess_os ($pa_config, $addr);
|
||||
|
||||
# Resolve the address
|
||||
my $host_name = gethostbyaddr(inet_aton($addr), AF_INET);
|
||||
$host_name = $addr unless defined ($host_name);
|
||||
|
|
|
@ -134,7 +134,7 @@ sub pandora_snmptrapd {
|
|||
my ($custom_oid, $custom_type, $custom_value) = ('', '', $type_desc);
|
||||
|
||||
# Custom OID
|
||||
if ($type == 6) {
|
||||
if ($type eq '6') {
|
||||
|
||||
#String data
|
||||
next if ($data =~ m/STRING/) && ($data !~ m/([0-9\.]*)\s\=\s([A-Za-z0-9]*)\:\s\"(.+)\"/);
|
||||
|
@ -152,7 +152,7 @@ sub pandora_snmptrapd {
|
|||
logger ($pa_config, "Received SNMP Trap from $source", 4);
|
||||
|
||||
# Evaluate alerts for this trap
|
||||
pandora_evaluate_snmp_alerts ($pa_config, $trap_id, $source, $oid, $oid, $custom_oid . ' ' . $custom_value, $dbh);
|
||||
pandora_evaluate_snmp_alerts ($pa_config, $trap_id, $source, $oid, $oid, $custom_oid, $custom_value, $dbh);
|
||||
}
|
||||
|
||||
enterprise_hook ('snmp_trap2agent', [$trap2agent, $pa_config, $source, $oid, $value, $custom_oid, $custom_value, $timestamp, $dbh]);
|
||||
|
|
Loading…
Reference in New Issue