Ad Widget

Collapse

How to pass variable to Email Script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pramod.k29
    Junior Member
    • Sep 2012
    • 3

    #1

    How to pass variable to Email Script

    Hello ,

    I am using Zabbix 1.8 server. I have an authenticated SMTP server. I want to configure a custom script for sending mails through this authenticated SMTP server.Zabbix is triggering my script but due to NULL values of $1,$2,$3 the script is not executing correctly . Following is my script.

    ************************************************** *********
    #!/bin/sh

    export [email protected]
    export zabbixemailto=$1
    export zabbixsubject=$2
    export zabbixbody=$3
    export smtpserver=smtp.1and1.com
    export [email protected]
    export smtppass=*****

    /usr/bin/sendEmail -f $smtpemailfrom -t $zabbixemailto -u $zabbixsubject -m $zab
    bixbody -s $smtpserver:25 -xu $smtplogin -xp $smtppass

    ************************************************** ******

    We can see the script is executing and Zabbix shows success status in event page.

    So the problem is the script is not getting the $1,$2,$3 variable .Can anybody help me how to pass variable to this bash script ??

    -Thanks
  • Davidus
    Senior Member
    • Dec 2010
    • 281

    #2
    Hello,

    As far as I know, for Zabbix Server 1.8 you have to place custom scripts under /home/zabbix/bin
    Make sure that your script is there.

    Good luck!

    Comment

    • pramod.k29
      Junior Member
      • Sep 2012
      • 3

      #3
      Hai Davidus,

      I have put the script under zabbix/bin directory.But still the scenario is same. Its clear that the values from Zabbix is not passing to the bash script. The only solution is to pass the values $1,$2and $3. I dont know how this values are passed to the script.

      Thanks

      Comment

      • mbsit
        Senior Member
        • Sep 2012
        • 130

        #4
        Hi
        You said, that script is executed, so you had successful configured custom action script.

        I don't have 1.8 ver. but in 2.0 is the same but different frontend.

        When you configure Action, and add Steps, "Run remote commands on current host" then in script line you have to put MACROS.

        Look on screen, this is for version 2.0.2 .

        Ps.
        Or, if you setup Administration->Media types this is WRONG DIRECTION because you will only have predefined variables .

        Bests,
        Grzegorz

        --
        Wdrożenia Zabbix - Warszawa
        Attached Files
        Pozdrawiam
        Grzegorz Grabowski
        ____
        Wdrożenia, szkolenia, umowy serwisowe
        Warszawa - Polska

        Comment

        • mbsit
          Senior Member
          • Sep 2012
          • 130

          #5
          Or
          If you use: "CONFIGURATION OF MEDIA TYPES"

          Put the script in correct place for Zabbix 1.8 ver. and it is enough to use such variable reference.

          #!/bin/bash
          #
          # sendsms
          #
          echo "`date` Odbiorca: $1 Tresc: $3" >> /var/log/zabbix/sms.log
          /usr/local/bin/send_sms "$1" "$3" >>/var/log/zabbix/sms.log 2>&1


          Bests,
          Grzegorz

          --
          Wdrożenia Zabbix - Warszawa
          Pozdrawiam
          Grzegorz Grabowski
          ____
          Wdrożenia, szkolenia, umowy serwisowe
          Warszawa - Polska

          Comment

          • pramod.k29
            Junior Member
            • Sep 2012
            • 3

            #6
            Hello All,

            I have changed my OS to Centos and zabbix version to 2.x. Now the script is working fine and I started receiving email alerts.

            Thanks for you support



            Originally posted by mbsit
            Or
            If you use: "CONFIGURATION OF MEDIA TYPES"

            Put the script in correct place for Zabbix 1.8 ver. and it is enough to use such variable reference.





            Bests,
            Grzegorz

            --
            Wdrożenia Zabbix - Warszawa
            www.mbs-it.pl

            Comment

            Working...