netdata.in 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. #
  4. # netdata Real-time performance monitoring, done right
  5. # chkconfig: 345 99 01
  6. # description: Netdata is a daemon that collects data in real-time (per second)
  7. # and presents a web site to view and analyze them. The presentation
  8. # is also real-time and full of interactive charts that precisely
  9. # render all collected values.
  10. # processname: netdata
  11. # Source functions
  12. . /etc/rc.d/init.d/functions
  13. DAEMON="netdata"
  14. DAEMON_PATH=@sbindir_POST@
  15. PIDFILE_PATH=@localstatedir_POST@/run/netdata
  16. PIDFILE=$PIDFILE_PATH/$DAEMON.pid
  17. DAEMONOPTS="-P $PIDFILE"
  18. STOP_TIMEOUT="60"
  19. [ -e /etc/sysconfig/$DAEMON ] && . /etc/sysconfig/$DAEMON
  20. LOCKFILE=/var/lock/subsys/$DAEMON
  21. service_start()
  22. {
  23. [ -x $DAEMON_PATH ] || exit 5
  24. [ ! -d $PIDFILE_PATH ] && mkdir -p $PIDFILE_PATH
  25. chown @netdata_user_POST@:@netdata_user_POST@ $PIDFILE_PATH
  26. echo -n "Starting $DAEMON..."
  27. daemon $DAEMON_PATH/$DAEMON $DAEMONOPTS
  28. RETVAL=$?
  29. echo
  30. [ $RETVAL -eq 0 ] && touch $LOCKFILE
  31. return $RETVAL
  32. }
  33. service_stop()
  34. {
  35. printf "%-50s" "Stopping $DAEMON..."
  36. killproc -p ${PIDFILE} -d ${STOP_TIMEOUT} $DAEMON
  37. RETVAL=$?
  38. echo
  39. [ $RETVAL -eq 0 ] && rm -f ${PIDFILE} ${LOCKFILE}
  40. return $RETVAL
  41. }
  42. condrestart()
  43. {
  44. if ! service_status > /dev/null; then
  45. RETVAL=$1
  46. return $RETVAL
  47. fi
  48. service_stop
  49. service_start
  50. }
  51. service_status()
  52. {
  53. status -p ${PIDFILE} $DAEMON_PATH/$DAEMON
  54. }
  55. service_status_quiet()
  56. {
  57. status -p ${PIDFILE} $DAEMON_PATH/$DAEMON >/dev/null 2>&1
  58. }
  59. case "$1" in
  60. start)
  61. service_status_quiet && exit 0
  62. service_start
  63. ;;
  64. stop)
  65. service_status_quiet || exit 0
  66. service_stop
  67. ;;
  68. restart)
  69. service_stop
  70. service_start
  71. ;;
  72. try-restart)
  73. condrestart 0
  74. ;;
  75. force-reload)
  76. condrestart 7
  77. ;;
  78. status)
  79. service_status
  80. ;;
  81. *)
  82. echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
  83. exit 3
  84. esac