Ad Widget

Collapse

Create start/stop srcipt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nicolasfo
    Member
    • Jul 2015
    • 56

    #1

    Create start/stop srcipt

    Hello,
    I've installed Zabbix 2.4.7 on Debian 8.2.0 x64 using make install (source).

    The problem is I don't have any "/etc/init.d" script and I used to use those kind of scripts to start/stop services.

    Is there a way to create it manually ?

    Optionally, I found this manpage but it's not mentionned how to start/stop service :/

    Thanks a lot

    Nicolas
  • Speedfight
    Member
    • May 2007
    • 67

    #2
    if you compliled it. you can start Zabbix with the command: zabbix_server

    A simple "pkill zabbix_server" will shut it down. Not fancy, but it works

    Comment

    • nicolasfo
      Member
      • Jul 2015
      • 56

      #3
      I'd prefer a method to create an init.d script but nevermind.
      Thanks a lot.

      Comment

      • Speedfight
        Member
        • May 2007
        • 67

        #4
        This is for an agent. But you can adjust it to server without any problem


        Code:
        #!/bin/sh
        #
        # chkconfig: - 86 14
        # description: Zabbix agent daemon
        # processname: zabbix_agentd
        # config: /etc/zabbix/zabbix_agentd.conf
        #
        
        ### BEGIN INIT INFO
        # Provides: zabbix-agent
        # Required-Start: $local_fs $network
        # Required-Stop: $local_fs $network
        # Should-Start: zabbix zabbix-proxy
        # Should-Stop: zabbix zabbix-proxy
        # Default-Start:
        # Default-Stop: 0 1 2 3 4 5 6
        # Short-Description: Start and stop Zabbix agent
        # Description: Zabbix agent
        ### END INIT INFO
        
        # Source function library.
        . /etc/rc.d/init.d/functions
        
        if [ -x /usr/sbin/zabbix_agentd ]; then
            exec=zabbix_agentd
        else
            exit 5
        fi
        
        prog=${exec##*/}
        conf=/etc/zabbix/zabbix_agentd.conf
        pidfile=$(grep -e "^PidFile=.*$" $conf | cut -d= -f2 | tr -d '\r')
        timeout=10
        
        if [ -f /etc/sysconfig/zabbix-agent ]; then
            . /etc/sysconfig/zabbix-agent
        fi
        
        lockfile=/var/lock/subsys/zabbix-agent
        
        start()
        {
            echo -n $"Starting Zabbix agent: "
            daemon $exec -c $conf
            rv=$?
            echo
            [ $rv -eq 0 ] && touch $lockfile
            return $rv
        }
        
        stop()
        {
            echo -n $"Shutting down Zabbix agent: "
            killproc -p $pidfile -d $timeout $prog
            rv=$?
            echo
            [ $rv -eq 0 ] && rm -f $lockfile
            return $rv
        }
        
        restart()
        {
            stop
            start
        }
        
        case "$1" in
            start|stop|restart)
                $1
                ;;
            force-reload)
                restart
                ;;
            status)
                status -p $pidfile $prog
                ;;
            try-restart|condrestart)
                if status $prog >/dev/null ; then
                    restart
                fi
                ;;
            reload)
                action $"Service ${0##*/} does not support the reload action: " /bin/false
                exit 3
                ;;
            *)
                echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
                exit 2
                ;;
        esac

        Comment

        • jan.garaj
          Senior Member
          Zabbix Certified Specialist
          • Jan 2010
          • 506

          #5
          Debian 8 uses systemd init system, so I'm not sure if this init script is the best option.

          I recommend to grab init (systemd) script from the official Zabbix Debian 8 package and then just edit paths.
          Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
          My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

          Comment

          Working...