Browse Source

(maint) Just a whitespace cleanup commit

Sebastien Badia 10 years ago
parent
commit
9bb81aaea1
8 changed files with 47 additions and 47 deletions
  1. 1 1
      LICENSE
  2. 7 7
      README.md
  3. 23 23
      bin/nagios-fifo.pl
  4. 1 1
      bin/tailgrep
  5. 8 8
      bin/tc-14.pl
  6. 4 4
      etc/config.template
  7. 2 2
      var/fortunes
  8. 1 1
      var/quotes

+ 1 - 1
LICENSE

@@ -671,4 +671,4 @@ into proprietary programs.  If your program is a subroutine library, you
 may consider it more useful to permit linking proprietary applications with
 may consider it more useful to permit linking proprietary applications with
 the library.  If this is what you want to do, use the GNU Lesser General
 the library.  If this is what you want to do, use the GNU Lesser General
 Public License instead of this License.  But first, please read
 Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ 7 - 7
README.md

@@ -3,7 +3,7 @@ nagios-fifo
 
 
 IRSSI BOT to handle nagios/irssi communication.
 IRSSI BOT to handle nagios/irssi communication.
 
 
-Presentation 
+Presentation
 ------------
 ------------
 
 
 To ease the use of the bot configuration, I use to link different
 To ease the use of the bot configuration, I use to link different
@@ -17,15 +17,15 @@ respective irssi directories :
 5. symlink it to etc/config.local
 5. symlink it to etc/config.local
 6. start "screen irssi  "
 6. start "screen irssi  "
 
 
-How does it works 
+How does it works
 ------------
 ------------
 
 
 The bot is made of 3 scripts :
 The bot is made of 3 scripts :
 - nagios bot ;
 - nagios bot ;
 - tweet.pl made to tweet, take care of a changelog ;
 - tweet.pl made to tweet, take care of a changelog ;
-- tc-14 a simple talkeng droid.  
+- tc-14 a simple talkeng droid.
 
 
-all are designed to work standalone.  
+all are designed to work standalone.
 
 
 Using the bots
 Using the bots
 ---------
 ---------
@@ -36,7 +36,7 @@ The nagios bot is designed to work with nagios notifications, via commands.cfg c
 - `!nagios help` : l'aide
 - `!nagios help` : l'aide
 - `!nagios ack <#ALERT> <message>` : ACK the alert
 - `!nagios ack <#ALERT> <message>` : ACK the alert
 - `!nagios check <#ALERT>` : recheck any alert (service/host)
 - `!nagios check <#ALERT>` : recheck any alert (service/host)
-- `!nagios refresh [silent]` : request nagios livestatus and import all unack alerts  
+- `!nagios refresh [silent]` : request nagios livestatus and import all unack alerts
 
 
 Commands allowed by *tc-14.pl* / Dumb module :
 Commands allowed by *tc-14.pl* / Dumb module :
 - `!status`      to have a look on inner variables / structures (particularly for the bingo module)
 - `!status`      to have a look on inner variables / structures (particularly for the bingo module)
@@ -47,8 +47,8 @@ Commands allowed by *tc-14.pl* / Dumb module :
   * any french/flemish/irish beer ;
   * any french/flemish/irish beer ;
   * any animal name ;
   * any animal name ;
   * some pedant words, used to check a bingo business card
   * some pedant words, used to check a bingo business card
-  * his own name  
-  
+  * his own name
+
 Commands allowed by *tweet.pl* / admin module :
 Commands allowed by *tweet.pl* / admin module :
 - `!tweet`        : tweet a tweet, on twitter and identi.ca (twitter module broken, to be redisigned)
 - `!tweet`        : tweet a tweet, on twitter and identi.ca (twitter module broken, to be redisigned)
 - `!tweet last`   : what was last tweet ?
 - `!tweet last`   : what was last tweet ?

+ 23 - 23
bin/nagios-fifo.pl

@@ -89,20 +89,20 @@ my %C = (
 	Ma => "\x0313", #	12. Light Blue (Royal)
 	Ma => "\x0313", #	12. Light Blue (Royal)
 	Gr => "\x0314", #	13. Pink (Light Purple) (Fuchsia)
 	Gr => "\x0314", #	13. Pink (Light Purple) (Fuchsia)
 	W  => "\x0315", #	14. Grey
 	W  => "\x0315", #	14. Grey
-                        #	15. Light Grey (Silver)             
+                        #	15. Light Grey (Silver)
 	Z => "\x03",
 	Z => "\x03",
 );
 );
 
 
 # Numeric to string conversion of nagios status
 # Numeric to string conversion of nagios status
 # 0..4   : hosts
 # 0..4   : hosts
 # 10..14 : services
 # 10..14 : services
-my @NagStates = qw/UP DOWN WARNING UNKNOWN .. .. .. .. .. .. 
+my @NagStates = qw/UP DOWN WARNING UNKNOWN .. .. .. .. .. ..
                   OK WARNING CRITICAL UNKNOWN/;
                   OK WARNING CRITICAL UNKNOWN/;
 
 
 #    Bold: U+0002 ("0x02") — Example: ^Bold Text^ whereas ^ represents the control character.
 #    Bold: U+0002 ("0x02") — Example: ^Bold Text^ whereas ^ represents the control character.
 #    Italics: U+001D ("0x1D") — Example: ^Italicized Text^ whereas ^ represents the control character.
 #    Italics: U+001D ("0x1D") — Example: ^Italicized Text^ whereas ^ represents the control character.
 #    Underline: U+001F ("0x1F") — Example: ^Underlined Text^ whereas ^ represents the control character.
 #    Underline: U+001F ("0x1F") — Example: ^Underlined Text^ whereas ^ represents the control character.
-#    The control character used for color is U+0003 ("0x03"). 
+#    The control character used for color is U+0003 ("0x03").
 
 
 my $state_to_color = {
 my $state_to_color = {
 	OK => $C{G},
 	OK => $C{G},
@@ -124,7 +124,7 @@ my ($d,$type,$host,$service,$state,$output);
 my ( $host, $svc, $state, $msg, $id );
 my ( $host, $svc, $state, $msg, $id );
 
 
 my ($server, $msg, $nick, $addr, $target);
 my ($server, $msg, $nick, $addr, $target);
-my ( $param, $server, $window ); 
+my ( $param, $server, $window );
 my (@issue, $issue);
 my (@issue, $issue);
 
 
 #my $state_to_color = { OK => '', UP => '', WARNING => '', CRITICAL => '', DOWN => '', UNKNOWN => '' };
 #my $state_to_color = { OK => '', UP => '', WARNING => '', CRITICAL => '', DOWN => '', UNKNOWN => '' };
@@ -133,7 +133,7 @@ my (@issue, $issue);
 
 
 my $last_alert;
 my $last_alert;
 
 
-my $DEBUG=Irssi::settings_get_str("nagios_ack_channel"); 
+my $DEBUG=Irssi::settings_get_str("nagios_ack_channel");
 
 
 # Simple subs ############################################################
 # Simple subs ############################################################
 sub TRUE()   { 1  }                            # some constants [perlsyn(1)
 sub TRUE()   { 1  }                            # some constants [perlsyn(1)
@@ -153,7 +153,7 @@ sub time2date($) {
 # where is the memory leak.
 # where is the memory leak.
 
 
 # Four unused subs. Still there to be implemented later
 # Four unused subs. Still there to be implemented later
-sub parse_status(); 
+sub parse_status();
 sub nagios_ack($$$);
 sub nagios_ack($$$);
 sub nagios_check($$$);
 sub nagios_check($$$);
 sub nagios_inject;
 sub nagios_inject;
@@ -216,9 +216,9 @@ sub event_privmsg ($$$$);
 
 
 # REFERENCES
 # REFERENCES
 # ----------
 # ----------
-# 
+#
 # This script is mainly adapted from 3 other scripts related to nagios :
 # This script is mainly adapted from 3 other scripts related to nagios :
-# 
+#
 # https://github.com/zorkian/nagios-irc-bot/blob/master/nagiosirc.pl
 # 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
 # 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
 # https://github.com/mikegrb/irssi-scripts/blob/master/nagios-ack.pl
@@ -226,7 +226,7 @@ sub event_privmsg ($$$$);
 ##########################################################################
 ##########################################################################
 # CODE ###################################################################
 # CODE ###################################################################
 ##########################################################################
 ##########################################################################
- 
+
 ##########################################################################
 ##########################################################################
 # Part B : user Actions ##################################################
 # Part B : user Actions ##################################################
 
 
@@ -294,11 +294,11 @@ sub insert_alert($$$$$) {
 			if (($ACKS[$i]->[0] eq $host) && ($ACKS[$i]->[1] eq $svc)) {
 			if (($ACKS[$i]->[0] eq $host) && ($ACKS[$i]->[1] eq $svc)) {
 				$ACKS[$i]->[4]=$d;
 				$ACKS[$i]->[4]=$d;
 				Irssi::print(">> found $i");
 				Irssi::print(">> found $i");
-				if ($ACKS[$i]->[2] ne $state) { 
+				if ($ACKS[$i]->[2] ne $state) {
 					# Same alert, but different level
 					# Same alert, but different level
-					$ACKS[$i]->[2]=$state; 
+					$ACKS[$i]->[2]=$state;
 					return format_alert_id('C', $i, $state);
 					return format_alert_id('C', $i, $state);
-				} else { 
+				} else {
 					# Same alert
 					# Same alert
 					return format_alert_id('!', $i, $state);
 					return format_alert_id('!', $i, $state);
 					# No need to display...
 					# No need to display...
@@ -365,7 +365,7 @@ sub open_fifo($) {                             # [2004-08-14]
         fileno($FIFO_HANDLE), INPUT_READ,      #     there's input in the pipe
         fileno($FIFO_HANDLE), INPUT_READ,      #     there's input in the pipe
         \&read_fifo, '';                       #
         \&read_fifo, '';                       #
     return 1;                                  #
     return 1;                                  #
-}             
+}
 
 
 # read from fifo
 # read from fifo
 # (called by fifo input signal)
 # (called by fifo input signal)
@@ -383,7 +383,7 @@ sub read_fifo() {                              # [2004-08-14]
         # TODO: Is the above re-opening of fifo really necessary? -- If not
         # TODO: Is the above re-opening of fifo really necessary? -- If not
         # invoked here `read_fifo' is called repeatedly, even though no input
         # invoked here `read_fifo' is called repeatedly, even though no input
         # is to be found on the fifo. (This seems a waste of resources to me.)
         # is to be found on the fifo. (This seems a waste of resources to me.)
-}                 
+}
 
 
 # create named fifo and open it for input
 # create named fifo and open it for input
 # (called on script load and fifo name changes)
 # (called on script load and fifo name changes)
@@ -391,7 +391,7 @@ sub create_fifo($) {                           # [2004-08-14]
     my ($new_fifo) = @_;                       #   get args
     my ($new_fifo) = @_;                       #   get args
     if (not -p $new_fifo) {                    #   create fifo if non-existant
     if (not -p $new_fifo) {                    #   create fifo if non-existant
         if (system "mkfifo '$new_fifo' &>/dev/null" and
         if (system "mkfifo '$new_fifo' &>/dev/null" and
-            system "chmod 777  '$new_fifo' &>/dev/null" and 
+            system "chmod 777  '$new_fifo' &>/dev/null" and
             system "mknod  '$new_fifo' &>/dev/null"){
             system "mknod  '$new_fifo' &>/dev/null"){
             print CLIENTERROR "`mkfifo' failed -- could not create named pipe";
             print CLIENTERROR "`mkfifo' failed -- could not create named pipe";
                 # TODO: capture `mkfifo's stderr and show that here
                 # TODO: capture `mkfifo's stderr and show that here
@@ -408,7 +408,7 @@ sub create_fifo($) {                           # [2004-08-14]
 sub nagios_query_status($){
 sub nagios_query_status($){
 	# 1412478149;hyppocampe;apt;2;CRITICAL : unknown: qemu-utils, qemu-kvm, qemu-keymaps
 	# 1412478149;hyppocampe;apt;2;CRITICAL : unknown: qemu-utils, qemu-kvm, qemu-keymaps
 	my ($option)=@_;
 	my ($option)=@_;
-	my @unixcat; 
+	my @unixcat;
 	my $unixline;
 	my $unixline;
 	$nagioscmd = Irssi::settings_get_str("nagios_command");
 	$nagioscmd = Irssi::settings_get_str("nagios_command");
         foreach $unixline ( `echo "GET services
         foreach $unixline ( `echo "GET services
@@ -453,7 +453,7 @@ sub parse_nagios_log($){
 	# HOST ########################
 	# HOST ########################
 		($d,$host,$state,$output)=@match;
 		($d,$host,$state,$output)=@match;
 		handle_alert($option,$d,"HOST",$host,$state,$output,$service);
 		handle_alert($option,$d,"HOST",$host,$state,$output,$service);
-		
+
 	# SERVICE #####################
 	# SERVICE #####################
 	} elsif (@match=$status_line =~ /\[?(\d+)\]? (\w+) ALERT: ([^;@]+)[@;]([^;@]+)[@;]([^;@]+)[@;]HARD[@;][^;@]*[@;](.+)/) {
 	} elsif (@match=$status_line =~ /\[?(\d+)\]? (\w+) ALERT: ([^;@]+)[@;]([^;@]+)[@;]([^;@]+)[@;]HARD[@;][^;@]*[@;](.+)/) {
 		($d,$type,$host,$service,$state,$output)=@match;
 		($d,$type,$host,$service,$state,$output)=@match;
@@ -486,7 +486,7 @@ sub handle_alert($$$$$$$) { # $d,$type,$host,$state,$output,$service
 	# HOST or SERVICE ?
 	# HOST or SERVICE ?
 	$id = insert_alert($host,$service,$state,$output,$d);
 	$id = insert_alert($host,$service,$state,$output,$d);
 	$msg = "$id".$state_to_color->{$state} . "$host:$service".$C{Z}." is $state : $output";
 	$msg = "$id".$state_to_color->{$state} . "$host:$service".$C{Z}." is $state : $output";
-	#Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);		
+	#Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);
 
 
 	$last_alert="NAGIOS - $host/$service is $state";
 	$last_alert="NAGIOS - $host/$service is $state";
 	$d=time2date($d);
 	$d=time2date($d);
@@ -496,7 +496,7 @@ sub handle_alert($$$$$$$) { # $d,$type,$host,$state,$output,$service
 	$nagios_ack_channel= Irssi::settings_get_str("nagios_ack_channel");
 	$nagios_ack_channel= Irssi::settings_get_str("nagios_ack_channel");
 	Irssi::active_server->command('MSG ' . $nagios_ack_channel .
 	Irssi::active_server->command('MSG ' . $nagios_ack_channel .
 		" ".$message) unless ($option eq "silent");
 		" ".$message) unless ($option eq "silent");
-	#		Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);		
+	#		Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);
 }
 }
 
 
 ##########################################################################
 ##########################################################################
@@ -530,8 +530,8 @@ sub event_privmsg($$$$) {
 		return if $target ne $nagios_ack_channel ;
 		return if $target ne $nagios_ack_channel ;
 
 
 		# !nagios [*] :
 		# !nagios [*] :
-		
-		# !nagios list [*] : 
+
+		# !nagios list [*] :
 		if ($arg =~ /^refresh ?(.*)/i) {
 		if ($arg =~ /^refresh ?(.*)/i) {
 			$arg=$1;
 			$arg=$1;
 			Irssi::print(">> $arg");
 			Irssi::print(">> $arg");
@@ -610,9 +610,9 @@ print CLIENTCRAP "%B>>%n $IRSSI{name} $VERSION (by $IRSSI{authors}) loaded";
 ##########################################################################
 ##########################################################################
 # REFERENCES
 # REFERENCES
 # ----------
 # ----------
-# 
+#
 # This script is mainly adapted from 3 other scripts related to nagios :
 # This script is mainly adapted from 3 other scripts related to nagios :
-# 
+#
 # https://github.com/zorkian/nagios-irc-bot/blob/master/nagiosirc.pl
 # 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
 # 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
 # https://github.com/mikegrb/irssi-scripts/blob/master/nagios-ack.pl

+ 1 - 1
bin/tailgrep

@@ -2,4 +2,4 @@
 filename=$1
 filename=$1
 shift
 shift
 #echo "parametres : $@"
 #echo "parametres : $@"
-[ "$1" != "" ] && cat $filename | grep $* | tail 
+[ "$1" != "" ] && cat $filename | grep $* | tail

+ 8 - 8
bin/tc-14.pl

@@ -7,7 +7,7 @@
 use Irssi;
 use Irssi;
 
 
 use vars qw($VERSION %IRSSI);
 use vars qw($VERSION %IRSSI);
-use POSIX qw(strftime); 
+use POSIX qw(strftime);
 
 
 use LWP::UserAgent;
 use LWP::UserAgent;
 
 
@@ -123,7 +123,7 @@ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
 			$warndate=time();
 			$warndate=time();
 		}
 		}
 	}
 	}
-	
+
 	my $admin=0;
 	my $admin=0;
 
 
 	if (in_array(@chan,$target) || in_array(@admin_chan,$target))
 	if (in_array(@chan,$target) || in_array(@admin_chan,$target))
@@ -153,11 +153,11 @@ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
 		if ( $text =~ /^tc-14:/i ) {
 		if ( $text =~ /^tc-14:/i ) {
 			$clocky="J'cause pas aux cons, ca les instruit.";
 			$clocky="J'cause pas aux cons, ca les instruit.";
 			send_server("msg", $target, $nick, "$clocky");
 			send_server("msg", $target, $nick, "$clocky");
-		}	
+		}
 		elsif ( $text =~ /^tc-14/i ) {
 		elsif ( $text =~ /^tc-14/i ) {
 		   $clocky = $clockok[rand @clockok];
 		   $clocky = $clockok[rand @clockok];
 			send_server("msg", $target, $nick, "$nick: $clocky");
 			send_server("msg", $target, $nick, "$nick: $clocky");
-		}	
+		}
 		elsif ( $text =~ /^!password( .+)?/ ) {
 		elsif ( $text =~ /^!password( .+)?/ ) {
 			my $password ="";
 			my $password ="";
 			$length = $1;
 			$length = $1;
@@ -197,18 +197,18 @@ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
 					 $last=$nick;
 					 $last=$nick;
 					 $clocky = "Coche la case.";
 					 $clocky = "Coche la case.";
 					 if ($bingovar{$1} eq "coche") {$clocky = "deja coche"}
 					 if ($bingovar{$1} eq "coche") {$clocky = "deja coche"}
-						 else { 
+						 else {
 							$bingovar{$1} = "coche";
 							$bingovar{$1} = "coche";
 							$bingo++;
 							$bingo++;
 						 }
 						 }
 					 $server->command ( "action $target $clocky" );
 					 $server->command ( "action $target $clocky" );
-					 if ( $bingo > 3 ) { 
+					 if ( $bingo > 3 ) {
 					   undef(%bingovar);
 					   undef(%bingovar);
-					   $bingo=0; $clocky="FOUTAISES !"; 
+					   $bingo=0; $clocky="FOUTAISES !";
 					   $server->command ( "msg $target $clocky" );
 					   $server->command ( "msg $target $clocky" );
 					   $warn=$nick;
 					   $warn=$nick;
 					 }
 					 }
-				} 
+				}
 			}
 			}
 		}
 		}
 		elsif ( $text =~ /orval|landelin|kwak|duvel|guinness|chimay|bi..?re|leffe/i ) {
 		elsif ( $text =~ /orval|landelin|kwak|duvel|guinness|chimay|bi..?re|leffe/i ) {

+ 4 - 4
etc/config.template

@@ -24,13 +24,13 @@ servers = (
     use_ssl = "no";
     use_ssl = "no";
     autosendcmd = "/^msg C nick IDENTIFY mybotpassword";
     autosendcmd = "/^msg C nick IDENTIFY mybotpassword";
   },
   },
-  { 
+  {
     address = "irc.undernet.org";
     address = "irc.undernet.org";
     chatnet = "Undernet";
     chatnet = "Undernet";
     port = "6667";
     port = "6667";
   },
   },
   { address = "irc.dal.net"; chatnet = "DALnet"; port = "6667"; },
   { address = "irc.dal.net"; chatnet = "DALnet"; port = "6667"; },
-  { 
+  {
     address = "irc.quakenet.org";
     address = "irc.quakenet.org";
     chatnet = "QuakeNet";
     chatnet = "QuakeNet";
     port = "6667";
     port = "6667";
@@ -46,7 +46,7 @@ chatnets = {
     max_whois = "4";
     max_whois = "4";
     max_query_chans = "5";
     max_query_chans = "5";
   };
   };
-  EFNet = { 
+  EFNet = {
     type = "IRC";
     type = "IRC";
     max_kicks = "4";
     max_kicks = "4";
     max_msgs = "3";
     max_msgs = "3";
@@ -304,7 +304,7 @@ conversions = {
 };
 };
 hilights = ( { text = "asr"; nick = "yes"; word = "yes"; } );
 hilights = ( { text = "asr"; nick = "yes"; word = "yes"; } );
 windows = {
 windows = {
-  1 = { 
+  1 = {
     immortal = "yes";
     immortal = "yes";
     name = "(status)";
     name = "(status)";
     level = "ALL";
     level = "ALL";

+ 2 - 2
var/fortunes

@@ -504,5 +504,5 @@ You don't know the power of the dark side [VADOR 7925] I feel this lack of faith
 %
 %
 « Si quelqun a compris quoi que ce soit à ce que je viens de dire, c'est que je me suis mal exprimé. » -- Alan Greenspan, économiste
 « Si quelqun a compris quoi que ce soit à ce que je viens de dire, c'est que je me suis mal exprimé. » -- Alan Greenspan, économiste
 %
 %
-Pour cause d'indiférence générale, demain est annulé. -- Anonyme su un mur 
-%
+Pour cause d'indiférence générale, demain est annulé. -- Anonyme su un mur
+%

+ 1 - 1
var/quotes

@@ -54,7 +54,7 @@
 %
 %
  Sir, I don't know where your ship learned to communicate, but it has the most peculiar dialect.
  Sir, I don't know where your ship learned to communicate, but it has the most peculiar dialect.
 %
 %
- [about Lando] 
+ [about Lando]
 %
 %
  Don't worry about Master Luke. I'm sure he'll be all right. He's quite clever, you know... for a human being.
  Don't worry about Master Luke. I'm sure he'll be all right. He's quite clever, you know... for a human being.
 %
 %