Ad Widget

Collapse

Teltonika and Media

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nabberuk
    Member
    • May 2010
    • 82

    #1

    Teltonika and Media

    I have a Teltonika SMS gateway that i would like to use with Zabbix for sending SMS. I can use POST event in the following format to send.

    Code:
    http://10.3.1.7/cgi-bin/sms_send?username=user1&password=user_pass&number=0037060000001&text=testmessage
    Looking at the media types and the webhooks i can't figure out how to do this in a simple manner. I'm not sure what to put in the script section, any help on this?
  • nabberuk
    Member
    • May 2010
    • 82

    #2
    Any help with this and simple URL webhooks, i can't seem to find any examples.

    Comment

    • ISiroshtan
      Senior Member
      • Nov 2019
      • 324

      #3
      Hi there mate.

      I'd say you need to create a script. Simple bash script might be enough. Do something like

      Code:
      #!/bin/bash 
      curl --data-urlencode "username=user1" --data-urlencode "password=user1" --data-urlencode "number=$1" --data-urlencode "number=$2" http://10.3.1.7/cgi-bin/sms_send?
      And when calling script from Zabbix pass {ALERT.SENDTO} macros as 1st argument and {ALERT.MESSAGE} as 2nd one. Please test it out, as obviously I don't have sms gateway in my lab to give you 100% accurate solution for you.

      Comment

      • nabberuk
        Member
        • May 2010
        • 82

        #4
        Originally posted by ISiroshtan
        Hi there mate.

        I'd say you need to create a script. Simple bash script might be enough. Do something like

        Code:
        #!/bin/bash
        curl --data-urlencode "username=user1" --data-urlencode "password=user1" --data-urlencode "number=$1" --data-urlencode "number=$2" http://10.3.1.7/cgi-bin/sms_send?
        And when calling script from Zabbix pass {ALERT.SENDTO} macros as 1st argument and {ALERT.MESSAGE} as 2nd one. Please test it out, as obviously I don't have sms gateway in my lab to give you 100% accurate solution for you.
        finally getting around to testing this and i'm getting the following message.

        SyntaxError: invalid token (line 1)

        When executing this from the CLI i had to encapsulate the url in double quotes​

        Comment

        • nabberuk
          Member
          • May 2010
          • 82

          #5

          So i have this working from the CLI now.
          curl --data-urlencode "username=admin" --data-urlencode "password=vayddd" --data-urlencode "number=07793500000000" --data-urlencode "text=test" http://10.1.1.5/cgi-bin/sms_send

          But when i add in the $1 and $2 to feed in the data for the number and data i get the error of invalid token.

          Comment

          • ISiroshtan
            Senior Member
            • Nov 2019
            • 324

            #6
            To clarify, are you trying to do it as a webhook?

            If you trying to use webhook type, the same as mentioned above needs to be rewritten in JavaScript, with which I'm not profficient enough to write it for you on the spot.

            I meant that you could use "Script" type instead with having bash script in corresponding folder on your Zabbix server so it would get invoked whenever Zabix needs to send SMS.

            Comment

            • ISiroshtan
              Senior Member
              • Nov 2019
              • 324

              #7
              $1 and $2 would be replaced by incoming arguments. So if you have saved it as a file, invoking it as below should do the trick

              Taking this
              HTML Code:
              curl --data-urlencode "username=admin" --data-urlencode "password=vayddd" --data-urlencode "number=07793500000000" --data-urlencode "text=test" http://10.1.1.5/cgi-bin/sms_send​
              as a base for notification message, you modify it as
              HTML Code:
              curl --data-urlencode "username=admin" --data-urlencode "password=vayddd" --data-urlencode "number=$1" --data-urlencode "text=$2" http://10.1.1.5/cgi-bin/sms_send​
              and invoke it as
              HTML Code:
              ./script.sh 07793500000000 test
              This way you can easily pass any phone number as first argument to script, and any string to be used as text.
              Last edited by ISiroshtan; 06-01-2023, 13:19.

              Comment

              • nabberuk
                Member
                • May 2010
                • 82

                #8
                I can now execute it locally but when running from Zabbix its says it has successfully run but i never receive the SMS.

                If i manually change the script and statically put the number and text in, its sends. this would suggest the params are not being passed to the script.

                I am using the following code.

                #!/bin/bash

                curl --data-urlencode "username=admin" --data-urlencode "password=vayaf" --data-urlencode "number=$1" --data-urlencode "text=$2">

                For the script params i'm using...

                {ALERT.TO}
                {ALERT.MESSAGE}

                Last edited by nabberuk; 06-01-2023, 16:07.

                Comment

                • nabberuk
                  Member
                  • May 2010
                  • 82

                  #9
                  I was being an idiot and should have been using {ALERT.SENDTO} for the param.

                  Comment

                  Working...