Created
January 10, 2013 22:55
-
-
Save favoretti/4506524 to your computer and use it in GitHub Desktop.
opencsw collectd SMF method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash-3.2# cat /lib/svc/method/collectd | |
#!/sbin/sh | |
PIDFILE=/var/opt/csw/run/collectd.pid | |
DAEMON=/opt/csw/sbin/collectd | |
. /lib/svc/share/smf_include.sh | |
case "$1" in | |
start) | |
if [ -f $PIDFILE ] ; then | |
echo "Already running. Stale PID file?" | |
PID=`cat $PIDFILE` | |
echo "$PIDFILE contains $PID" | |
ps -p $PID | |
exit $SMF_EXIT_ERR_FATAL | |
fi | |
$DAEMON | |
if [ $? -ne 0 ] ; then | |
echo $DAEMON faild to start | |
exit $SMF_EXIT_ERR_FATAL | |
fi | |
;; | |
stop) | |
PID=`cat $PIDFILE 2>/dev/null` | |
kill -15 $PID 2>/dev/null | |
pwait $PID 1> /dev/null 2>/dev/null | |
;; | |
restart) | |
$0 stop | |
$0 start | |
;; | |
status) | |
ps -ef | grep collectd | grep -v status | grep -v grep | |
;; | |
*) | |
echo "Usage: $0 [ start | stop | restart | status ]" | |
exit 1 | |
;; | |
esac | |
exit $SMF_EXIT_OK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment