Ad Widget

Collapse

Run remote command on trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rocklee44
    Junior Member
    • Apr 2015
    • 7

    #1

    Run remote command on trigger

    Hi all,
    I'm using Zabbix 2.4 to monitor nodejs service on a server, I want Zabbix Agent can restart service when trigger on "service down"
    /etc/passwd
    zabbix:x:498:498:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin
    I want Zabbix agent can run this command as userA:
    /path-to/forever restart /path-to/nodejs.js
    How should I configure action : Target list , Type , Commands
    And visudo ?
    Thanks for your help.
  • rocklee44
    Junior Member
    • Apr 2015
    • 7

    #2
    Can anyone help me ?

    Comment

    • Atsushi
      Senior Member
      • Aug 2013
      • 2028

      #3
      If you want execute that command line by userA, you must settng change shell and visudo.
      At first, you must change shell for zabbix user.

       # usermod -s /bin/sh zabbix

      Next, some setting change by visudo.

      Add 2 lines :
      -----
      zabbix ALL=(userA) NOPASSWD:/path-to/forever restart /path-to/nodejs.js
      Defaults:zabbix !requiretty
      -----

      And, EnableRemoteCommands value set to 1 in zabbix_agentd.conf.
      -----
      EnableRemoteCommands=1
      -----

      After that, you can add Action setting.

      example value:
      Operation type : Remote command
      Type : Custom script
      Execute on : Zabbix agent
      Commands : sudo -u userA /path-to/forever restart /path-to/nodejs.js

      Comment

      • kloczek
        Senior Member
        • Jun 2006
        • 1771

        #4
        Originally posted by rocklee44
        Can anyone help me ?
        You can add top of the trigger action (Configuration -> Action -> triggers)

        In Action definition Trigger name and exact template or host name and in Operations tab: Operation type -> Remote command and here you can choose execute action on zabbix agent or server.

        To be honest I think that it would be good if it would be possible to define actions on template/host level as well.
        http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
        https://kloczek.wordpress.com/
        zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
        My zabbix templates https://github.com/kloczek/zabbix-templates

        Comment

        • rocklee44
          Junior Member
          • Apr 2015
          • 7

          #5
          Thank you very much Atsushi,
          I made it worked.

          Comment

          • pangarano
            Junior Member
            • Apr 2015
            • 9

            #6
            Thank you, this is useful I'll try to implement it

            Comment

            Working...