120 lines
2.3 KiB
Bash
Executable file
120 lines
2.3 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# /etc/init.d/munin-node
|
|
#
|
|
# chkconfig: - 90 10
|
|
# description: Network-wide resource monitoring tool (node)
|
|
# processname: munin-node
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: munin-node
|
|
# Required-Start: $network $syslog
|
|
# Required-Stop:
|
|
# Default-Stop: 0 1 2 6
|
|
# Short-Description: Network-wide resource monitoring tool (node)
|
|
# Description: Munin is a highly flexible and powerful solution used to create
|
|
# graphs of virtually everything imaginable throughout your network,
|
|
# while still maintaining a rattling ease of installation and
|
|
# configuration.
|
|
### END INIT INFO
|
|
|
|
# Source function library.
|
|
. /etc/init.d/functions
|
|
|
|
# Source networking configuration.
|
|
. /etc/sysconfig/network
|
|
|
|
# Check that networking is up.
|
|
[ ${NETWORKING} = "no" ] && exit 0
|
|
|
|
# Read config
|
|
ASYNCD=no
|
|
[ -f /etc/sysconfig/munin-node ] && . /etc/sysconfig/munin-node
|
|
|
|
prognode=munin-node
|
|
progasync=munin-asyncd
|
|
binnode=/usr/sbin/$prognode
|
|
binasync=/usr/sbin/$progasync
|
|
pidnode=/var/run/munin/$prognode.pid
|
|
RETVAL=0
|
|
|
|
start() {
|
|
echo -n $"Starting $prognode: "
|
|
mkdir -p /var/run/munin 2>/dev/null
|
|
chown munin:munin /var/run/munin
|
|
restorecon /var/run/munin 2>/dev/null
|
|
${binnode} < /dev/null > /dev/null 2>&1 &
|
|
sleep 1
|
|
pkill -0 $prognode
|
|
RETVAL=$?
|
|
if [ $RETVAL -eq 0 ]; then
|
|
echo_success
|
|
touch /var/lock/subsys/$prognode
|
|
if [ "${ASYNCD}" = "yes" ]; then
|
|
echo
|
|
echo -n $"Starting $progasync: "
|
|
sleep 1
|
|
${binasync} < /dev/null > /dev/null 2>&1 &
|
|
sleep 1
|
|
pkill -0 $progasync
|
|
RETVAL=$?
|
|
if [ $RETVAL -eq 0 ]; then
|
|
echo_success
|
|
else
|
|
echo_failure
|
|
fi
|
|
fi
|
|
else
|
|
echo_failure
|
|
fi
|
|
echo
|
|
return $RETVAL
|
|
}
|
|
|
|
stop() {
|
|
if [ "${ASYNCD}" = "yes" ]; then
|
|
echo -n $"Stopping $progasync: "
|
|
killproc ${binasync}
|
|
echo
|
|
fi
|
|
echo -n $"Stopping $prognode: "
|
|
killproc ${binnode}
|
|
RETVAL=$?
|
|
echo
|
|
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prognode
|
|
return $RETVAL
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|
|
|
|
# See how we were called.
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
restart)
|
|
restart
|
|
;;
|
|
condrestart)
|
|
[ -f /var/lock/subsys/$prognode ] && restart
|
|
;;
|
|
status)
|
|
status -p ${pidnode} ${binnode}
|
|
RETVAL=$?
|
|
if [ $RETVAL = 0 -a "${ASYNCD}" = "yes" ]; then
|
|
status ${binasync}
|
|
RETVAL=$?
|
|
fi
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|condrestart|status}"
|
|
RETVAL=2
|
|
esac
|
|
|
|
exit $RETVAL
|