Ad Widget

Collapse

Zabbix not send variables for script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fabiosoares
    Junior Member
    • Jul 2015
    • 9

    #1

    Zabbix not send variables for script

    I have two servers, one is Zabbix, and the other to use as sending Script's.

    Server one - Zabbix Server installed
    Server two - Raspberry (Debian installed with Huawei device connected to perform sending sms GSM). Apt gammu installed.

    I have e-mail script, working.

    I made an ssh connection without a password between the two, and created the following script at /etc/zabbix/alertscripts:

    #! / bin / bash
    ssh [email protected] "echo "$1" "$2" | gammu sendsms TEXT "$3"";

    Manually works.

    When I drop a VM tests, Zabbix alarm and send email and sms, email is received, the sms not.
    I performed the following test:

    #! / bin / bash
    ssh [email protected] "echo "$1" "$2" "$3" >> test.txt"

    Manually works.
    But does not receive zabbix variables

    What to do?
  • akbar415
    Senior Member
    • May 2015
    • 119

    #2
    Originally posted by fabiosoares
    I have two servers, one is Zabbix, and the other to use as sending Script's.

    Server one - Zabbix Server installed
    Server two - Raspberry (Debian installed with Huawei device connected to perform sending sms GSM). Apt gammu installed.

    I have e-mail script, working.

    I made an ssh connection without a password between the two, and created the following script at /etc/zabbix/alertscripts:

    #! / bin / bash
    ssh [email protected] "echo "$1" "$2" | gammu sendsms TEXT "$3"";

    Manually works.

    When I drop a VM tests, Zabbix alarm and send email and sms, email is received, the sms not.
    I performed the following test:

    #! / bin / bash
    ssh [email protected] "echo "$1" "$2" "$3" >> test.txt"

    Manually works.
    But does not receive zabbix variables

    What to do?
    I think the problem is remote machine don't understand the local machine variable
    Try this
    Code:
    # Use the ssh to set ARG1 and ARG2 on remote host and open a ssh connection
    ssh [email][email protected][/email] ARG1=$1 ARG2=$2'bash -s' <<'ENDSSH'
    #Here you can put all command you want
    
    gammu sendsms TEXT $ARG1 $ARG2
    # This end the remote command
    ENDSSH
    I hope this helps you

    Comment

    • fabiosoares
      Junior Member
      • Jul 2015
      • 9

      #3
      Originally posted by akbar415
      I think the problem is remote machine don't understand the local machine variable
      Try this
      Code:
      # Use the ssh to set ARG1 and ARG2 on remote host and open a ssh connection
      ssh [email][email protected][/email] ARG1=$1 ARG2=$2'bash -s' <<'ENDSSH'
      #Here you can put all command you want
      
      gammu sendsms TEXT $ARG1 $ARG2
      # This end the remote command
      ENDSSH
      I hope this helps you

      I will try, I'm having some problems with Firewall, so resolve post saying if it worked or not. Thanks very much

      Comment

      • fabiosoares
        Junior Member
        • Jul 2015
        • 9

        #4
        Problem solved!

        Edited Zabbix user in the / etc / passwd / was:

        zabbix: x: 1000: 1000 :: / home / zabbix: / bin / false

        Changed to:

        zabbix: x: 1000: 1000 :: / home / zabbix: / bin / bash

        And copied the script to / home / zabbix / gave permissions and work

        I hope to help those who have the same problem one day.

        Comment

        Working...