Transcript
8/4/2019 Google Talk Notifications
1/62
Google TalkNotificaciones en Tiempo Real
sudoers Barcelona20111004Javier Arturo Rodrguez
mailto:javier@rodriguez.org.mxmailto:javier@rodriguez.org.mx8/4/2019 Google Talk Notifications
2/62
xkcd.com (cc) Randall Munroe
8/4/2019 Google Talk Notifications
3/62
8/4/2019 Google Talk Notifications
4/62
xkcd.com (cc) Randall Munroe
8/4/2019 Google Talk Notifications
5/62
xkcd.com (cc) Randall Munroe
8/4/2019 Google Talk Notifications
6/62
8/4/2019 Google Talk Notifications
7/62
8/4/2019 Google Talk Notifications
8/62
8/4/2019 Google Talk Notifications
9/62
8/4/2019 Google Talk Notifications
10/62Flickr (cc) Albert!
8/4/2019 Google Talk Notifications
11/62
8/4/2019 Google Talk Notifications
12/62
8/4/2019 Google Talk Notifications
13/62
8/4/2019 Google Talk Notifications
14/62
Menos cambios decontexto
8/4/2019 Google Talk Notifications
15/62
8/4/2019 Google Talk Notifications
16/62
Canal Dedicado
8/4/2019 Google Talk Notifications
17/62
8/4/2019 Google Talk Notifications
18/62
API Abierto
8/4/2019 Google Talk Notifications
19/62
8/4/2019 Google Talk Notifications
20/62
Basado en Estndares
8/4/2019 Google Talk Notifications
21/62
8/4/2019 Google Talk Notifications
22/62
http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/http://www.jabber.org/8/4/2019 Google Talk Notifications
23/62
8/4/2019 Google Talk Notifications
24/62
8/4/2019 Google Talk Notifications
25/62
8/4/2019 Google Talk Notifications
26/62
8/4/2019 Google Talk Notifications
27/62
Cliente IM
Mvil
Web
8/4/2019 Google Talk Notifications
28/62
Cliente IM
Mvil
Web
8/4/2019 Google Talk Notifications
29/62
Cliente IM
Mvil
Web
8/4/2019 Google Talk Notifications
30/62
Cliente IM
Mvil
Web
8/4/2019 Google Talk Notifications
31/62
8/4/2019 Google Talk Notifications
32/62
Gran Infraestructura
8/4/2019 Google Talk Notifications
33/62
8/4/2019 Google Talk Notifications
34/62
8/4/2019 Google Talk Notifications
35/62
Archivo Histrico
8/4/2019 Google Talk Notifications
36/62
8/4/2019 Google Talk Notifications
37/62
gTalk Prctico
8/4/2019 Google Talk Notifications
38/62
http://www.gridpp.ac.uk/wiki/Nagios_jabber_notification
http://www.gridpp.ac.uk/wiki/Nagios_jabber_notificationhttp://www.gridpp.ac.uk/wiki/Nagios_jabber_notification8/4/2019 Google Talk Notifications
39/62
8/4/2019 Google Talk Notifications
40/62
8/4/2019 Google Talk Notifications
41/62
8/4/2019 Google Talk Notifications
42/62
die "Usage...\n $0 [jabberid] [message]\n";}
@fi ld lit(/ / $ARGV[0])
8/4/2019 Google Talk Notifications
43/62
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.commy $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 hostnamemy $sid = $Connection->{SESSION}->{id};$Connection->{STREAM}->{SIDS}->{$sid}->{hostname} = $componentname;
# Authenticatemy @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 messagesforeach ( @field ) {$Connection->MessageSend(
to => "$_\@$componentname",resource => $resource,subject => "Notification",type => "chat",body => $ARGV[1]);
}
8/4/2019 Google Talk Notifications
44/62
Parche para
8/4/2019 Google Talk Notifications
45/62
8/4/2019 Google Talk Notifications
46/62
8/4/2019 Google Talk Notifications
47/62
$ /usr/local/bin/notify_via_gtalk gtalkuser Hello, gTalk world!
Lnea de comando
8/4/2019 Google Talk Notifications
48/62
$ /usr/local/bin/notify_via_gtalk gtalkuser Hello, gTalk world!
Lnea de comando
8/4/2019 Google Talk Notifications
49/62
8/4/2019 Google Talk Notifications
50/62
$ rsync src/ remote:dst/ \
&& /usr/local/bin/notify_via_gtalk gtalkuser Backup completed \|| /usr/local/bin/notify_via_gtalk gtalkuser ERROR
Shell scripts
8/4/2019 Google Talk Notifications
51/62
8/4/2019 Google Talk Notifications
52/62
Nagios commands.cfg
8/4/2019 Google Talk Notifications
53/62
# 'host-notify-by-gtalk' command definitiondefine command{
command_name host-notify-by-gtalkcommand_line /usr/local/bin/notify_via_gtalk $CONTACTPAGER$ "Host
'$HOSTALIAS$' is $HOSTSTATE$ - Info: $HOSTOUTPUT$"}
# 'notify-by-gtalk' command definitiondefine command{
command_name notify-by-gtalkcommand_line /usr/local/bin/notify_via_gtalk $CONTACTPAGER$
"$NOTIFICATIONTYPE$ $HOSTNAME$ $SERVICEDESC$ $SERVICESTATE$ $SERVICEOUTPUT$$LONGDATETIME$"
}
Nagios commands.cfg
8/4/2019 Google Talk Notifications
54/62
# 'host-notify-by-gtalk' command definitiondefine command{
command_name host-notify-by-gtalkcommand_line /usr/local/bin/notify_via_gtalk $CONTACTPAGER$ "Host
'$HOSTALIAS$' is $HOSTSTATE$ - Info: $HOSTOUTPUT$"}
# 'notify-by-gtalk' command definitiondefine command{
command_name notify-by-gtalkcommand_line /usr/local/bin/notify_via_gtalk $CONTACTPAGER$
"$NOTIFICATIONTYPE$ $HOSTNAME$ $SERVICEDESC$ $SERVICESTATE$ $SERVICEOUTPUT$$LONGDATETIME$"
}
Nagios commands.cfg
8/4/2019 Google Talk Notifications
55/62
mail2gtalk
8/4/2019 Google Talk Notifications
56/62
#!/usr/bin/perluse strict;use Email::StripMIME;use Email::Simple;use Data::Dumper;
my $NOTIFY = "/usr/local/bin/notify_via_gtalk";
local $/ = undef;my $to = shift @ARGV;$to=~s,[^a-z0-9],,igs;my $in = ;my $email = Email::Simple->new(Email::StripMIME::strip_mime( $in ));my $from = $email->header("From");
my $subject = $email->header("Subject");if($from=~m,,) {" $from = $1;}my $body = $from. ': ' . $subject . '. ' . $email->body();$body=~s,[\n\r], ,igs;$body=~s,\s+, ,igs;# Uncomment next line to limit length, e.g. for SMS
# $body=substr($body,0,160);if(-x $NOTIFY) {" open(PIPE,"|$NOTIFY $to")||die($!);" print PIPE $body;" close(PIPE)||die($!);} else {" die("Can't find $NOTIFY");}
mail2gtalk
8/4/2019 Google Talk Notifications
57/62
sudo: /etc/aliases
8/4/2019 Google Talk Notifications
58/62
8/4/2019 Google Talk Notifications
59/62
sudo: /etc/sudoers
8/4/2019 Google Talk Notifications
60/62
Defaults mail_no_perms
Defaults mail_badpassDefaults mailto="root,santa@local.domain"
sudo: /etc/sudoers
mailto:santa@colabora.netmailto:santa@colabora.net8/4/2019 Google Talk Notifications
61/62
8/4/2019 Google Talk Notifications
62/62
Javier Arturo Rodrguez
mailto:javier@rodriguez.org.mxmailto:javier@rodriguez.org.mx
top related