snmp monitoring enhancement: added contains =~ in the monsettting table to filter the traps out for certain actions.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6197 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
60cf8edb1c
commit
6ac3c398c9
@ -781,7 +781,7 @@ sub getDescription {
|
||||
Settings:
|
||||
ignore: specifies the events that will be ignored. It's a comma separated
|
||||
pairs of oid=value. For example,
|
||||
BLADESPPALT-MIB::spTrapAppType=4,BLADESPPALT-MIB::spTrapAppType=4.
|
||||
spTrapAppType=4,spTrapMsgText=~power,spTrapMsgText=Hello there.
|
||||
email: specifies the events that will get email notification.
|
||||
log: specifies the events that will get logged.
|
||||
runcmd: specifies the events that will be passed to the user defined scripts.
|
||||
@ -798,9 +798,9 @@ sub getDescription {
|
||||
Informational -- all informational events.
|
||||
|
||||
For example, you can have the following setting:
|
||||
email CRITICAL,BLADESPPALT-MIB::pTrapPriority=4
|
||||
This means send email for all the critical events and the BladeCenter
|
||||
system events.\n"
|
||||
email Critical,spTrapMsgText=~Test this,spTrapMsgText=Hello there
|
||||
This means send email for all the critical events and events with spTrapMsgText
|
||||
contains the phrase 'Test this' or equals 'Hello there'.\n"
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
|
@ -12,6 +12,7 @@ use xCAT::NetworkUtils;
|
||||
use xCAT_plugin::ipmi;
|
||||
use xCAT_monitoring::monitorctrl;
|
||||
use Socket;
|
||||
use Data::Dumper;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -412,18 +413,23 @@ sub getMoreInfo {
|
||||
sub parseSettings {
|
||||
my $settings=shift;
|
||||
my %ret=();
|
||||
while (($settings =~ s/^(Informational|Warning|Critical|All|None)()(,)*//) ||
|
||||
($settings =~ s/^([^\=]+)=(\"[^\"]+\")(,)*//) ||
|
||||
($settings =~ s/^([^\=]+)=([^\"\,]+)(,)*//)) {
|
||||
#print "$1=$2\n";
|
||||
if (exists($ret{$1}{'eq'})) {
|
||||
my $pa=$ret{$1}{eq};
|
||||
push(@$pa, $2);
|
||||
while (($settings =~ s/^(Informational|Warning|Critical|All|None)()()(,)*//) ||
|
||||
($settings =~ s/^([^\=]+)(=~)(\"[^\"]+\")(,)*//) ||
|
||||
($settings =~ s/^([^\=]+)(=~)([^\"\,]+)(,)*//) ||
|
||||
($settings =~ s/^([^\=]+)(=)(\"[^\"]+\")(,)*//) ||
|
||||
($settings =~ s/^([^\=]+)(=)([^\"\,]+)(,)*//)) {
|
||||
my $val='eq';
|
||||
if ($2 eq "=~") { $val='=~';}
|
||||
if (exists($ret{$1}{$val})) {
|
||||
my $pa=$ret{$1}{$val};
|
||||
push(@$pa, $3);
|
||||
}
|
||||
else {
|
||||
$ret{$1}{'eq'}=[$2];
|
||||
$ret{$1}{$val}=[$3];
|
||||
}
|
||||
}
|
||||
|
||||
#print Dumper(%ret);
|
||||
return %ret;
|
||||
}
|
||||
|
||||
@ -451,19 +457,37 @@ sub checkWithOid {
|
||||
@a_oid=split('::', $o);
|
||||
my $new_o=$o;
|
||||
if (@a_oid == 2) { $new_o=$a_oid[1]; }
|
||||
print "o=$o, new_o=$new_o\n";
|
||||
#print "o=$o, new_o=$new_o v=$v\n";
|
||||
|
||||
#check for 'contains'
|
||||
if (exists($hashX->{$o})) {
|
||||
my $pa= $hashX->{$o}{'=~'};
|
||||
foreach(@$pa) {
|
||||
if ($v =~ /$_/) {return 1; }
|
||||
}
|
||||
}
|
||||
if (exists($hashX->{$new_o})) {
|
||||
my $pa= $hashX->{$new_o}{'=~'};
|
||||
foreach(@$pa) {
|
||||
if ($v =~ /$_/) {return 1; }
|
||||
}
|
||||
}
|
||||
|
||||
#check for 'equals'
|
||||
if (exists($hashX->{$o})) {
|
||||
my $pa= $hashX->{$o}{'eq'};
|
||||
foreach(@$pa) {
|
||||
if ($_ eq $v) {return 1; }
|
||||
if ($_ eq $v) { return 1; }
|
||||
}
|
||||
}
|
||||
if (exists($hashX->{$new_o})) {
|
||||
my $pa= $hashX->{$new_o}{'eq'};
|
||||
foreach(@$pa) {
|
||||
if ($_ eq $v) {return 1; }
|
||||
if ($_ eq $v) { return 1; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user