Linux startup script

By default the monitoring agent will not start on boot. We provide a Linux startup script that can be quickly installed to allow the agent to be automatically started on boot.

Note 1 By using this script, the agent will be started and run as the root user.

Note 2 The usual PID file location /tmp/sd-agent.pid changes when using the init.d script to /var/run/sd-agent.pid.

1. Install the startup script

The sd-agent distribution package includes a file called sd-agent.init. As the root user, copy this into the /etc/init.d/ directory and rename it sd-agent (i.e. remove the .init suffix).

2. Set up the agent path

The startup script will look for the sd-agent files in /usr/bin/sd-agent/. You can do either:

a) Create a symlink to the real location of the files

ln -s /path/to/sd-agent/ /usr/bin/sd-agent

or

b) Move the sd-agent files to /usr/bin/sd-agent/

mv /path/to/sd-agent/ /usr/bin/sd-agent/

3. Set the correct permissions

chmod 0755 /etc/init.d/sd-agent

4. Stop the current agent

It is important that the existing agent instance is stopped before you start it using the new init.d script.

python /path/to/sd-agent/agent.py stop

5. Test the script

/etc/init.d/sd-agent start

You should see output similar to:

root@lyra ~: /etc/init.d/sd-agent start
Starting...
                                                           [  OK  ]

and the /var/run/sd-agent.pid file should exist.

6. Configure to start on boot (Red Hat systems - RHEL, Fedora, CentOS)

Use the chkconfig command to define when sd-agent should start/stop. This must be executed as root.

chkconfig --add sd-agent

You can check this was successful by executing:

chkconfig --list sd-agent

which should output the following

sd-agent       	0:off	1:off	2:off	3:on	4:on	5:on	6:off

If you get command not found or the above does not match, then you can manually create the startup scripts by executing each of these commands.

ln -s /etc/rc.d/init.d/sd-agent /etc/rc.d/rc0.d/K15sd-agent
ln -s /etc/rc.d/init.d/sd-agent /etc/rc.d/rc1.d/K15sd-agent
ln -s /etc/rc.d/init.d/sd-agent /etc/rc.d/rc2.d/K15sd-agent
ln -s /etc/rc.d/init.d/sd-agent /etc/rc.d/rc3.d/S85sd-agent
ln -s /etc/rc.d/init.d/sd-agent /etc/rc.d/rc4.d/S85sd-agent
ln -s /etc/rc.d/init.d/sd-agent /etc/rc.d/rc5.d/S85sd-agent 
ln -s /etc/rc.d/init.d/sd-agent /etc/rc.d/rc6.d/K15sd-agent

The monitoring agent will now automatically start on boot and quit on shutdown.

6. Configure to start on boot (Ubuntu)

Use the update-rc.d command to define when sd-agent should start/stop. This must be executed as root.

update-rc.d sd-agent defaults

The expected output from this will be something like:

update-rc.d: warning: /etc/init.d/sd-agent missing LSB information
update-rc.d: see 
 Adding system startup for /etc/init.d/sd-agent ...
   /etc/rc0.d/K20sd-agent -> ../init.d/sd-agent
   /etc/rc1.d/K20sd-agent -> ../init.d/sd-agent
   /etc/rc6.d/K20sd-agent -> ../init.d/sd-agent
   /etc/rc2.d/S20sd-agent -> ../init.d/sd-agent
   /etc/rc3.d/S20sd-agent -> ../init.d/sd-agent
   /etc/rc4.d/S20sd-agent -> ../init.d/sd-agent
   /etc/rc5.d/S20sd-agent -> ../init.d/sd-agent