Ad Widget

Collapse

Remote command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ufocek
    Senior Member
    • Aug 2006
    • 161

    #1

    Remote command

    Hi

    I create own items which check is apache2 running on port 8081

    items -> bobo-apache net.tcp.port[192.168.1.53,8081] ,

    next I create triggers which check is apache2 is down on bobo

    triggers so like this -> {bobo:net.tcp.port[192.168.1.53,8081] <http://192.168.1.50/%7EzabbiX/history.php?action=showvalues&period=3600&itemid=1 8151>.*last(*0*)*}=0

    I add actions :
    action type = remote commands
    source: trigger
    Trigger = "Apache2 server is down on bobo"
    remote command -> bobo:/etc/init.d/apache2 restart

    and I stop apache2 , in monitoring on map I see small phone and label "Apache2 server is down on bobo" and this is ok works good,
    but action not work , I don't see any errors about remote command in zabbix_server.log and zabbix_agentd ,
    In zabbix_agentd.conf EnableRemoteCommands=1

    What's wrong?

    Albert
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    Check if user 'zabbix' has permissions to execute /etc/init.d/apache2 restart. Perhaps you want to use sudo?
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • ufocek
      Senior Member
      • Aug 2006
      • 161

      #3
      Hi

      I use sudo and now it's working very well

      Comment

      • ufocek
        Senior Member
        • Aug 2006
        • 161

        #4
        Hi

        I create action , and I see in zabbix_agentd.log it's works ,but apache2 is not restart

        003814:20060922:093717 Got line:system.run[sudo /etc/init.d/apache2 restart,nowait]
        003814:20060922:093717 RUN_COMMAND cmd = 'system.run[sudo /etc/init.d/apache2 restart,nowait]'
        003814:20060922:093717 RUN_COMMAND flag = 'nowait'
        003814:20060922:093717 Run remote command 'sudo /etc/init.d/apache2 restart'
        003814:20060922:093717 RUN_COMMAND runed as NOWAIT

        003815:20060922:093717 Got line:system.run[/home/zabbix/alert.sh,nowait]
        003815:20060922:093717 RUN_COMMAND cmd = 'system.run[/home/zabbix/alert.sh,nowait]'
        003815:20060922:093717 RUN_COMMAND flag = 'nowait'
        003815:20060922:093717 Run remote command '/home/zabbix/alert.sh'
        003815:20060922:093717 RUN_COMMAND runed as NOWAIT

        my triggers action

        bobo:sudo /etc/init.d/apache2 restart
        bobo:/home/zabbix/alert.sh


        zabbix@bobo:~$ sudo -l
        User zabbix may run the following commands on this host:
        (root) ALL
        (root) NOPASSWD: /etc/init.d/apache2 restart

        ls -l /home/zabbix/alert.sh
        -rwxr-xr-x 1 zabbix zabbix 441 2006-09-22 09:15 /home/zabbix/alert.sh


        su - zabbix; sudo /etc/init.d/apache2 restart


        Forcing reload of web server: Apache2 ... no pidfile found! not running?.

        ps aux |grep apache2

        root 26049 0.0 0.7 14208 5264 ? SNs 09:42 0:00 /usr/sbin/apache2 -k start -DSSL
        www-data 26050 0.0 0.4 14344 3436 ? SN 09:42 0:00 /usr/sbin/apache2 -k start -DSSL
        www-data 26051 0.0 0.4 14344 3436 ? SN 09:42 0:00 /usr/sbin/apache2 -k start -DSSL
        www-data 26052 0.0 0.4 14344 3308 ? SN 09:42 0:00 /usr/sbin/apache2 -k start -DSSL
        www-data 26053 0.0 0.4 14344 3284 ? SN 09:42 0:00 /usr/sbin/apache2 -k start -DSSL
        www-data 26054 0.0 0.4 14344 3284 ? SN 09:42 0:00 /usr/sbin/apache2 -k start -DSSL

        And I have question why it's not working? Suddenly it stop works

        Comment

        Working...