Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.