Ad Widget

Collapse

Send Perl Scripts SMS and Email Auth

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marceloaudi
    Junior Member
    • Feb 2008
    • 5

    #1

    Send Perl Scripts SMS and Email Auth

    Please,

    I am using version 1.6.1
    How do I use a my Perl scripts for send SMS and other by Auth Email?
    How this do?
    Where should i pass parameters to the scripts?

    Thank you!
  • Calimero
    Senior Member
    • Nov 2006
    • 481

    #2
    You notification/media script will get 3 parameters from Zabbix:
    - 1st arg: adressee ("Send to" in the media configuration screen). Typically you'd give the phone number for SMS notifications.
    - 2nd arg: notification subject
    - 3rd arg: notification body

    That's how your script would be called by zabbix:

    ./sendsms.php 001122334455 "Alert Host: mycriticalhost" "Alert: Host mycriticalhost Trigger: HTTP down...."

    Body and subject of course are what you've defined per action.

    Comment

    • marceloaudi
      Junior Member
      • Feb 2008
      • 5

      #3
      Send Perl Scripts SMS and Email Auth

      Dear,

      The parameters are %1 %2 and %3?

      And to send to the two scripts, I need to set up two different groups: one for sms and other for email, right?

      Thanks,

      Marcelo Audi

      Comment

      • Calimero
        Senior Member
        • Nov 2006
        • 481

        #4
        Originally posted by marceloaudi
        Dear,

        The parameters are %1 %2 and %3?
        Depends on what langage you write you script (or binary).

        If your script is a shell script, you'll get those values as $1, $2, $3...
        If your "script" is a C binary, you'll pull those values from argc/argv...
        If your script is written in perl, you get get args with $ARGV[0], $ARGV[1]...

        This isn't zabbix-specific. Zabbix just runs your script/binary with three arguments just as you would from your shell.

        Originally posted by marceloaudi
        And to send to the two scripts, I need to set up two different groups: one for sms and other for email, right?
        First you would define two medias:
        - Type: Script, using your custom scripts to send SMS (unless you have one of the supported GSM-modems)
        - Type: E-Mail, using a custom email script (with authentication, I assume)


        ==> Edit: If you want to use a custom script for email, Media type would of course be "script" and not "Email".



        Where and how notifications are sent depends on users.

        Each user can have multiple Medias defined. Each media can be setup to only pass notifications depending on date/time and severity

        Let's say:
        Bob
        --> SMS script, send to '0011223344' (phone) only 'High, Critical', only at by night
        --> Email script: send to '[email protected]', any alerts, business hours
        Alice
        --> SMS script, send to '0102030405' (phone), any alerts, anytime
        but no email
        Oscar:
        --> SMS script, send to '9988776655' (personal phone)
        --> SMS script, send to '3344556677' (professional phone)
        Last edited by Calimero; 18-11-2008, 11:20.

        Comment

        • marceloaudi
          Junior Member
          • Feb 2008
          • 5

          #5
          Send Perl Scripts SMS and Email Auth

          Dear Calimero,

          I do not know where is my error!
          The Perl script run properly in the Debian Shell but not send message by the Zabbix.


          My script:

          #!/usr/bin/perl

          print "content-type: text/html\n\n";
          use CGI;
          $cgi = new CGI;

          $cel = $ARGV[0];
          $title = $ARGV[1];
          $msgx = $ARGV[2];

          &enviasms;

          # SOAP (Simple Object Access Protocol)
          ############################################

          sub enviasms{

          $dispatch = "send";
          $account = "myaccount";
          $code = "mypassword";
          $msg = "$msgx";
          $from = "Zabbix";
          $to = "$cel";
          $id = time();
          $user = $id - 1;
          $schedule = "";
          $callbackOption = "";

          $palavra = "000 - Message sent";

          use LWP::Simple;

          $result = get("http://system.human.com.br:8080/GatewayIntegration/msgSms.do?dispatch=send&account=$account&code=$cod e&msg=$msg&from=$from&to=$to&id=$id&schedule=$sche dule&callbackOption=$callbackOption");

          if(!$result){
          print "Error! SMS was not sent!";
          } elsif($result =~/$palavra/i) {
          print "SMS sent successfully";
          }else{
          print "SMS was not sent!";
          }
          }

          Comment

          • marceloaudi
            Junior Member
            • Feb 2008
            • 5

            #6
            Send Perl Scripts SMS and Email Auth - Finished!!!

            It worked! Lacked only:

            chown zabbix.zabbix sendsms.pl
            chmod 755 sendsms.pl

            Thanks!

            Comment

            Working...