|
@@ -37,7 +37,7 @@ our ( $FIFO, # fifo absolute filename (expanded from Irssi config)
|
|
|
$FIFO_HANDLE, # fifo filehandle for `open' et al.
|
|
|
$FIFO_TAG ); # fifo signal tag for `input_add'
|
|
|
|
|
|
-$VERSION = "0.3.0";
|
|
|
+$VERSION = "0.4.2";
|
|
|
%IRSSI = (
|
|
|
authors => 'asr',
|
|
|
contact => 'root@lautre.net',
|
|
@@ -48,6 +48,7 @@ $VERSION = "0.3.0";
|
|
|
changed => '20141006',
|
|
|
modules => ''
|
|
|
);
|
|
|
+my $PRINTF = "/usr/bin/printf";
|
|
|
|
|
|
# Put signals to irssi ###################################################
|
|
|
Irssi::settings_add_str($IRSSI{name}, # default fifo_remote_file
|
|
@@ -55,7 +56,8 @@ Irssi::settings_add_str($IRSSI{name}, # default fifo_remote_file
|
|
|
|
|
|
Irssi::settings_add_str("nagios_ack", "nagios_ack_channel", "#main_channel"); # see also etc/config.template
|
|
|
Irssi::settings_add_str("nagios_ack", "nagios_ack_nick", ""); # any user (none by default)
|
|
|
-Irssi::settings_add_str("nagios_ack", "nagios_command", "/var/lib/nagios3/rw/live");
|
|
|
+Irssi::settings_add_str("nagios_ack", "nagios_live", "/var/lib/nagios3/rw/live");
|
|
|
+Irssi::settings_add_str("nagios_ack", "nagios_command", "/var/lib/nagios3/rw/nagios.cmd");
|
|
|
#Irssi::command_bind( 'ack', \&nagios_ack );
|
|
|
#Irssi::command_bind( 'nagstat', \&nagios_status );
|
|
|
Irssi::command_bind( 'nagrefresh', \&nagios_query_status );
|
|
@@ -65,6 +67,7 @@ Irssi::command_bind( 'nagrefresh', \&nagios_query_status );
|
|
|
|
|
|
# To be used to check immediately / hosts-stats
|
|
|
my $nagioscmd = Irssi::settings_get_str("nagios_command");
|
|
|
+my $nagioslive = Irssi::settings_get_str("nagios_live");
|
|
|
my $nagios_ack_channel= Irssi::settings_get_str("nagios_ack_channel");
|
|
|
my $nagios_ack_nick= Irssi::settings_get_str("nagios_ack_nick");
|
|
|
|
|
@@ -119,13 +122,15 @@ my $state_to_color = {
|
|
|
# where is the memory leak.
|
|
|
my ($status_line);
|
|
|
my @match;
|
|
|
-my ($msg,$num);
|
|
|
-my ($message,$i);
|
|
|
+my $msg;
|
|
|
+my $i;
|
|
|
+my $stat;
|
|
|
+my $message;
|
|
|
my ($type,$data);
|
|
|
my ($d,$type,$host,$service,$state,$output);
|
|
|
-my ( $host, $svc, $state, $msg, $id );
|
|
|
+my ( $host, $svc, $state, $id );
|
|
|
|
|
|
-my ($server, $msg, $nick, $addr, $target);
|
|
|
+my ($server, $nick, $addr, $target);
|
|
|
my ( $param, $server, $window );
|
|
|
my (@issue, $issue);
|
|
|
|
|
@@ -135,7 +140,7 @@ my (@issue, $issue);
|
|
|
|
|
|
my $last_alert;
|
|
|
|
|
|
-my $DEBUG=Irssi::settings_get_str("nagios_ack_channel");
|
|
|
+my $DEBUG=Irssi::settings_get_str("nagios_ack_nick");
|
|
|
|
|
|
# Simple subs ############################################################
|
|
|
sub TRUE() { 1 } # some constants [perlsyn(1)
|
|
@@ -143,7 +148,7 @@ sub FALSE() { "" } # "Constant Functions"]
|
|
|
sub DEBUG(@) { print "%B", join(":", @_),"%n" }# DEBUG thingy
|
|
|
|
|
|
sub time2date($) {
|
|
|
- my ($d)=@_;
|
|
|
+ ($d)=@_;
|
|
|
return strftime("%d/%m/%y %H:%M", localtime($d));
|
|
|
}
|
|
|
|
|
@@ -167,8 +172,9 @@ sub nagios_inject;
|
|
|
# state : state string, from @NagStates or %state_to_color
|
|
|
sub format_alert_id($$$$); # ($Flag,$I,$state,$acked)
|
|
|
|
|
|
-# Add alert to array / index
|
|
|
-sub insert_alert($$$$$$); #( $host, $svc, $state, $msg, $d )
|
|
|
+# is_alert : is this alert in the DB ?
|
|
|
+# returns ID of alert ; -1 if not.
|
|
|
+sub is_alert($$$$$$) ;
|
|
|
|
|
|
|
|
|
##########################################################################
|
|
@@ -196,6 +202,10 @@ sub nagios_query_status($);
|
|
|
##########################################################################
|
|
|
# Part D : Alert processing ##############################################
|
|
|
|
|
|
+# display a line resuming the alert
|
|
|
+# ($server,$chan,$alert_id,$prefix) -> alert_id from @ACKS
|
|
|
+sub display_alert($$$$);
|
|
|
+
|
|
|
# Search for services/host informations, and post them to IRC ############
|
|
|
# Delimiter : ; for logs; @ for direct nagios custom notification command
|
|
|
# one parameter : the logline to parse.
|
|
@@ -216,6 +226,9 @@ sub setup(); # [2004-08-13]
|
|
|
# Interact with IRC chan users
|
|
|
sub event_privmsg ($$$$);
|
|
|
|
|
|
+##########################################################################
|
|
|
+# References #############################################################
|
|
|
+##########################################################################
|
|
|
# REFERENCES
|
|
|
# ----------
|
|
|
#
|
|
@@ -241,12 +254,42 @@ sub parse_status() {
|
|
|
|
|
|
sub nagios_ack($$$) {
|
|
|
( $param, $server, $window ) = @_;
|
|
|
+ $msg='';
|
|
|
@issue = parse_status();
|
|
|
if (!@issue) {
|
|
|
#$window->print("Failed to parse last status: $last_alert");
|
|
|
}
|
|
|
- my $message = " ACK ".$param . join ' ', reverse @issue;
|
|
|
- Irssi::active_server->command('MSG ' . $DEBUG . $message);
|
|
|
+ # $host / sticky / notif / persistant / user
|
|
|
+ ($id,$message)=split " ",$param;
|
|
|
+ if (($id =~ /^#(\d+)/) && ($id <= scalar @ACKS)) {
|
|
|
+ $id=$1;
|
|
|
+ $i=time;
|
|
|
+ if ($ACKS[$id]->[5] == 1) {
|
|
|
+ # Already ACKed, print an error.
|
|
|
+ $msg = " ACK : impossible, c'est dejà fait" ;
|
|
|
+ display_alert($server,$nagios_ack_channel,$id,' '
|
|
|
+# format_alert_id(' ', $id, $ACKS[$id]->[2], $ACKS[$id]->[5])
|
|
|
+ );
|
|
|
+ } elsif ($ACKS[$id]->[1] ne "") {
|
|
|
+ $msg = " ACK ".$id." \"ACKNOWLEDGE_SVC_PROBLEM;$ACKS[$id]->[0];$ACKS[$id]->[1];2;0;1;nagiosadmin;$message\" $i > $nagioscmd";
|
|
|
+ Irssi::active_server->command('MSG ' . $DEBUG . " ".
|
|
|
+ `$PRINTF "[\%lu] ACKNOWLEDGE_SVC_PROBLEM;$ACKS[$id]->[0];$ACKS[$id]->[1];2;0;1;nagiosadmin;$message" $i> $nagioscmd`
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ $msg = " ACK ".$id." \"ACKNOWLEDGE_HOST_PROBLEM;$ACKS[$id]->[0];2;0;1;nagiosadmin;$message\" $i > $nagioscmd";
|
|
|
+ Irssi::active_server->command('MSG ' . $DEBUG . " ".
|
|
|
+ `$PRINTF "[\%lu] ACKNOWLEDGE_HOST_PROBLEM;$ACKS[$id]->[0];2;0;1;nagiosadmin;$message" $i > $nagioscmd`
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $ACKS[$id]->[5] = 1;
|
|
|
+ Irssi::active_server->command('MSG ' . $nagios_ack_channel . $msg);
|
|
|
+ } else {
|
|
|
+ $server->command ( "msg ".$nagios_ack_channel. " Usage : !nagios ACK #<alert_num> <ack message to be sent to nagios>. Please validate first, with a !nagios list #<alert_num>");
|
|
|
+ display_alert($server,$nagios_ack_channel,$id,' '
|
|
|
+# format_alert_id(' ', $id, $ACKS[$id]->[2], $ACKS[$id]->[5])
|
|
|
+ ) if $id =~ /^(\d+)/ ;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
sub nagios_check($$$) {
|
|
@@ -256,7 +299,7 @@ sub nagios_check($$$) {
|
|
|
if (!@issue) {
|
|
|
#$window->print("Failed to parse last status: $last_alert");
|
|
|
}
|
|
|
- my $message = " CHECK ".$param . join ' ', reverse @issue;
|
|
|
+ $message = " CHECK ".$param . join ' ', reverse @issue;
|
|
|
Irssi::active_server->command('MSG ' . $DEBUG . $message);
|
|
|
# handle_alert($$$$$$$) { # $d,$type,$host,$state,$output,$service }
|
|
|
}
|
|
@@ -284,50 +327,23 @@ sub format_alert_id($$$$) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-# Add alert to array / index
|
|
|
-sub insert_alert($$$$$$) {
|
|
|
+# is_alert : is this alert in the DB ?
|
|
|
+sub is_alert($$$$$$) {
|
|
|
+# returns ID of alert ; -1 if not.
|
|
|
#Irssi::print(">> On vire $host/$svc");
|
|
|
my $i;
|
|
|
my $acked;
|
|
|
( $host, $svc, $state, $msg, $d, $acked ) = @_;
|
|
|
# ALERT
|
|
|
- if ( $state eq 'WARNING' || $state eq 'CRITICAL' || $state eq 'UNKNOWN' || $state eq 'DOWN' ) {
|
|
|
- while ($i <= $#ACKS) {
|
|
|
- # Update, or insert ?
|
|
|
- if (($ACKS[$i]->[0] eq $host) && ($ACKS[$i]->[1] eq $svc)) {
|
|
|
- $ACKS[$i]->[4]=$d;
|
|
|
- Irssi::print(">> found $i");
|
|
|
- if ($ACKS[$i]->[2] ne $state) {
|
|
|
- # Same alert, but different level
|
|
|
- $ACKS[$i]->[2]=$state;
|
|
|
- return format_alert_id('c', $i+1, $state,0);
|
|
|
- } else {
|
|
|
- # Same alert
|
|
|
- return format_alert_id('!', $i+1, $state,0);
|
|
|
- # No need to display...
|
|
|
- }
|
|
|
- }
|
|
|
- $i++;
|
|
|
+ while ($i <= $#ACKS) {
|
|
|
+ # Update, or insert ?
|
|
|
+ if (($ACKS[$i]->[0] eq $host) && ($ACKS[$i]->[1] eq $svc)) {
|
|
|
+ Irssi::print(">> found $i");
|
|
|
+ return $i;
|
|
|
}
|
|
|
- # New alert, insert.
|
|
|
- push (@ACKS, [ $host, $svc, $state, $msg, $d, $acked ] );
|
|
|
- return format_alert_id('+',scalar @ACKS,$state,0);
|
|
|
- # Clear alert
|
|
|
- } else {
|
|
|
-# Irssi::print(">> On vire $host/$svc");
|
|
|
- $i=0;
|
|
|
- # Find alert (need to be used by service/host index)
|
|
|
- while ($i <= $#ACKS) {
|
|
|
- if (($ACKS[$i]->[0] eq $host) && ($ACKS[$i]->[1] eq $svc)) {
|
|
|
- $ACKS[$i] = pop @ACKS;
|
|
|
- $i=$#ACKS;
|
|
|
- Irssi::print(">> found $i");
|
|
|
- return format_alert_id('-',$i+1,$state,1);
|
|
|
- }
|
|
|
- $i++;
|
|
|
- }
|
|
|
- return format_alert_id('?',0,$state,1);
|
|
|
+ $i++;
|
|
|
}
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -414,13 +430,13 @@ sub nagios_query_status($){
|
|
|
my @unixcat;
|
|
|
my $unixline;
|
|
|
my $acked;
|
|
|
- $nagioscmd = Irssi::settings_get_str("nagios_command");
|
|
|
+ $nagioslive = Irssi::settings_get_str("nagios_live");
|
|
|
foreach $acked (0,1) {
|
|
|
foreach $unixline ( `echo "GET services
|
|
|
-Columns: last_state_change host_alias display_name state plugin_output
|
|
|
+Columns: last_state_change host_name display_name state plugin_output
|
|
|
Filter: state > 0
|
|
|
Filter: acknowledged = $acked
|
|
|
-And: 2" | unixcat $nagioscmd` ) {
|
|
|
+And: 2" | unixcat $nagioslive` ) {
|
|
|
chomp $unixline;
|
|
|
($d,$host,$service,$state,$output)=split /;/,$unixline;
|
|
|
handle_alert($option,$d,'SERVICE',$host,$NagStates[$state+10],$output,$service,$acked);
|
|
@@ -431,10 +447,10 @@ And: 2" | unixcat $nagioscmd` ) {
|
|
|
return;
|
|
|
foreach $acked (0,1) {
|
|
|
foreach $unixline ( `echo "GET hosts
|
|
|
-Columns: last_state_change host_alias state plugin_output
|
|
|
+Columns: last_state_change host_name state plugin_output
|
|
|
Filter: state > 0
|
|
|
Filter: acknowledged = 0
|
|
|
-And: 2" | unixcat $nagioscmd` ) {
|
|
|
+And: 2" | unixcat $nagioslive` ) {
|
|
|
chomp $unixline;
|
|
|
($d,$host,$state,$output)=split /;/,$unixline;
|
|
|
handle_alert($option,$d,'HOST',$host,$NagStates[$state],$output,"",$acked);
|
|
@@ -446,6 +462,21 @@ And: 2" | unixcat $nagioscmd` ) {
|
|
|
##########################################################################
|
|
|
# Part D : Alert processing ##############################################
|
|
|
|
|
|
+sub display_alert($$$$){
|
|
|
+ my ($server,$chan,$alert_id,$prefix) = @_;
|
|
|
+ #Irssi::print("... $alert_id");
|
|
|
+ return unless defined $ACKS[$alert_id];
|
|
|
+# @ACKS; # [ hostname, service, state, plugin_output, last_state_change, ACKnowledged ] );
|
|
|
+# my ($server,$chan,$date,$prefix,$state,$acked,$hostname,$service,$output) = @_;
|
|
|
+ $prefix=format_alert_id($prefix,$alert_id,$ACKS[$alert_id]->[2],$ACKS[$alert_id]->[5]) ;
|
|
|
+ #format_alert_id(' ', $i, $K->[2], $K->[5]),
|
|
|
+ $server->command ( 'msg ' . $chan .
|
|
|
+ " NAGIOS ". time2date ($ACKS[$alert_id]->[4])." ".
|
|
|
+ $prefix. " ". $state_to_color->{$ACKS[$alert_id]->[2]}.$ACKS[$alert_id]->[0]."/".$ACKS[$alert_id]->[1].$C{Z}.
|
|
|
+ " / $ACKS[$alert_id]->[2]".($ACKS[$alert_id]->[5]?" Acked":"")." : $ACKS[$alert_id]->[3]"
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
# Search for services/host informations, and post them to IRC ############
|
|
|
# Delimiter : ; for logs; @ for direct nagios custom notification command
|
|
|
sub parse_nagios_log($){
|
|
@@ -485,29 +516,62 @@ sub parse_nagios_log($){
|
|
|
}
|
|
|
|
|
|
# Use alert fields to print and insert it
|
|
|
-sub handle_alert($$$$$$$$) { # $d,$type,$host,$state,$output,$service,acked
|
|
|
- my $option;
|
|
|
- my $acked;
|
|
|
-
|
|
|
+sub handle_alert($$$$$$$$) { # $option,$d,$type,$host,$state,$output,$service,acked
|
|
|
# Temporisation
|
|
|
+ my ($option,$acked);
|
|
|
($option,$d,$type,$host,$state,$output,$service,$acked)=@_;
|
|
|
next if exists $renot{"$host:$service"} && $renot{"$host:$service"} >= time() - 5;
|
|
|
$renot{"$host:$service"} = time();
|
|
|
|
|
|
- # HOST or SERVICE ?
|
|
|
- $id = insert_alert($host,$service,$state,$output,$d,$acked);
|
|
|
- $msg = "$id".$state_to_color->{$state} . "$host:$service".$C{Z}." is $state : $output";
|
|
|
- #Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);
|
|
|
+ my $id=is_alert ( $host, $service, $state, $output, $d, $acked ) ;
|
|
|
+ #( $host, $service, $state, $output, $d, $acked ) = @_;
|
|
|
+ my $acked;
|
|
|
|
|
|
- $last_alert="NAGIOS - $host/$service is $state";
|
|
|
- $d=time2date($d);
|
|
|
- $message = " $d - $last_alert - $msg";
|
|
|
- # Silently ignore previously sent alerts
|
|
|
- return if $id =~ '\[!' ;
|
|
|
+ # Silently ignore previously sent/acked alerts
|
|
|
+ Irssi::print(">> $stat,$d,$id,$state,$acked,$host,$service,$output");
|
|
|
$nagios_ack_channel= Irssi::settings_get_str("nagios_ack_channel");
|
|
|
- Irssi::active_server->command('MSG ' . $nagios_ack_channel .
|
|
|
- " ".$message) unless ($option eq "silent");
|
|
|
- # Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);
|
|
|
+ # ALERT
|
|
|
+ if ($id == -1) {
|
|
|
+ $id=scalar @ACKS;
|
|
|
+ if ( $state eq 'WARNING' || $state eq 'CRITICAL' || $state eq 'UNKNOWN' || $state eq 'DOWN' ) {
|
|
|
+ push (@ACKS, [ $host, $service, $state, $output, $d, $acked ] );
|
|
|
+ # display
|
|
|
+ display_alert(Irssi::active_server,$nagios_ack_channel,$id,'+'),
|
|
|
+ unless ($option eq "silent");
|
|
|
+ return ($#ACKS,'+');
|
|
|
+ } else {
|
|
|
+ push (@ACKS, [ $host, $service, $state, $output, $d, $acked ] );
|
|
|
+ # display
|
|
|
+ display_alert(Irssi::active_server,$nagios_ack_channel,$id,'?'),
|
|
|
+ unless ($option eq "silent");
|
|
|
+ pop @ACKS;
|
|
|
+ return ($#ACKS,'?');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ( $state eq 'WARNING' || $state eq 'CRITICAL' || $state eq 'UNKNOWN' || $state eq 'DOWN' ) {
|
|
|
+ $ACKS[$id]->[4]=$d;
|
|
|
+ if ($ACKS[$id]->[2] ne $state) {
|
|
|
+ # Same alert, but different level
|
|
|
+ $ACKS[$id]->[2]=$state;
|
|
|
+ # display
|
|
|
+ display_alert(Irssi::active_server,$nagios_ack_channel,$id,'c'),
|
|
|
+ unless ($option eq "silent");
|
|
|
+ return ($id+1,'c');
|
|
|
+ } else {
|
|
|
+ # Same alert
|
|
|
+ return ($id+1, '!');
|
|
|
+ # No need to display...
|
|
|
+ }
|
|
|
+ # Clear alert
|
|
|
+ } else {
|
|
|
+ # display
|
|
|
+ display_alert(Irssi::active_server,$nagios_ack_channel,$id,'-'),
|
|
|
+ unless ($option eq "silent");
|
|
|
+ # Put the last- alert instead of existing one.
|
|
|
+ $ACKS[$id] = pop @ACKS;
|
|
|
+ return ($i,'-');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
##########################################################################
|
|
@@ -540,44 +604,48 @@ sub event_privmsg($$$$) {
|
|
|
Irssi::print(">> $arg - $nagios_ack_channel - $target");
|
|
|
return if $target ne $nagios_ack_channel ;
|
|
|
|
|
|
- # !nagios [*] :
|
|
|
-
|
|
|
- # !nagios list [*] :
|
|
|
if ($arg =~ /^refresh ?(.*)/i) {
|
|
|
$arg=$1;
|
|
|
Irssi::print(">> $arg");
|
|
|
- if ($arg =~ /^silent/) {
|
|
|
+ if ($arg =~ /\bclear\b/) {
|
|
|
+ $server->command ( "msg ".$nagios_ack_channel." Local alerts cleared" );
|
|
|
+ @ACKS=();
|
|
|
+ }
|
|
|
+ if ($arg =~ /\bsilent\b/) {
|
|
|
nagios_query_status("silent");
|
|
|
} else {
|
|
|
nagios_query_status("");
|
|
|
$server->command ( "msg ".$nagios_ack_channel.
|
|
|
- 'Refresh nagios. Use "silent" keyword to disable display.');
|
|
|
+ ' Refresh nagios. Use "silent" keyword to disable display.');
|
|
|
}
|
|
|
$server->command ( "msg ".$nagios_ack_channel.
|
|
|
" ".scalar @ACKS." alertes");
|
|
|
}
|
|
|
elsif ($arg =~ /^list ?(.*)/i) {
|
|
|
- $server->command ( "msg ".$nagios_ack_channel.
|
|
|
- " ".scalar @ACKS." alertes");
|
|
|
my $i=0;
|
|
|
|
|
|
# Do you search on pattern (whole database), or a list (reduced database) ?
|
|
|
my $grepto;
|
|
|
my $motif=$1;
|
|
|
- $motif="" unless defined($motif) ;
|
|
|
my $search_unack=0;
|
|
|
+
|
|
|
+ $server->command ( "msg ".$nagios_ack_channel.
|
|
|
+ " ".scalar @ACKS." alertes");
|
|
|
+ $motif="" unless defined($motif) ;
|
|
|
+ $motif="0\$" if $motif =~ /^ack$/i;
|
|
|
+ $motif="1\$" if $motif =~ /^unack$/i;
|
|
|
$search_unack="1" if $motif eq "";
|
|
|
+ Irssi::print(">> List : $motif");
|
|
|
|
|
|
foreach $K (@ACKS) {
|
|
|
- my $grepto="@$K";
|
|
|
+ my $grepto="#$i @$K";
|
|
|
# just display alert fields, with colors.
|
|
|
# See ACKS fields organization
|
|
|
# Field 5 is "Alert has been previously acknowledged"
|
|
|
- $server->command ( "msg ".$nagios_ack_channel.
|
|
|
- " ". time2date ($K->[4])." ".
|
|
|
- format_alert_id(' ', $i, $K->[2], $K->[5]).
|
|
|
- " ". $state_to_color->{$K->[2]}.$K->[0]."/".$K->[1].$C{Z}.
|
|
|
- " / $K->[2]".($K->[5]?" Acked":"")." : $K->[3]"
|
|
|
+ # display_alert($server,$chan,$date,$prefix,$state,$acked,$hostname,$service,$output)
|
|
|
+ display_alert($server,$nagios_ack_channel,$i,' '
|
|
|
+ #format_alert_id(' ', $i, $K->[2], $K->[5]),
|
|
|
+ #$K->[2],$K->[5],$K->[0],$K->[1],$K->[3]
|
|
|
) if ( ($grepto =~ /$motif/i) || ($search_unack && ($K->[5]==0)) );
|
|
|
# Display only if : $motif is found, or $motif is empty, and alert is unack
|
|
|
$i++;
|
|
@@ -585,7 +653,7 @@ sub event_privmsg($$$$) {
|
|
|
}
|
|
|
elsif ($arg =~ /^help/i) {
|
|
|
$server->command ( "msg ".$nagios_ack_channel.
|
|
|
- " !nagios list [pattern] : liste des alertes nagios reçues ici");
|
|
|
+ " !nagios list [pattern] [ack/unack] : liste des alertes nagios reçues ici");
|
|
|
$server->command ( "msg ".$nagios_ack_channel.
|
|
|
" !nagios help : l'aide");
|
|
|
$server->command ( "msg ".$nagios_ack_channel.
|
|
@@ -593,11 +661,23 @@ sub event_privmsg($$$$) {
|
|
|
$server->command ( "msg ".$nagios_ack_channel.
|
|
|
" !nagios check <#ALERTE> TODO : recheck une alerte donnée (service/host)");
|
|
|
$server->command ( "msg ".$nagios_ack_channel.
|
|
|
- " !nagios refresh [silent] : interroge le nagios pour avoir la liste de toutes les alertes");
|
|
|
+ " !nagios refresh [silent] [clear] : interroge le nagios pour avoir la liste de toutes les alertes");
|
|
|
+ $server->command ( "msg ".$nagios_ack_channel.
|
|
|
+ " si le mot clef 'clear' est ajouté, il purge les alertes locales");
|
|
|
+ $server->command ( "msg ".$nagios_ack_channel.
|
|
|
+ " [!+00]/00 le numéro et le statut d'alerte sont résumés dans le premier symbole :");
|
|
|
+ $server->command ( "msg ".$nagios_ack_channel.
|
|
|
+ " [ ACK STATUT NUM ] / TOTAL un '!' signifie 'nouvelle alerte, unack'. le \"statut\" peut être de la forme :");
|
|
|
+ $server->command ( "msg ".$nagios_ack_channel.
|
|
|
+ " ! : alerte identique. C : niveau d'alerte changé. - : alerte terminée. ? : 'feu vert' inconnu. + : nouvelle alerte");
|
|
|
+ $server->command ( "msg ".$nagios_ack_channel.
|
|
|
+ " ");
|
|
|
} elsif ( $arg =~ /^check ?(.*)/i ){
|
|
|
nagios_check($1,$server,undef);
|
|
|
} elsif ( $arg =~ /^ack ?(.*)/i ){
|
|
|
nagios_ack($1,$server,undef);
|
|
|
+ $server->command ( "msg ".$nagios_ack_channel.
|
|
|
+ " ".scalar @ACKS." alertes");
|
|
|
} else {
|
|
|
$server->command ( "msg ".$nagios_ack_channel.
|
|
|
" ".scalar @ACKS." alertes");
|
|
@@ -633,15 +713,3 @@ print CLIENTCRAP "%B>>%n $IRSSI{name} $VERSION (by $IRSSI{authors}) loaded";
|
|
|
|
|
|
|
|
|
1;
|
|
|
-
|
|
|
-##########################################################################
|
|
|
-# References #############################################################
|
|
|
-##########################################################################
|
|
|
-# REFERENCES
|
|
|
-# ----------
|
|
|
-#
|
|
|
-# This script is mainly adapted from 3 other scripts related to nagios :
|
|
|
-#
|
|
|
-# https://github.com/zorkian/nagios-irc-bot/blob/master/nagiosirc.pl
|
|
|
-# http://www.update.uu.se/~zrajm/programs/irssi-scripts/fifo_remote.pl-0.5
|
|
|
-# https://github.com/mikegrb/irssi-scripts/blob/master/nagios-ack.pl
|