|
@@ -297,10 +297,10 @@ sub insert_alert($$$$$) {
|
|
|
if ($ACKS[$i]->[2] ne $state) {
|
|
|
# Same alert, but different level
|
|
|
$ACKS[$i]->[2]=$state;
|
|
|
- return mark ('C', $i, $state);
|
|
|
+ return format_alert_id('C', $i, $state);
|
|
|
} else {
|
|
|
# Same alert
|
|
|
- return mark ('!', $i, $state);
|
|
|
+ return format_alert_id('!', $i, $state);
|
|
|
# No need to display...
|
|
|
}
|
|
|
}
|
|
@@ -413,7 +413,9 @@ sub nagios_query_status($){
|
|
|
$nagioscmd = Irssi::settings_get_str("nagios_command");
|
|
|
foreach $unixline ( `echo "GET services
|
|
|
Columns: last_state_change host_name display_name state plugin_output
|
|
|
-Filter: state > 1" | unixcat $nagioscmd` ) {
|
|
|
+Filter: state > 0
|
|
|
+Filter: acknowledged = 0
|
|
|
+And: 2" | unixcat $nagioscmd` ) {
|
|
|
($d,$host,$service,$state,$output)=split /;/,$unixline;
|
|
|
handle_alert($option,$d,'SERVICE',$host,$NagStates[$state+10],$output,$service);
|
|
|
Irssi::print("%B>>%n $unixline", MSGLEVEL_CLIENTCRAP);
|
|
@@ -422,7 +424,9 @@ Filter: state > 1" | unixcat $nagioscmd` ) {
|
|
|
return;
|
|
|
foreach $unixline ( `echo "GET hosts
|
|
|
Columns: last_state_change host_name state plugin_output
|
|
|
-Filter: state > 1" | unixcat $nagioscmd` ) {
|
|
|
+Filter: state > 0
|
|
|
+Filter: acknowledged = 0
|
|
|
+And: 2" | unixcat $nagioscmd` ) {
|
|
|
($d,$host,$state,$output)=split /;/,$unixline;
|
|
|
handle_alert($option,$d,'HOST',$host,$NagStates[$state],$output,"");
|
|
|
Irssi::print("%B>>%n $unixline", MSGLEVEL_CLIENTCRAP);
|
|
@@ -437,19 +441,21 @@ Filter: state > 1" | unixcat $nagioscmd` ) {
|
|
|
sub parse_nagios_log($){
|
|
|
my $option="";
|
|
|
$d=0; $status_line=""; $host="";$output="";$service="";
|
|
|
+ $status_line=shift;
|
|
|
|
|
|
### log :
|
|
|
# [1412330770] SERVICE ALERT: ella;IMAPs_LOGIN;OK;SOFT;2;OK - CO1N OK LOGIN Ok.
|
|
|
# /\[\d+\] (\w+) ALERT: (\w+);(\w+);(\w+);HARD;(\d+);(.+)/
|
|
|
# [1410969598] HOST ALERT: filou;DOWN;SOFT;1;PING CRITICAL - Paquets perdus = 100%
|
|
|
# [TIMESTAMP] PROCESS type ALERT: host;service;STATE1;HARD;num;commentaire
|
|
|
- if (@match=$status_line =~ /\[?(\d+)\]? HOST ALERT: ([^@;]+)[@;](\w+)[@;]HARD[@;].*[@;](.+)/) {
|
|
|
+
|
|
|
+ if (@match=$status_line =~ /\[?(\d+)\]? HOST ALERT: ([^@;]+)[@;]([^;@]+)[@;]HARD[@;][^;@]*[@;](.+)/) {
|
|
|
# HOST ########################
|
|
|
($d,$host,$state,$output)=@match;
|
|
|
handle_alert($option,$d,"HOST",$host,$state,$output,$service);
|
|
|
|
|
|
# SERVICE #####################
|
|
|
- } elsif (@match=$status_line =~ /\[?(\d+)\]? (\w+) ALERT: ([^;@]+)[@;]([^;@]+)[@;](\w+)[@;]HARD[@;].*[@;](.+)/) {
|
|
|
+ } elsif (@match=$status_line =~ /\[?(\d+)\]? (\w+) ALERT: ([^;@]+)[@;]([^;@]+)[@;]([^;@]+)[@;]HARD[@;][^;@]*[@;](.+)/) {
|
|
|
($d,$type,$host,$service,$state,$output)=@match;
|
|
|
|
|
|
$service=~s/[^\w\d_-]/_/g;
|
|
@@ -462,7 +468,7 @@ sub parse_nagios_log($){
|
|
|
# FALLBACK ####################
|
|
|
} else {
|
|
|
Irssi::print( #
|
|
|
- "%B>>%n $IRSSI{name} received command: \"$_\"",
|
|
|
+ "%B>>%n $IRSSI{name} received message: \"$_\"",
|
|
|
MSGLEVEL_CLIENTCRAP); #
|
|
|
next
|
|
|
}
|