Ad Widget

Collapse

Start Script from Actions/media types.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rodrigo.root.rj
    Junior Member
    • Jun 2010
    • 26

    #1

    Start Script from Actions/media types.

    Hi all,
    i have a question about Actions and media types setup. I want start a local server script from trigger, but not work.
    I make a python script for test this feature in path /usr/lib/zabbix/alertscripts with bellow code:
    #!/bin/env python3
    import os, sys
    os.popen('echo `date` >> log')

    That script work fine, when run from shell, but not work from zabbix.
    I setup a Media, Action and setuo a user for this media.
    Following the ACL, for this files:
    root@Zabbix:/usr/lib/zabbix/alertscripts# ls -l
    total 4
    -rwxr-xr-x 1 zabbix zabbix 71 Aug 23 01:57 hmg.py
    -rw-rw-rw- 1 zabbix zabbix 0 Aug 23 01:57 log
    root@Zabbix:/usr/lib/zabbix/alertscripts#

    Attach the setup from GUI.

    My version is Zabbix 5.0.14.
    Attached Files
  • johndoe2374
    Member
    • Aug 2021
    • 80

    #2
    Hello. I think you're doing it wrong wrong way. Media types are for notifications, not custom actions. You don't need to create media to run scripts. When you set up trigger actions, just choose "Run command" instead of "Send message" in action step, choose the server as an script runner and put absolute path to your script in command window.

    Comment

    • rodrigo.root.rj
      Junior Member
      • Jun 2010
      • 26

      #3
      Originally posted by johndoe2374
      Hello. I think you're doing it wrong wrong way. Media types are for notifications, not custom actions. You don't need to create media to run scripts. When you set up trigger actions, just choose "Run command" instead of "Send message" in action step, choose the server as an script runner and put absolute path to your script in command window.
      Hi, johndoe2374, tks for answer
      I want create a single script for many hosts with prototypes in autodiscovery. I need automate the setup for start this script in each trigger. Therefore, i need start this script for many triggers in each host in hosts groups. Whem the host create a new trigger from autodiscovery rules, the trigger must be start this script.

      Comment

      • johndoe2374
        Member
        • Aug 2021
        • 80

        #4
        1. Where your script suppose to be executed? Zabbix server or hosts themselves?
        2. Is your script suppose to be different for each host (some details changes like parameters)?

        In general: if you want script to be executed on different hosts with individual triggers, you need to put trigger in some template. Then you can link it to your hosts and in trigger actions choose trigger from template, not from individual host. Action will be executed if trigger from any linked hosts becomes a "problem".

        Comment

        • rodrigo.root.rj
          Junior Member
          • Jun 2010
          • 26

          #5
          Originally posted by johndoe2374
          1. Where your script suppose to be executed? Zabbix server or hosts themselves?
          2. Is your script suppose to be different for each host (some details changes like parameters)?

          In general: if you want script to be executed on different hosts with individual triggers, you need to put trigger in some template. Then you can link it to your hosts and in trigger actions choose trigger from template, not from individual host. Action will be executed if trigger from any linked hosts becomes a "problem".
          Hi johndoe2374.
          I created my script in alertscripts, in zabbix subdirectory from zabbix server.
          I want use midias to run that for each trigger in specific groups.However, the script run in globalscripts and actions but not work with midias and actions. My question is about setup actions and midias, to run scripts about triggers.

          Comment

          Working...