Skip to content

Instantly share code, notes, and snippets.

@favoretti
Created January 10, 2013 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save favoretti/4506524 to your computer and use it in GitHub Desktop.
Save favoretti/4506524 to your computer and use it in GitHub Desktop.
opencsw collectd SMF method
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