Ad Widget

Collapse

zabbix and the daemon tools

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghislain
    Senior Member
    • Jun 2005
    • 160

    #1

    zabbix and the daemon tools

    Hi,

    I allready had some discution here about the way zabbix_server start. HHere is the problem i meet, perhaps some of you can help me


    I tried to tweak the scripts and use the daemon tool supervise with zabbix. In all case i meet a problem. It seems that zabbix just start his process and fork a new one leaving the started one so supervise cannot restart it in case of failure.

    The daemon tools have for this case a hack that we see here :

    How can I supervise a daemon that puts itself into the background? When I run inetd, my shell script exits immediately, so supervise keeps trying to restart it.

    Answer: The best answer is to fix the daemon. Having every daemon put itself into the background is bad software design.

    fghack can force some daemons to run in the foreground:

    #!/bin/sh
    echo starting
    exec fghack inetd
    Beware that supervise cannot send signals to daemons under fghack.


    But fghack does not work for zabbix.

    I was wondering if there was an option to the command line to prevent zabbix to go in foreground or anything like that in the configuration file. Anyone made this work ? I'de like to have supervise restart the daemon in case of failure

    regards,
    Ghislain.
    Regards,
    Ghislain.
  • fonderia
    Junior Member
    • Dec 2005
    • 5

    #2
    quite rude, but effective.
    Code:
    # cat /service/monitoring_agent/run 
    #!/bin/sh
    #pkill -9 zabbix_agentd
    ps waxu|grep /usr/sbin/zabbix_agentd|grep -vq grep
    RES=$?
    if [[ -f /var/run/zabbix/zabbix_agentd.pid && $RES -eq 0 ]]
    then
            exit
    else
            rm -rf /var/run/zabbix/zabbix_agentd.pid
            killall -9 zabbix_agentd 2>/dev/null
            exec /usr/sbin/zabbix_agentd 2>&1
    fi

    Comment

    • ghislain
      Senior Member
      • Jun 2005
      • 160

      #3
      yes quite hard

      thanks for sharing. Alexei what is your point of view on this ? Will it be difficult to prevent the forking or is it silly to ask ? (sorry i am not a dev so i really miss the knowledge to know if this is good/bad/neutral...

      If not i will use this solution but as we see this is rather the "hard" way

      Thanks again.
      Ghislain.

      ps: by the way the trigger and template in beta5 are really easy to work with, thanks !
      Regards,
      Ghislain.

      Comment

      • SATux
        Junior Member
        • Dec 2006
        • 10

        #4
        Ghislain,

        Did you ever get zabbix_server to work nicely with daemontools?

        Thanks
        SATux

        Comment

        • ghislain
          Senior Member
          • Jun 2005
          • 160

          #5
          in fact no. I used a third party monitoring services to monitor zabbix and the support team get paged if it dies. So i basicaly use it in a normal way

          regards,
          Ghislain.
          Regards,
          Ghislain.

          Comment

          • johnnyirons
            Junior Member
            • Dec 2007
            • 16

            #6
            this is better.
            you can reuse it for the agent, you change $PROC.

            (freebsd 6.2)

            Code:
            #!/usr/local/bin/bash
            
            PROC=zabbix_server
            
            ps waxu|grep $PROC|grep "main process"
            if [[ $? -gt 0 ]]; then
                    if [[ -f /var/run/zabbix/$PROC.pid  ]]; then
                            echo "Found stale lock file, killing... "|logger -t $PROC
                            rm -rf /var/run/zabbix/$PROC.pid
                    fi
                    killall  $PROC 2>/dev/null
                    sleep 5
                    ps waxu|grep $PROC|grep "main process"
                    RES=$?
                    if [ $? -gt 0 ]; then
                            echo "Brute force killing $PROC (-9).. "|logger -t $PROC
                            killall -9 $PROC 2>/dev/null
                    fi
                    sleep 5
                    exec /usr/local/bin/$PROC 2>&1 &
                    sleep 5
                    ps waxu|grep $PROC|grep "main process"
                    if [[ $? -gt 0 ]]; then
                            echo "Did not start!!! Check $PROC.log."|logger -t $PROC
                    else
                            echo "started."|logger -t $PROC
                    fi
            fi
            Last edited by johnnyirons; 09-04-2008, 16:42.

            Comment

            Working...