Browse Source

Merge branch 'master' of ssh://code.ffdn.org:55555/asr/nagios-irssi

Gaétan RYCKEBOER 10 years ago
parent
commit
abb2354d23
8 changed files with 204 additions and 111 deletions
  1. 22 0
      CHANGELOG
  2. 3 2
      INSTALL
  3. 3 5
      README.md
  4. 167 99
      bin/nagios-fifo.pl
  5. 3 3
      bin/tweet.pl
  6. 1 1
      contrib/debian/nagbot.dirs
  7. 3 0
      contrib/debian/nagbot.links
  8. 2 1
      etc/config.template

+ 22 - 0
CHANGELOG

@@ -0,0 +1,22 @@
+v0.1.0 - 29-09-2014
+asr - initial design : simple log parser from nagios log
+      built from 2 nagios bots, and a fifo irssi command bot.
+
+v0.2.0 - 04-10-2014
+asr - Add function to load alerts from nagios mk_livestatus
+
+v0.2.1 - 05-10-2014
+asr - Documentation, cosmetic, and git import
+
+v0.2.2 - 06-10-2014
+asr - Code rewriting, functiOn name cleansing
+
+v0.3.0 - 08-10-2014
+asr - Add ability to check patterns accros acked or unacked alerts
+
+v0.4.0 - 09-10-2014
+asr - Add ACK command to acknowledge alerts. _Will_break_configuration_file_
+      (mixed names between nagios_live, added, and nagios_command, previously refering
+      to livestatus fifo today renames nagios_live)
+asr - Change HOST ALIAS to HOST NAME for nagios services. _will_break_previous_nagios_configuration_file_
+

+ 3 - 2
INSTALL

@@ -3,7 +3,8 @@ Quick install in 3 words
 * Check the symlinks
 * put nagios-irssi.pl into /usr/local/bin
 * modify config file (to be put on ~.irssi/) to match your configuration
-* put scripts .pl into ~/.irssi/scripts/autorun
+* put scripts .pl into ~/.irssi/scripts/
+* put links to ~/.irssi/scripts/ to ~/.irssi/scripts/autorun
 
 Add to nagios commands :
 # 'notify-host-by-irssi' command definition
@@ -14,7 +15,7 @@ define command{
 
 define command{
         command_name    notify-service-by-irssi
-        command_line    /usr/local/bin/nagios-irssi.pl $CONTACTPAGER$ "[$LASTSERVICESTATECHANGE$] SERVICE ALERT: $HOSTALIAS$@$SERVICEDESC$@$SERVICESTATE$@HARD@1@$SERVICEOUTPUT$"
+        command_line    /usr/local/bin/nagios-irssi.pl $CONTACTPAGER$ "[$LASTSERVICESTATECHANGE$] SERVICE ALERT: $HOSTNAME$@$SERVICEDESC$@$SERVICESTATE$@HARD@1@$SERVICEOUTPUT$"
 }
 
 Add to /etc/nagios3/<placeholder>.cfg

+ 3 - 5
README.md

@@ -32,12 +32,10 @@ Using the bots
 
 Commands allowed by *nagios-fifo.pl* / Nagios module :
 The nagios bot is designed to work with nagios notifications, via commands.cfg configuration file.
-- `!nagios list [PATTERN]` : list of received alerts
-- `!nagios list` : list of received alerts
 - `!nagios help` : l'aide
-- `!nagios ack <#ALERT> <message>` : ACK the alert
-- `!nagios check <#ALERT>` : recheck any alert (service/host)
-- `!nagios refresh [silent]` : request nagios livestatus and import all unack alerts
+- `!nagios ack #<ALERT> <message>` : ACK the alert
+- `!nagios check <#ALERT>`(todo) : recheck any alert (service/host)
+- `!nagios refresh [silent] [clear]` : request nagios livestatus and import all unack alerts ; optionnaly clear local alerts cache (bot, not nagios)
 
 Commands allowed by *tc-14.pl* / Dumb module :
 - `!status`      to have a look on inner variables / structures (particularly for the bingo module)

+ 167 - 99
bin/nagios-fifo.pl

@@ -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

+ 3 - 3
bin/tweet.pl

@@ -11,12 +11,12 @@ use POSIX qw(strftime);
 
 use LWP::UserAgent;
 
-$VERSION = "1.2.2";
+$VERSION = "1.3.0";
 
 %IRSSI = (
     author => 'pleia2',
     contact => 'lyz@princessleia.com ',
-    name => 'TC-14',
+    name => 'TC-14 Tweet',
     description => 'Protocol Droid, dedicated to Lautre.roots',
     license => 'GNU GPL v2 or later',
     url => 'http://www.lautre.net/',
@@ -45,7 +45,7 @@ Irssi::settings_add_str($IRSSI{name},          # default fifo_remote_file
 Irssi::settings_add_str($IRSSI{name},          # default fifo_remote_file
     'tc_changefile', '/home/tc-14/var/last.log');     #
 
-my @chan=split m/ /, Irssi::settings_get_str("tc_chan");
+my @chan=split m/ /, Irssi::settings_get_str("tc_chans");
 my @admin_chan=split m/ /, Irssi::settings_get_str("tc_admins");
 my $change=Irssi::settings_get_str("tc_changefile");
 

+ 1 - 1
contrib/debian/nagbot.dirs

@@ -1,3 +1,3 @@
-var/lib/nagbot/.irssi/
+var/lib/nagbot/.irssi/scripts/autorun/
 etc/nagbot/
 usr/local/bin/

+ 3 - 0
contrib/debian/nagbot.links

@@ -1 +1,4 @@
 etc/nagbot/config var/lib/nagbot/.irssi/config
+usr/local/bin/nagios-fifo.pl var/lib/nagbot/.irssi/scripts/nagios-fifo.pl
+usr/local/bin/tc-14.pl var/lib/nagbot/.irssi/scripts/tc-14.pl
+usr/local/bin/tweet.pl var/lib/nagbot/.irssi/scripts/tweet.pl

+ 2 - 1
etc/config.template

@@ -283,7 +283,8 @@ settings = {
     autorejoin_channels = "#main_channel";
     nagios_ack_channel = "#main_channel"
     nagios_ack_nick = ""
-    nagios_command = "/var/lib/nagios3/rw/live"
+    nagios_command = "/var/lib/nagios3/rw/nagios.cmd"
+    nagios_live = "/var/lib/nagios3/rw/live"
     fifo_remote_file = "/home/tc-14/var/nagios-fifo"
 }
   };