2009-10-15 Sancho lerena <slernea@artica.es>

* lib/PandoraFMS/SNMPServer.pm: Fixed small problem in snmp2agent
        forwarding and better implementation of server error control.
        Also solved problem with duplicated traps in SNMP console.

        * lib/PandoraFMS/Server.pm: better implementation of server error control.

        * lib/PandoraFMS/Core.pm: SNMP alerts now show the IP in _agent_ macro   

        * lib/PandoraFMS/Tools.pm: Better management of enterprise_hook on 
        opensource version. 

        * util/alert_multicast.pl: Added sample of alert script for render
        alerts as multicast XML.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2023 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2009-10-15 11:23:40 +00:00
parent 2a2c5b9a52
commit b56c3d8ef7
6 changed files with 139 additions and 74 deletions

View File

@ -1,3 +1,19 @@
2009-10-15 Sancho lerena <slernea@artica.es>
* lib/PandoraFMS/SNMPServer.pm: Fixed small problem in snmp2agent
forwarding and better implementation of server error control.
Also solved problem with duplicated traps in SNMP console.
* lib/PandoraFMS/Server.pm: better implementation of server error control.
* lib/PandoraFMS/Core.pm: SNMP alerts now show the IP in _agent_ macro
* lib/PandoraFMS/Tools.pm: Better management of enterprise_hook on
opensource version.
* util/alert_multicast.pl: Added sample of alert script for render
alerts as multicast XML.
2009-10-13 Sancho Lerena <slerena@artica.es>
* util/pandora_server: Incremented shutting down grace time to 60 secs

View File

@ -443,7 +443,7 @@ sub pandora_execute_action ($$$$$$$$) {
_alert_times_fired_ => $alert->{'times_fired'},
_alert_priority_ => $alert->{'priority'},
_module_ => (defined ($module)) ? $module->{'nombre'} : '',
_id_agent_ => (defined ($agent)) ? $module->{'id_agente'} : '',
_id_agent_ => (defined ($module)) ? $module->{'id_agente'} : '',
);
@ -905,13 +905,19 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$) {
'priority' => $alert->{'priority'},
);
my %agent = (
'nombre' => $trap_agent,
'direccion' => $trap_agent,
);
# Execute alert
my $action = get_db_single_row ($dbh, 'SELECT *
FROM talert_actions, talert_commands
WHERE talert_actions.id_alert_command = talert_commands.id
AND talert_actions.id = ?', $alert->{'id_alert'});
pandora_execute_action ($pa_config, '', undef, \%alert, 1, $action, undef, $dbh) if (defined ($action));
my $trap_rcv_full = $trap_oid . " " . $trap_custom_oid . " " . $trap_custom_value;
pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert, 1, $action, undef, $dbh) if (defined ($action));
# Generate an event
pandora_event ($pa_config, "SNMP alert fired (" . $alert->{'description'} . ")",

View File

@ -74,6 +74,7 @@ sub pandora_snmptrapd {
my $self = shift;
my $pa_config = $self->getConfig ();
eval {
# Connect to the DB
my $dbh = db_connect ('mysql', $pa_config->{'dbname'}, $pa_config->{'dbhost'},
3306, $pa_config->{'dbuser'}, $pa_config->{'dbpass'});
@ -152,13 +153,17 @@ sub pandora_snmptrapd {
# Evaluate alerts for this trap
pandora_evaluate_snmp_alerts ($pa_config, $trap_id, $source, $oid, $oid, $custom_oid, $custom_value, $dbh);
}
if ($pa_config->{enterprise} == 1){
enterprise_hook ('snmp_trap2agent', [$trap2agent, $pa_config, $source, $oid, $value, $custom_oid, $custom_value, $timestamp, $self->getServerID (), $dbh]);
}
}
sleep ($pa_config->{'server_threshold'});
}
};
if ($@) {
$self->setErrStr ($@);
}
}
########################################################################################

View File

@ -241,9 +241,11 @@ sub restartEvent ($$) {
my ($self, $msg) = @_;
return unless defined ($self->{'_dbh'});
eval {
pandora_event ($self->{'_pa_config'}, $self->{'_pa_config'}->{'servername'} .
$ServerTypes[$self->{'_server_type'}] . " RESTARTING" . (defined ($msg) ? " ($msg)" : ''),
0, 0, 4, 0, 0, 'system', $self->{'_dbh'});
};
}
########################################################################################

View File

@ -365,7 +365,10 @@ sub enterprise_hook ($$) {
my $output = eval { &$func (@args); };
# Check for errors
return undef if ($@);
#return undef if ($@);
# undef is returned only if the enterprise function was not found
return '' unless defined ($output);
return $output;
}

View File

@ -0,0 +1,33 @@
#!/usr/bin/perl
# Multicast client
# Copyright (c) 2007 Artica Soluciones Tecnologicas S.L.
use strict;
use warnings;
use POSIX qw(strftime);
use IO::Socket::Multicast;
if ($#ARGV != 3) {
print "Usage: $0 <group> <port> <agent_name> <alert_name>\n";
exit 1;
}
my $group = $ARGV[0];
my $port = $ARGV[1];
my $agent_name = $ARGV[2];
my $alert_name = $ARGV[3];
my $status_report = "<status_report>\n";
$status_report .= "<element id='$agent_name' name='$alert_name' status='ALRM' timestamp='" . strftime ("%Y/%m/%d %H:%M:%S", localtime()) . "'></element>\n";
$status_report .= "</status_report>\n";
my $socket = IO::Socket::Multicast->new(Proto => 'udp',
PeerAddr => $group . ':' . $port);
return unless defined ($socket);
$socket->send($status_report);
# print $status_report;