Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # nfsd_stats - script to start/stop nfsd_stats daemon
- #
- # chkconfig: 2345 99 10
- # description: daemon to dump nfsd_stats.log statistics to InfluxDB
- # (requires telegraf)
- # processname: nfsd_stats
- # pidfile: /var/run/nfsd_stats.pid
- # Source function library.
- . /etc/rc.d/init.d/functions
- nfsd_stats=/usr/local/bin/nfsd_stats
- prog=${nfsd_stats##*/}
- pidfile="/var/run/$prog.pid"
- start()
- {
- local st
- if st=$( status ); then
- echo "$st"
- return
- fi
- [ -x $nfsd_stats ] || exit 5
- echo -n "Starting $prog: "
- $nfsd_stats <&- >&- 2> /var/run/$prog.stderr &
- sleep 3
- if kill -0 $! 2> /dev/null; then
- echo success
- echo $! > $pidfile
- else
- echo failed
- fi
- }
- stop()
- {
- local st
- if ! st=$( status ); then
- echo "$st"
- return
- fi
- echo -n "Stopping $prog: "
- pkill -P $( cat $pidfile )
- if [ $? -eq 0 ]; then
- echo killed
- else
- echo failed
- fi
- }
- status()
- {
- local pid
- if pid=$( cat $pidfile 2> /dev/null ) &&
- pgrep -P $pid telegraf > /dev/null
- then
- echo "$prog is running (pid $pid)"
- else
- echo "$prog not running"
- return 1
- fi
- }
- case "$1" in
- start|stop|status) $1 ;;
- restart) stop && sleep 3 && start ;;
- *)
- echo "Usage: $0 {start|stop|restart|status}"
- exit 2
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement