netdata.init 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides: netdata
  5. # Required-Start: $all
  6. # Should-Start:
  7. # Required-Stop: $all
  8. # Should-Stop:
  9. # Default-Start: 2 3 5
  10. # Default-Stop:
  11. # Short-Description: Start and stop the netdata real-time monitoring server daemon
  12. # Description: Controls the main netdata monitoring server daemon "netdata".
  13. ### END INIT INFO
  14. DAEMON="netdata"
  15. DAEMON_BIN="/usr/sbin/${DAEMON}"
  16. DAEMON_PID="/var/run/${DAEMON}.pid"
  17. DAEMON_ARGS=""
  18. . /etc/rc.status
  19. rc_reset
  20. if [ ! -x $DAEMON_BIN ]; then
  21. echo -n >&2 "${DAEMON} binary is not installed. "
  22. rc_status -s
  23. exit 5
  24. fi
  25. case "$1" in
  26. start)
  27. echo -n "Starting $DAEMON"
  28. /sbin/startproc $DAEMON_BIN $DAEMON_ARGS
  29. rc_status -v
  30. ;;
  31. stop)
  32. echo -n "Stopping $DAEMON"
  33. /sbin/killproc $DAEMON_BIN
  34. rc_status -v
  35. ;;
  36. reload)
  37. # netdata: HUP reopen log files, USR1 save DB, USR2 reload health config
  38. echo -n "Reloading $DAEMON config"
  39. /sbin/killproc -USR2 $DAEMON_BIN
  40. ;;
  41. restart)
  42. $0 stop
  43. $0 start
  44. ;;
  45. status)
  46. echo -n "Checking $DAEMON"
  47. /sbin/checkproc $DAEMON_BIN
  48. rc_status -v
  49. ;;
  50. *)
  51. echo "Usage: $0 {start|stop|status|reload|restart}"
  52. exit 1
  53. ;;
  54. esac
  55. rc_exit