Ad Widget

Collapse

How Passing Severity as $-Variable to ext Script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tharder
    Junior Member
    • Sep 2009
    • 5

    #1

    How Passing Severity as $-Variable to ext Script?

    I have a Zabbix 1.6.6 and configured a Media Type "Script" which calls a Shell Script with the normal Parameters $1 to $9.

    If it possible to send the Severity of the Trigger to the Script as $10?

    Sorry for my bad English, I'm from Germany.
  • richlv
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2005
    • 3112

    #2
    it should be possible to pass severity by placing it's macro in the "subject" or "message" parts of the action operation
    Zabbix 3.0 Network Monitoring book

    Comment

    • tharder
      Junior Member
      • Sep 2009
      • 5

      #3
      don't work for me, so i need it as a $variable. I would patch the sourcecode of the zabbix if i know where the $variables are generated. any hints?

      Comment

      • richlv
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Oct 2005
        • 3112

        #4
        it would be easier to help if you explained what exactly does not work...
        Zabbix 3.0 Network Monitoring book

        Comment

        • tharder
          Junior Member
          • Sep 2009
          • 5

          #5
          If i change it in the Actions it would be changed for all Notification Types (SMS, Email, Scripts) but i need it for only one Media Type (exact one Script for iPhone Message but not for the other Script who generates the SMS Messages)

          Comment

          • richlv
            Senior Member
            Zabbix Certified Trainer
            Zabbix Certified SpecialistZabbix Certified Professional
            • Oct 2005
            • 3112

            #6
            ok. possible solutions that seem sensible to me

            1. use a separate action;

            2. in 1.8, it will be possible to choose media per action operation;

            3. use a wrapper script instead that calls your script with whatever parameters you need.

            first is a bit of a hassle, second is not available yet, so i would suggest going with the third
            Zabbix 3.0 Network Monitoring book

            Comment

            • tharder
              Junior Member
              • Sep 2009
              • 5

              #7
              So no hints for patching the Sourcecode to pass the Variable?

              Okay..I'll try the third Solution and report.

              Comment

              • nelsonab
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Sep 2006
                • 1233

                #8
                If your external action is a shell script it is up to you to create variables out of the data that's passed to you. This is actually a very simple process. All items sent on the command line are automatically variables in the form of $1, $2, $3 etc...

                Otherwise let's say you have a large bit of data coming in from standard input, you're going to need to do some work but it's still quite possible. You can first either take stdin and put it to a file "cat > /tmp/myfile" or you could put all of it in a temporary variable "myvar=`cat`". After that you can now process it into the variables you want.

                Let's say you put it all into a temporary file and you're looking for something for something a line similar to this:
                myvar:12345
                This is very easy to parse the following is what I would use.
                myvar=$(cat /tmp/myfile | grep myvar | cut -d: -f2)
                This assumes you used the dump to a temp file technique first.

                As for patching Zabbix to "pass a variable" I don't see that happening any time soon but if it did then it would be done through environment variables. If that is something you really really really really need then open a ticket requesting this feature.

                Hopefully this helps illuminate some of the process.
                RHCE, author of zbxapi
                Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
                Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

                Comment

                • karthikls
                  Junior Member
                  • Jun 2012
                  • 8

                  #9
                  Status sent but no mail aleert

                  Dear All,

                  Please provide me a solution, on the events the action says ok and the status says the mail is sent.But as far i have not received any email notifications.requesting any one to let me know how to pass variables such as body. subject and to or a script which works will be great.Please help.

                  regards,
                  Karthik

                  Comment

                  Working...