Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digital Ocean monitoring do-agent setup on Debian 9 #1414

Closed
Pls opened this issue Aug 5, 2019 · 3 comments
Closed

Digital Ocean monitoring do-agent setup on Debian 9 #1414

Pls opened this issue Aug 5, 2019 · 3 comments

Comments

@Pls
Copy link

Pls commented Aug 5, 2019

Hey,

I just installed BOA 4.0.1 on Digital Ocean with Debian 9.7 (recommended version by BOA). Now I'm having problems with do-agent that it's not supporting sysvinit init system - digitalocean/do-agent#202

Do you guys use BOA on Digital Ocean and don't have this problem? Seems to me that sysvinit integration should be pretty easy to do. I would be willing to create pull request if someone could give me syntax on how to add do-agent using sysvinit init system.

Related issue with more people reporting about his problem: digitalocean/do-agent#35

Code that has systemd and upstart logic, but sysvinit logic is missing (that is default Debian init system as I understand): https://github.com/digitalocean/do-agent/blob/7977cee907ef63de9584969eed3f0fab8edd9363/packaging/scripts/after_install.sh#L24

Thanks for reading this issue, pointing in the right direction would be really appreciated. Cheers!

@Pls Pls changed the title Digital Ocean monitoring agent setup on Debian 9 Digital Ocean monitoring do-agent setup on Debian 9 Aug 5, 2019
@omega8cc
Copy link
Owner

We use DO droplets but we don’t install their agent, because from our experience similar software on Linode before always caused problems on upgrades. Since we don’t support systemd and the agent is installed from packages, adding custom startup script is not going to help because agent upgrades will break system upgrades anyway. This has to be fixed in the agent package so it stops depending on systemd, or it should be installed from sources perhaps.

Sent with GitHawk

@diodenyc
Copy link

diodenyc commented Sep 3, 2019

I got it running on my BOA systems using the following steps:
First, follow DigitalOcean's upgrade instructions (the install will fail, but the new version will actually get installed):

  1. sudo apt-get purge do-agent

  2. curl -sSL https://repos.insights.digitalocean.com/install.sh | sudo bash

  3. Now, create a new file for this service, and set perms:
    sudo touch /etc/init.d/do-agent; sudo chown root:root /etc/init.d/do-agent; sudo chmod 0755 /etc/init.d/do-agent;

  4. Paste the following into that file:

#
#       /etc/init.d/do-agent  -- startup script for DigitalOcean agent
#
### BEGIN INIT INFO
# Provides: do-agent
# Required-Start:       $syslog $local_fs
# Required-Stop:        $syslog $local_fs
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description: DigitalOcean agent
### END INIT INFO

prog=do-agent
DAEMON=/opt/digitalocean/bin/do-agent
PIDFILE=/var/run/$prog.pid
DESC="DigitalOcean agent"
SCRIPTNAME=/etc/init.d/$prog
RUN_AS_USER="do-agent"
RUN_AS_GROUP="do-agent"
DAEMON_ARGS=""

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#



start() {
        log_daemon_msg "Starting $DESC" "$prog"
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started

        touch $PIDFILE
        chown $RUN_AS_USER:$RUN_AS_GROUP $PIDFILE

        start-stop-daemon --start -c $RUN_AS_USER:$RUN_AS_GROUP -b -m --pidfile /var/run/do-agent.pid --exec $DAEMON  --test > /dev/null \
                || return 1
        start-stop-daemon --start -c $RUN_AS_USER:$RUN_AS_GROUP -b -m --pidfile /var/run/do-agent.pid --exec $DAEMON $DAEMON_ARGS || return 2

        log_end_msg $?
}

stop() {
        log_daemon_msg "Stopping $DESC" "$prog"
        killproc -p $PIDFILE /opt/digitalocean/bin/do-agent
        if [ $? -ne 0 ]; then
                log_end_msg 1
                return $?
        fi
        if [ $? -eq 0 ]; then
                log_end_msg 0
        fi

        rm -f $PIDFILE

        # # Return
        # #   0 if daemon has been stopped
        # #   1 if daemon was already stopped
        # #   2 if daemon could not be stopped
        # #   other if a failure occurred
        # start-stop-daemon --stop --retry=TERM/10/KILL/5 --pidfile $PIDFILE --name $prog
        # RETVAL="$?"
        # [ "$RETVAL" = 2 ] && return 2
        # # Wait for children to finish too if this is a daemon that forks
        # # and if the daemon is only ever run from this initscript.
        # # If the above conditions are not satisfied then add some other code
        # # that waits for the process to drop all resources that could be
        # # needed by services started subsequently.  A last resort is to
        # # sleep for some time.
        # start-stop-daemon --stop --oknodo --retry=0/10/KILL/5 --exec $DAEMON
        # [ "$?" = 2 ] && return 2
        # # Many daemons don't delete their pidfiles when they exit.
        # return "$RETVAL"
}

force_reload() {
        stop
        start

}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        force-reload)
                force_reload
                ;;
        restart)
                stop
                start
                ;;

        *)
                echo "$Usage: $prog {start|stop|force-reload|restart}"
                exit 2
esac
  1. Now start the service sudo service do-agent start and that should do it.

@Pls
Copy link
Author

Pls commented Sep 4, 2019

Cool! @diodenyc You rock, thanks! Works smoothly now!

@Pls Pls closed this as completed Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants