Ad Widget

Collapse

Notifications using talk.google.com

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dabd
    Junior Member
    • Jan 2012
    • 5

    #1

    Notifications using talk.google.com

    Hi,

    I cannot use the built-in jabber support since 'telnet jabber.org 5222' shows jabber server is not acessible. However I can 'telnet talk.google.com 443'. Is there a simple setup for notifications through talk.google.com?

    Thanks.
  • untergeek
    Senior Member
    Zabbix Certified Specialist
    • Jun 2009
    • 512

    #2
    No. But you can use a perl script someone wrote to accomplish this. This is the last iteration I have found and I modified it to send from Zabbix. There are a few dependencies (hope you can figure them out) and you need to put this script in the external scripts location defined in zabbix_server.conf, and it needs to be executable by the zabbix user. You need to create a new media-type with this script as the target. That's about it. Ask more questions if you need them. This has worked well for me.

    Code:
    #!/usr/bin/perl -w
    
    #
    # script to send jabber message to Google Talk Instant Messaging
    #   using XMPP protocol and SASL PLAIN authentication.
    #
    # author: Thus0 <[email protected]>
    # Copyright (c) 2005, Thus0 <[email protected]>. All rights reserved.
    #
    # released under the terms of the GNU General Public License v2
    
    use strict;
    use Net::XMPP;
    
    # Username of "FROM" user
    my $username = "FROM_USER";
    my $password = "FROM_PASS";
    
    ## Configuration
    ## 3 Arguments will be passed. 
    ## $ARGV[0] username (Google Talk username minus the @gmail.com part)
    ## $ARGV[1] Subject
    ## $ARGV[2] Message
    
    my $to = "$ARGV[0]";
    my $body = "$ARGV[1]\n\n$ARGV[2]\n";
    
    my $resource = "ACCOUNT_NAME";
    # Presume where ACCOUNT_NAME@$componentname as below.
    
    ## End of configuration
    
    #------------------------------------
    
    # 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 message
    $Connection->MessageSend(
           to => "$to\@$componentname", body => $body,
           resource => $resource);

    Comment

    • dabd
      Junior Member
      • Jan 2012
      • 5

      #3
      I used a similar script but I had to use port 443 with SSL and it works fine. Thanks.

      Comment

      • Zaniwoop
        Senior Member
        • Jan 2010
        • 232

        #4
        I worked around this by using jabber.org as my jabber server.

        you need to create an account and send your gtalk users a buddy request, which they must accept.

        Then it just works. No scripts.

        Comment

        • uxadm
          Junior Member
          • May 2012
          • 5

          #5
          what about web-proxy?

          Hello,
          I cannot use this script (above). Here is an error:
          ---------------------------------------------
          ./conn2talk.pl "uname2r" "test" "test2"
          Use of uninitialized value $args{"file"} in lc at /usr/share/perl5/Net/XMPP/Debug.pm line 154.
          ERROR: XMPP connection failed.
          (Invalid argument)
          ---------------------------------------------

          May be my web proxy make a problem? I can use Gtalk Account with Pidgin from the same system. how can I test it without Zabbix GUI? Please help me.
          Thanks

          Comment

          Working...