Ad Widget

Collapse

Restart zabbix agent remotely

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alwaysin
    Junior Member
    • Jan 2012
    • 27

    #1

    Restart zabbix agent remotely

    Hi,

    I've tried to restart zabbix agent by script, with a "sudo /etc/init.d/zabbix-agent restart" executed on a Ubuntu machine. However, it stops the service but never restarts it. Is it maybe that zabbix kills itself and so can't restart ?
    I'm uing 2.2.3.

    Thanks,

    /Adrien.
  • pc99096
    Senior Member
    • Oct 2011
    • 193

    #2
    who is executing that script and when? have you tried executing it manually?

    Comment

    • kloczek
      Senior Member
      • Jun 2006
      • 1771

      #3
      Originally posted by pc99096
      who is executing that script and when? have you tried executing it manually?
      On Solaris it should be doable. If in zabbix action will be execution of something like "svcadm restart zabbix_agent" SMF should take care finishing zabbix agent restart even if parent process executing svcadm command will be killed (only because restart is not done by svsadm command but it only communicates with svc.startd to request do something like service restart). Of course zabbix user must have permission to restart exact service (zabbix user must be in profile with zabbix_agent service restart permission).
      Last edited by kloczek; 18-04-2014, 16:33.
      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

      • Alwaysin
        Junior Member
        • Jan 2012
        • 27

        #4
        Originally posted by pc99096
        who is executing that script and when? have you tried executing it manually?
        I put this on the "scripts" part of Zabbix. I put "executed by : zabbix agent".

        Since it is only a command, "sudo /etc/init.d/zabbix-agent restart", yeah, I tested it and know that it works when manually executing it on the client.

        Comment

        • pc99096
          Senior Member
          • Oct 2011
          • 193

          #5
          i would maybe try agent stop && agent start instead of agent restart

          Comment

          • ZabbixFun
            Junior Member
            • Apr 2014
            • 23

            #6
            Maybe what you need is passwordless sudo
            To do that switch to root with
            Code:
            sudo su
            and then execute
            Code:
            visudo
            and place at the end of the file
            Code:
            your-user ALL=(ALL) NOPASSWD: ALL
            save and exit

            Comment

            • Alwaysin
              Junior Member
              • Jan 2012
              • 27

              #7
              Originally posted by pc99096
              i would maybe try agent stop && agent start instead of agent restart
              I tried that and here's what I got in the log :

              Code:
               6000:20140423:114055.640 Executing command 'sudo /etc/init.d/zabbix-agent stop && sudo /etc/init.d/zabbix-agent start'
                5997:20140423:114055.679 Got signal [signal:15(SIGTERM),sender_pid:6014,sender_uid:0,reason:0]. Exiting ...
                5999:20140423:114055.679 Got signal [signal:15(SIGTERM),sender_pid:6014,sender_uid:0,reason:0]. Exiting ...
                5998:20140423:114055.679 Got signal [signal:15(SIGTERM),sender_pid:6014,sender_uid:0,reason:0]. Exiting ...
                6001:20140423:114055.678 Got signal [signal:15(SIGTERM),sender_pid:6014,sender_uid:0,reason:0]. Exiting ...
                6000:20140423:114055.679 Got signal [signal:15(SIGTERM),sender_pid:6014,sender_uid:0,reason:0]. Exiting ...
                5996:20140423:114055.680 One child process died (PID:5997,exitcode/signal:255). Exiting ...
              zabbix_agentd [5996]: Error on thread waiting.
                5996:20140423:114055.680 Zabbix Agent stopped. Zabbix 2.2.3 (revision 44105).
              Not working either ... :'(

              And as for the suggestion of ZabbixFun, I've already done this. I use a script to launch updates (sudo /usr/bin/yum -y upgrade) and it is working just fine.

              Comment

              • steveboyson
                Senior Member
                • Jul 2013
                • 582

                #8
                If you stop the parent process (which is zabbix_agentd) then obviously all child processes (which are scripts) get stopped.

                You need to separate the restart job from zabbix_agentd, for example with an independant process. Have a infinite process running which checks for existance of a flagfile. If flagfile exists, restart zabbix_agentd and delete the flagfile.

                In your script, just create the flagfile when a zabbix_agentd restart is required.

                Comment

                Working...