mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-23 22:05:41 +02:00
2011-08-17 Sancho Lerena <slerena@artica.es>
* SNMPServer.pm: Custom value and custom type are not used anymore. All extended info comes into custom_oid which stores now all the raw info. * Core.pm: pandora_evaluate_snmp_alerts() function now uses complex regular expression and new macros to allow complex SNMP trap alerts which takes information from the trap info and puts on the alert. * DataServer.pm: Fixed notice about undefined GIS position desc. * pandora_db.pl: Version update. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4761 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
194eca91d8
commit
df6d922a69
@ -1,3 +1,17 @@
|
|||||||
|
2011-08-17 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
|
* SNMPServer.pm: Custom value and custom type are not used anymore.
|
||||||
|
All extended info comes into custom_oid which stores now all the
|
||||||
|
raw info.
|
||||||
|
|
||||||
|
* Core.pm: pandora_evaluate_snmp_alerts() function now uses complex
|
||||||
|
regular expression and new macros to allow complex SNMP trap alerts
|
||||||
|
which takes information from the trap info and puts on the alert.
|
||||||
|
|
||||||
|
* DataServer.pm: Fixed notice about undefined GIS position desc.
|
||||||
|
|
||||||
|
* pandora_db.pl: Version update.
|
||||||
|
|
||||||
2011-08-17 Ramon Novoa <rnovoa@artica.es>
|
2011-08-17 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* lib/PandoraFMS/NetworkServer.pm: Convert text obj tags to OIDs.
|
* lib/PandoraFMS/NetworkServer.pm: Convert text obj tags to OIDs.
|
||||||
|
@ -1590,15 +1590,16 @@ sub pandora_module_keep_alive_nd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
=head2 C<< pandora_evaluate_snmp_alerts (I<$pa_config>, I<$trap_id>, I<$trap_agent>, I<$trap_oid>, I<$trap_oid_text>, I<$value>, I<$trap_custom_oid>, I<$trap_custom_value>, I<$dbh>) >>
|
=head2 C<< pandora_evaluate_snmp_alerts (I<$pa_config>, I<$trap_id>, I<$trap_agent>, I<$trap_oid>, I<$trap_oid_text>, I<$value>, I<$trap_custom_oid>, I<$dbh>) >>
|
||||||
|
|
||||||
Execute alerts that apply to the given SNMP trap.
|
Execute alerts that apply to the given SNMP trap.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
sub pandora_evaluate_snmp_alerts ($$$$$$$$) {
|
||||||
my ($pa_config, $trap_id, $trap_agent, $trap_oid,
|
my ($pa_config, $trap_id, $trap_agent, $trap_oid,
|
||||||
$trap_oid_text, $trap_value, $trap_custom_oid, $trap_custom_value, $dbh) = @_;
|
$trap_oid_text, $trap_value, $trap_custom_oid, $dbh) = @_;
|
||||||
|
|
||||||
|
|
||||||
# Get all SNMP alerts
|
# Get all SNMP alerts
|
||||||
my @snmp_alerts = get_db_rows ($dbh, 'SELECT * FROM talert_snmp');
|
my @snmp_alerts = get_db_rows ($dbh, 'SELECT * FROM talert_snmp');
|
||||||
@ -1613,28 +1614,57 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
|||||||
($alert->{'times_fired'}, $alert->{'internal_counter'}, $alert->{'alert_type'});
|
($alert->{'times_fired'}, $alert->{'internal_counter'}, $alert->{'alert_type'});
|
||||||
|
|
||||||
# OID
|
# OID
|
||||||
|
# Decode first, could be a complex regexp !
|
||||||
|
$alert->{'oid'} = decode_entities($alert->{'oid'});
|
||||||
my $oid = $alert->{'oid'};
|
my $oid = $alert->{'oid'};
|
||||||
if ($oid ne '') {
|
if ($oid ne '') {
|
||||||
next if ($trap_oid !~ m/^$oid$/i && $trap_oid_text !~ m/^$oid$/i);
|
next if ($trap_oid !~ m/^$oid$/i && $trap_oid_text !~ m/^$oid$/i);
|
||||||
$alert_data .= "OID: $oid ";
|
$alert_data .= "OID: $oid ";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Custom OID/value
|
# Specific SNMP Trap alert macros for regexp selectors in trap info
|
||||||
my $custom_oid = $alert->{'custom_oid'};
|
my $snmp_f1 = "";
|
||||||
if ($custom_oid ne '') {
|
my $snmp_f2 = "";
|
||||||
if ($trap_value =~ m/^$custom_oid$/i){
|
my $snmp_f3 = "";
|
||||||
$alert_data .= " Trap Value: $trap_value";
|
|
||||||
|
# Custom OID/value
|
||||||
} elsif ($trap_custom_value =~ m/^$custom_oid$/i){
|
# Decode first, this could be a complex regexp !
|
||||||
$alert_data .= " Trap Value: $trap_custom_value";
|
|
||||||
|
$alert->{'custom_oid'} = decode_entities($alert->{'custom_oid'});
|
||||||
|
my $custom_oid = $alert->{'custom_oid'};
|
||||||
|
|
||||||
|
if ($custom_oid ne '') {
|
||||||
|
if ($trap_custom_oid =~ m/^$custom_oid$/i){
|
||||||
|
$alert_data .= " Custom: $trap_custom_oid";
|
||||||
|
|
||||||
|
# Let's capture some data using regexp selectors !
|
||||||
|
|
||||||
|
if (defined($1)){
|
||||||
|
$snmp_f1 = $1;
|
||||||
|
}
|
||||||
|
if (defined($2)){
|
||||||
|
$snmp_f2 = $2;
|
||||||
|
}
|
||||||
|
if (defined($3)){
|
||||||
|
$snmp_f3 = $3;
|
||||||
|
}
|
||||||
|
|
||||||
} elsif ($trap_custom_oid =~ m/^$custom_oid$/i){
|
|
||||||
$alert_data .= " Trap Value: $trap_custom_oid";
|
|
||||||
} else {
|
} else {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# SANCHO DEBUG
|
||||||
|
|
||||||
|
my %macros;
|
||||||
|
$macros{_snmp_f1_} = $snmp_f1;
|
||||||
|
$macros{_snmp_f2_} = $snmp_f2;
|
||||||
|
$macros{_snmp_f3_} = $snmp_f3;
|
||||||
|
|
||||||
|
$alert->{'al_field1'} = subst_alert_macros ($alert->{'al_field1'}, \%macros);
|
||||||
|
$alert->{'al_field2'} = subst_alert_macros ($alert->{'al_field2'}, \%macros);
|
||||||
|
$alert->{'al_field3'} = subst_alert_macros ($alert->{'al_field3'}, \%macros);
|
||||||
|
|
||||||
# Agent IP
|
# Agent IP
|
||||||
my $agent = $alert->{'agent'};
|
my $agent = $alert->{'agent'};
|
||||||
if ($agent ne '') {
|
if ($agent ne '') {
|
||||||
@ -1702,7 +1732,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
|
|||||||
WHERE talert_actions.id_alert_command = talert_commands.id
|
WHERE talert_actions.id_alert_command = talert_commands.id
|
||||||
AND talert_actions.id = ?', $alert->{'id_alert'});
|
AND talert_actions.id = ?', $alert->{'id_alert'});
|
||||||
|
|
||||||
my $trap_rcv_full = $trap_oid . " " . $trap_value. " ". $trap_custom_oid . " " . $trap_custom_value;
|
my $trap_rcv_full = $trap_oid . " " . $trap_value. " ". $trap_custom_oid;
|
||||||
|
|
||||||
pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert, 1, $action, undef, $dbh, $timestamp) if (defined ($action));
|
pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert, 1, $action, undef, $dbh, $timestamp) if (defined ($action));
|
||||||
|
|
||||||
|
@ -241,11 +241,13 @@ sub process_xml_data ($$$$$) {
|
|||||||
my $doc = $xs1->XMLin($content);
|
my $doc = $xs1->XMLin($content);
|
||||||
$position_description = safe_input ($doc->{result}{content});
|
$position_description = safe_input ($doc->{result}{content});
|
||||||
|
|
||||||
} else {
|
|
||||||
$position_description = ''; # Default value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!defined($position_description)){
|
||||||
|
$position_description = "";
|
||||||
|
}
|
||||||
|
|
||||||
logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude position_description=$position_description", 8);
|
logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude position_description=$position_description", 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,12 +151,12 @@ sub pandora_snmptrapd {
|
|||||||
$value = limpia_cadena ($value);
|
$value = limpia_cadena ($value);
|
||||||
|
|
||||||
my ($custom_oid, $custom_type, $custom_value) = ('', '', '');
|
my ($custom_oid, $custom_type, $custom_value) = ('', '', '');
|
||||||
($custom_oid, $custom_type, $custom_value) = ($1, $2, limpia_cadena ($3)) if ($data =~ m/([0-9\.]*)\s\=\s([A-Za-z0-9]*)\:\s(.+)/);
|
|
||||||
|
# custom_type, custom_value is not used since 4.0 version, all custom data goes on custom_oid
|
||||||
|
$custom_oid = $data;
|
||||||
|
|
||||||
# Try to save as much information as possible if the trap could not be parsed
|
# Try to save as much information as possible if the trap could not be parsed
|
||||||
$oid = $type_desc if ($oid eq '' || $oid eq '.');
|
$oid = $type_desc if ($oid eq '' || $oid eq '.');
|
||||||
$custom_value = $type_desc if ($custom_oid eq '' || $custom_oid eq '.');
|
|
||||||
$custom_value = $data if ($custom_value eq '');
|
|
||||||
|
|
||||||
# Insert the trap into the DB
|
# Insert the trap into the DB
|
||||||
if (! defined(enterprise_hook ('snmp_insert_trap', [$pa_config, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type, $timestamp, $self->getServerID (), $dbh]))) {
|
if (! defined(enterprise_hook ('snmp_insert_trap', [$pa_config, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type, $timestamp, $self->getServerID (), $dbh]))) {
|
||||||
@ -165,7 +165,7 @@ sub pandora_snmptrapd {
|
|||||||
logger ($pa_config, "Received SNMP Trap from $source", 4);
|
logger ($pa_config, "Received SNMP Trap from $source", 4);
|
||||||
|
|
||||||
# Evaluate alerts for this trap
|
# Evaluate alerts for this trap
|
||||||
pandora_evaluate_snmp_alerts ($pa_config, $trap_id, $source, $oid, $oid, $value, $custom_oid, $custom_value, $dbh);
|
pandora_evaluate_snmp_alerts ($pa_config, $trap_id, $source, $oid, $oid, $value, $custom_oid, $dbh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ use PandoraFMS::Tools;
|
|||||||
use PandoraFMS::DB;
|
use PandoraFMS::DB;
|
||||||
|
|
||||||
# version: define current version
|
# version: define current version
|
||||||
my $version = "4.0 PS100310";
|
my $version = "4.0 PS110810";
|
||||||
|
|
||||||
# Pandora server configuration
|
# Pandora server configuration
|
||||||
my %conf;
|
my %conf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user