Ad Widget

Collapse

Which macro to use for eventids

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • booblik
    Junior Member
    • Oct 2021
    • 11

    #1

    Which macro to use for eventids

    Colleagues, how can you get and transfer the value of eventids to the script. Tried using the {EVENT.ID} macro, doesn't work
    /usr/lib/zabbix/externalscripts/ssh.py --ip {HOST.DNS} --idm {EVENT.ID}

    https://www.zabbix.com/documentation..._by_location?s[]=macros

    Click image for larger version  Name:	sf34.png Views:	0 Size:	25.3 KB ID:	435571

    Any ideas anyone ?
    thanks
    Last edited by booblik; 26-11-2021, 13:15.
  • vicbc
    Member
    • Nov 2021
    • 39

    #2
    Hey there.

    Could you explain a littler better what you're trying to do?
    Where is that script running from, what is triggering it?
    It's not so clear to me, sorry.


    Comment

    • booblik
      Junior Member
      • Oct 2021
      • 11

      #3
      Originally posted by vicbc
      Hey there.

      Could you explain a littler better what you're trying to do?
      Where is that script running from, what is triggering it?
      It's not so clear to me, sorry.

      I have a working python script that runs after a trigger fires and comments out an event. But for it to work through zabbix, it needs to get the value of eventids. VIDEO https://disk.yandex.ru/i/gPzUZJM8gHhfbQ (set high quality when watching video)
      I tried to create my own {$mymacros} macro and then pass the value of the macro to the script, it works. But that doesn't suit me because I have a lot of devices.
      can I somehow get the value of eventids via api or via frontend?
      I don't want to use web scraping
      Click image for larger version  Name:	12.png Views:	1 Size:	93.7 KB ID:	435624
      Last edited by booblik; 27-11-2021, 12:28.

      Comment

      • vicbc
        Member
        • Nov 2021
        • 39

        #4
        Hey booblik, I think I may have a solution to help you with this issue.

        First thing you need is an action to run this script automatically when the trigger is fired, and you can pass a remote command to run your script, while it receives {HOST.DNS} and {EVENT.ID} as parameters as the following:

        Click image for larger version

Name:	image_2021-11-27_081758.png
Views:	147
Size:	31.8 KB
ID:	435629

        Inside your python script you can import the lib "sys", and pass those parameters as variables:


        Click image for larger version

Name:	image_2021-11-27_082003.png
Views:	145
Size:	3.2 KB
ID:	435632

        That way, you can easily point it into the Zabbix API JSON body to ackonowledge the event.

        Use the variable "eventid" inside "message: ", and it will always display the EventID in the message.

        Hope this helps you somehow.


        Cheers, have a nice weekend.

        Attached Files

        Comment

        • booblik
          Junior Member
          • Oct 2021
          • 11

          #5
          Originally posted by vicbc
          Hey booblik, I think I may have a solution to help you with this issue.
          ..................

          it worked!!!!! THX

          Why is the action repeated twice?

          Click image for larger version

Name:	12.png
Views:	120
Size:	13.4 KB
ID:	435649
          Last edited by booblik; 28-11-2021, 17:37.

          Comment

          Working...