Notificação do Nagios no Gtalk
Essa dica e pra quem quer receber notificações de mensagens do nagios através de uma conta do gtalk, assim você pode receber na hora um alerta do nagios no seu cliente de gtalk (seja no seu desktop ou celular)
Essa dica eu peguei do site: http://www.gridpp.ac.uk/wiki/Nagios_jabber_notification
Vou mostrar aqui como configurar em um FreeBSD:
Satisfazendo algumas dependências do perl para o script:
cd /usr/ports/net-im/p5-Net-XMPP make install clean cd /usr/ports/security/p5-IO-Socket-SSL make install clean
A partir dai podemos criar o nosso script:
#!/usr/bin/perl -w # # script for nagios notify via Jabber / Google Talk Instant Messaging # using XMPP protocol and SASL PLAIN authentication. # # author: Andrew Elwell # based on work by Thus0 and David Cox # # released under the terms of the GNU General Public License v2 # Copyright 2007 Andrew Elwell. use strict; use Net::XMPP; ## Configuration my $username = "your.google.username"; my $password = "your.google.password"; my $resource = "nagios"; ## End of configuration my $len = scalar @ARGV; if ($len ne 2) { die "Usage...\n $0 [jabberid] [message]\n"; } my @field=split(/,/,$ARGV[0]); #------------------------------------ # Google Talk & Jabber parameters : my $hostname = 'talk.google.com'; my $port = 5222; my $componentname = 'gmail.com'; my $connectiontype = 'tcpip'; my $tls = 1; #------------------------------------ my $Connection = new Net::XMPP::Client(); # Connect to talk.google.com my $status = $Connection->Connect( hostname => $hostname, port => $port, componentname => $componentname, connectiontype => $connectiontype, tls => $tls); if (!(defined($status))) { print "ERROR: XMPP connection failed.\n"; print " ($!)\n"; exit(0); } # Change hostname my $sid = $Connection->{SESSION}->{id}; $Connection->{STREAM}->{SIDS}->{$sid}->{hostname} = $componentname; # Authenticate my @result = $Connection->AuthSend( username => $username, password => $password, resource => $resource); if ($result[0] ne "ok") { print "ERROR: Authorization failed: $result[0] - $result[1]\n"; exit(0); } # Send messages foreach ( @field ) { $Connection->MessageSend( to => "$_\@$componentname", resource => $resource, subject => "Notification", type => "chat", body => $ARGV[1]); }
Altere as opcoes no script conforme os dados de sua conexao no Gtalk
Dai configure no seu nagios (ou Centreon) o seu comando de notificacao:
# 'host-notify-by-jabber' command definition
define command{
command_name host-notify-by-jabber
command_line /usr/local/bin/notify_via_jabber $CONTACTPAGER$ "Host '$HOSTALIAS$' is $HOSTSTATE$ - Info
: $HOSTOUTPUT$"
}
# 'notify-by-jabber' command definition
define command{
command_name notify-by-jabber
command_line /usr/local/bin/notify_via_jabber $CONTACTPAGER$ "$NOTIFICATIONTYPE$ $HOSTNAME$ $SERVICED
ESC$ $SERVICESTATE$ $SERVICEOUTPUT$ $LONGDATETIME$"
}