Ad Widget

Collapse

Zabbix integration - passing parameters to a Perl script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lantrung246a
    Junior Member
    • Jan 2020
    • 1

    #1

    Zabbix integration - passing parameters to a Perl script

    Hello,

    I'm struggling with some integration procedure in order to trigger auto-tickets from Zabbix to ServiceNow via SOAP.


    However Python is using an old library (SOAPpy - latest version from 2014) that is not working as expected, so I just abandoned this option after plenty of attempts and now I'm trying a new one.

    Using Zabbix 4.0 installed on Fedora 31 with Perl version 5.30.1 and perl-ServiceNow-API, I'm able to create tickets via perl script using SOAP.
    So now I need to develop a script to capture the event from Zabbix but I didn't find any reference in how to send the parameters from Zabbix to the script (I assume it should be something similar to the script and instructions from URL above)

    I already configured the Media Type to call the script, modified the media for Admin user and configured the actions for the trigger with concerned macros.
    My question is: how to send all the information to the script? Does anybody has an example?
    Keep in mind that I don't want the full script, just an example like:

    - configure these steps in zabbix
    - call this way in the script
    - check the output

    Even not being a developer I will remove the rusty and create the routine to capture the information and send it via SOAP as I need to the ticketing tool.
    There are not too many references in the web of people doing this, I believe most of the people are sending via email/sms/etc... but in my case SOAP + Perl or Python (if any other up to date library is available) is the last resort.

    If anybody has another solution that can work, please feel free for any suggestions.
    Any information you may have would be appreciated.
    Thanks in advance.

    Regards,
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    It sounds like you're on the right track and that you've read about https://www.zabbix.com/documentation...s/media/script . As a first step, without having any parameters passed to your script, have you been able to see Zabbix call you script? This is a "walk before you run" check, to make sure you've got all the other stuff configured.

    Once you can do that, it's a matter of modifying the Media Type so that whatever parameters you need get passed on the command line to the script. The example in the link above shows that. Your script then needs to process its command line (probably being careful with quoting) and take the information that came in on the command line and add it to the correct places in your SOAP call.

    That's probably the most straightforward method, but the downside is all the parameters come in on the command line. It would be nice if there was an alternate type of "Script (reads stdin)" that could read e.g. an email trigger message and parse out the bits it needs.

    There are at least two alternate ways you can do this, but they're hackish and more complex.

    The first alternate method would be to not use a script Media type, instead use one of the Webhook media types, and have it call a custom webhook you've written (i.e. a web form that accepts some parameters via the web hook) that in turn generates the SOAP call to ServiceNow.

    The second alternate method would be to use the script media type but don't pass any parameters to it (or perhaps, just very minimal parameters, like perhaps event id or something). Since your script basically has no information, it is responsible for using the Zabbix API to get the information on what event(s) just happened, and it will have to decide what information to pass to ServiceNow. This is probably the most complicated route, because it will involve a number of Zabbix API calls. Keep in mind that the Zabbix API is fairly complete, so nearly everything you can see and most of what you can do via the frontend can be interacted with via the API.

    Comment

    Working...