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
 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
-<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.
 
-Presentation 
+Presentation
 ------------
 
 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
 6. start "screen irssi  "
 
-How does it works 
+How does it works
 ------------
 
 The bot is made of 3 scripts :
 - nagios bot ;
 - 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
 ---------
@@ -36,7 +36,7 @@ The nagios bot is designed to work with nagios notifications, via commands.cfg c
 - `!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 refresh [silent]` : request nagios livestatus and import all unack alerts
 
 Commands allowed by *tc-14.pl* / Dumb 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 animal name ;
   * some pedant words, used to check a bingo business card
-  * his own name  
-  
+  * his own name
+
 Commands allowed by *tweet.pl* / admin module :
 - `!tweet`        : tweet a tweet, on twitter and identi.ca (twitter module broken, to be redisigned)
 - `!tweet last`   : what was last tweet ?

+ 23 - 23
bin/nagios-fifo.pl

@@ -89,20 +89,20 @@ my %C = (
 	Ma => "\x0313", #	12. Light Blue (Royal)
 	Gr => "\x0314", #	13. Pink (Light Purple) (Fuchsia)
 	W  => "\x0315", #	14. Grey
-                        #	15. Light Grey (Silver)             
+                        #	15. Light Grey (Silver)
 	Z => "\x03",
 );
 
 # Numeric to string conversion of nagios status
 # 0..4   : hosts
 # 10..14 : services
-my @NagStates = qw/UP DOWN WARNING UNKNOWN .. .. .. .. .. .. 
+my @NagStates = qw/UP DOWN WARNING UNKNOWN .. .. .. .. .. ..
                   OK WARNING CRITICAL UNKNOWN/;
 
 #    Bold: U+0002 ("0x02") — Example: ^Bold 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.
-#    The control character used for color is U+0003 ("0x03"). 
+#    The control character used for color is U+0003 ("0x03").
 
 my $state_to_color = {
 	OK => $C{G},
@@ -124,7 +124,7 @@ my ($d,$type,$host,$service,$state,$output);
 my ( $host, $svc, $state, $msg, $id );
 
 my ($server, $msg, $nick, $addr, $target);
-my ( $param, $server, $window ); 
+my ( $param, $server, $window );
 my (@issue, $issue);
 
 #my $state_to_color = { OK => '', UP => '', WARNING => '', CRITICAL => '', DOWN => '', UNKNOWN => '' };
@@ -133,7 +133,7 @@ my (@issue, $issue);
 
 my $last_alert;
 
-my $DEBUG=Irssi::settings_get_str("nagios_ack_channel"); 
+my $DEBUG=Irssi::settings_get_str("nagios_ack_channel");
 
 # Simple subs ############################################################
 sub TRUE()   { 1  }                            # some constants [perlsyn(1)
@@ -153,7 +153,7 @@ sub time2date($) {
 # where is the memory leak.
 
 # Four unused subs. Still there to be implemented later
-sub parse_status(); 
+sub parse_status();
 sub nagios_ack($$$);
 sub nagios_check($$$);
 sub nagios_inject;
@@ -216,9 +216,9 @@ sub event_privmsg ($$$$);
 
 # 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
@@ -226,7 +226,7 @@ sub event_privmsg ($$$$);
 ##########################################################################
 # CODE ###################################################################
 ##########################################################################
- 
+
 ##########################################################################
 # Part B : user Actions ##################################################
 
@@ -294,11 +294,11 @@ sub insert_alert($$$$$) {
 			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) { 
+				if ($ACKS[$i]->[2] ne $state) {
 					# Same alert, but different level
-					$ACKS[$i]->[2]=$state; 
+					$ACKS[$i]->[2]=$state;
 					return format_alert_id('C', $i, $state);
-				} else { 
+				} else {
 					# Same alert
 					return format_alert_id('!', $i, $state);
 					# 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
         \&read_fifo, '';                       #
     return 1;                                  #
-}             
+}
 
 # read from fifo
 # (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
         # 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.)
-}                 
+}
 
 # create named fifo and open it for input
 # (called on script load and fifo name changes)
@@ -391,7 +391,7 @@ sub create_fifo($) {                           # [2004-08-14]
     my ($new_fifo) = @_;                       #   get args
     if (not -p $new_fifo) {                    #   create fifo if non-existant
         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"){
             print CLIENTERROR "`mkfifo' failed -- could not create named pipe";
                 # TODO: capture `mkfifo's stderr and show that here
@@ -408,7 +408,7 @@ sub create_fifo($) {                           # [2004-08-14]
 sub nagios_query_status($){
 	# 1412478149;hyppocampe;apt;2;CRITICAL : unknown: qemu-utils, qemu-kvm, qemu-keymaps
 	my ($option)=@_;
-	my @unixcat; 
+	my @unixcat;
 	my $unixline;
 	$nagioscmd = Irssi::settings_get_str("nagios_command");
         foreach $unixline ( `echo "GET services
@@ -453,7 +453,7 @@ sub parse_nagios_log($){
 	# HOST ########################
 		($d,$host,$state,$output)=@match;
 		handle_alert($option,$d,"HOST",$host,$state,$output,$service);
-		
+
 	# SERVICE #####################
 	} elsif (@match=$status_line =~ /\[?(\d+)\]? (\w+) ALERT: ([^;@]+)[@;]([^;@]+)[@;]([^;@]+)[@;]HARD[@;][^;@]*[@;](.+)/) {
 		($d,$type,$host,$service,$state,$output)=@match;
@@ -486,7 +486,7 @@ sub handle_alert($$$$$$$) { # $d,$type,$host,$state,$output,$service
 	# HOST or SERVICE ?
 	$id = insert_alert($host,$service,$state,$output,$d);
 	$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";
 	$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");
 	Irssi::active_server->command('MSG ' . $nagios_ack_channel .
 		" ".$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 ;
 
 		# !nagios [*] :
-		
-		# !nagios list [*] : 
+
+		# !nagios list [*] :
 		if ($arg =~ /^refresh ?(.*)/i) {
 			$arg=$1;
 			Irssi::print(">> $arg");
@@ -610,9 +610,9 @@ print CLIENTCRAP "%B>>%n $IRSSI{name} $VERSION (by $IRSSI{authors}) loaded";
 ##########################################################################
 # 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

+ 1 - 1
bin/tailgrep

@@ -2,4 +2,4 @@
 filename=$1
 shift
 #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 vars qw($VERSION %IRSSI);
-use POSIX qw(strftime); 
+use POSIX qw(strftime);
 
 use LWP::UserAgent;
 
@@ -123,7 +123,7 @@ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
 			$warndate=time();
 		}
 	}
-	
+
 	my $admin=0;
 
 	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 ) {
 			$clocky="J'cause pas aux cons, ca les instruit.";
 			send_server("msg", $target, $nick, "$clocky");
-		}	
+		}
 		elsif ( $text =~ /^tc-14/i ) {
 		   $clocky = $clockok[rand @clockok];
 			send_server("msg", $target, $nick, "$nick: $clocky");
-		}	
+		}
 		elsif ( $text =~ /^!password( .+)?/ ) {
 			my $password ="";
 			$length = $1;
@@ -197,18 +197,18 @@ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
 					 $last=$nick;
 					 $clocky = "Coche la case.";
 					 if ($bingovar{$1} eq "coche") {$clocky = "deja coche"}
-						 else { 
+						 else {
 							$bingovar{$1} = "coche";
 							$bingo++;
 						 }
 					 $server->command ( "action $target $clocky" );
-					 if ( $bingo > 3 ) { 
+					 if ( $bingo > 3 ) {
 					   undef(%bingovar);
-					   $bingo=0; $clocky="FOUTAISES !"; 
+					   $bingo=0; $clocky="FOUTAISES !";
 					   $server->command ( "msg $target $clocky" );
 					   $warn=$nick;
 					 }
-				} 
+				}
 			}
 		}
 		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";
     autosendcmd = "/^msg C nick IDENTIFY mybotpassword";
   },
-  { 
+  {
     address = "irc.undernet.org";
     chatnet = "Undernet";
     port = "6667";
   },
   { address = "irc.dal.net"; chatnet = "DALnet"; port = "6667"; },
-  { 
+  {
     address = "irc.quakenet.org";
     chatnet = "QuakeNet";
     port = "6667";
@@ -46,7 +46,7 @@ chatnets = {
     max_whois = "4";
     max_query_chans = "5";
   };
-  EFNet = { 
+  EFNet = {
     type = "IRC";
     max_kicks = "4";
     max_msgs = "3";
@@ -304,7 +304,7 @@ conversions = {
 };
 hilights = ( { text = "asr"; nick = "yes"; word = "yes"; } );
 windows = {
-  1 = { 
+  1 = {
     immortal = "yes";
     name = "(status)";
     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
 %
-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.
 %
- [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.
 %