Troubleshoot cagent on CentOS6

Learn how to solve problems on CentOS6

The installation of the agent run flawlessly using the RPM package which is suitable for CentOS/Rehl 6 and 7. But the agent might not start after the installation. CentOS and Rhel6 use both upstart and sysvinit Verify by executing rpm -qa|grep upstart If upstart has been detected during the installation of cagent, a file /etc/init/cagent.conf has been created. The command initctl list should confirm, that cagent has been registered as an upstart service. Try initctl start cagent to start the agent.

Switching to sysvinit

If the above hints don't help, try to switch back to a traditional sysvinit start-stop-script. Delete the upstart script and reload upstart.

rm /etc/init/cagent.conf initctl reload-configuration

Create the start-stop-script in /etc/init.d/cagent

/etc/init.d/cagent
#! /bin/sh
#
# cagent Start/Stop cagent daemon
#
# chkconfig: 345 30 30
# description: cloudradar monitoring agent daemon
# processname: cagent
# Source function library.
. /etc/init.d/functions
# Check that we're a privileged user
[ `id -u` = 0 ] || exit 4
prog="cagent"
RETVAL=0
lockfile=/var/lock/subsys/$prog
cd /tmp
start() {
# Check if binary is installed & executable
[ -f /usr/bin/$prog ] && [ -x /usr/bin/$prog ] || exit 5
echo -n $"Starting $prog: "
ARGS="-d -c /etc/cagent/cagent.conf"
daemon --user=cagent /usr/bin/$prog $ARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $lockfile
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $lockfile
return $RETVAL
}
restart() {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
exit $?

Finally, execute chkconfig cagent on to start cagent automatically on boot.