summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2016-09-05 08:27:26 +0000
committerLennart Weller <lhw@ring0.de>2016-09-05 08:27:26 +0000
commit58d9525d7fcacffe52eff7282b7a888dd0dcc1d0 (patch)
tree251a805eb38d4d75b2a7f44c2cc22e7ea4849513 /system
parentFixes for service startup and extra config files (diff)
parentImported Upstream version 1.3.0+dfsg (diff)
downloadnetdata-58d9525d7fcacffe52eff7282b7a888dd0dcc1d0.tar.xz
netdata-58d9525d7fcacffe52eff7282b7a888dd0dcc1d0.zip
Merge tag 'upstream/1.3.0+dfsg'
Upstream version 1.3.0+dfsg
Diffstat (limited to 'system')
-rw-r--r--system/Makefile.am3
-rw-r--r--system/Makefile.in6
-rw-r--r--[-rwxr-xr-x]system/netdata-init-d.in41
-rw-r--r--system/netdata-lsb.in100
-rw-r--r--[-rwxr-xr-x]system/netdata-openrc.in4
-rw-r--r--system/netdata.conf3
-rw-r--r--system/netdata.logrotate.in16
-rw-r--r--system/netdata.service.in18
8 files changed, 158 insertions, 33 deletions
diff --git a/system/Makefile.am b/system/Makefile.am
index f16a720e2..b2e49c5af 100644
--- a/system/Makefile.am
+++ b/system/Makefile.am
@@ -7,6 +7,7 @@ CLEANFILES = \
netdata.logrotate \
netdata.service \
netdata-init-d \
+ netdata-lsb \
$(NULL)
include $(top_srcdir)/build/subst.inc
@@ -18,6 +19,7 @@ nodist_noinst_DATA = \
netdata.logrotate \
netdata.service \
netdata-init-d \
+ netdata-lsb \
$(NULL)
dist_noinst_DATA = \
@@ -25,5 +27,6 @@ dist_noinst_DATA = \
netdata.logrotate.in \
netdata.service.in \
netdata-init-d.in \
+ netdata-lsb.in \
netdata.conf \
$(NULL)
diff --git a/system/Makefile.in b/system/Makefile.in
index e8f5eb3c8..75d2e753f 100644
--- a/system/Makefile.in
+++ b/system/Makefile.in
@@ -233,6 +233,8 @@ pluginsdir = @pluginsdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+pythondir = @pythondir@
+registrydir = @registrydir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -253,6 +255,7 @@ CLEANFILES = \
netdata.logrotate \
netdata.service \
netdata-init-d \
+ netdata-lsb \
$(NULL)
SUFFIXES = .in
@@ -261,6 +264,7 @@ nodist_noinst_DATA = \
netdata.logrotate \
netdata.service \
netdata-init-d \
+ netdata-lsb \
$(NULL)
dist_noinst_DATA = \
@@ -268,6 +272,7 @@ dist_noinst_DATA = \
netdata.logrotate.in \
netdata.service.in \
netdata-init-d.in \
+ netdata-lsb.in \
netdata.conf \
$(NULL)
@@ -463,6 +468,7 @@ uninstall-am:
-e 's#[@]localstatedir_POST@#$(localstatedir)#g' \
-e 's#[@]sbindir_POST@#$(sbindir)#g' \
-e 's#[@]sysconfdir_POST@#$(sysconfdir)#g' \
+ -e 's#[@]pythondir_POST@#$(pythondir)#g' \
$< > $@.tmp; then \
mv "$@.tmp" "$@"; \
else \
diff --git a/system/netdata-init-d.in b/system/netdata-init-d.in
index c317d1021..edda9950f 100755..100644
--- a/system/netdata-init-d.in
+++ b/system/netdata-init-d.in
@@ -1,14 +1,20 @@
-#!/bin/bash
+#!/bin/sh
+#
+# netdata Real-time performance monitoring, done right
# chkconfig: 345 99 01
-# description: startup script
+# description: Netdata is a daemon that collects data in real-time (per second)
+# and presents a web site to view and analyze them. The presentation
+# is also real-time and full of interactive charts that precisely
+# render all collected values.
+# processname: netdata
# Source functions
. /etc/rc.d/init.d/functions
DAEMON="netdata"
DAEMON_PATH=@sbindir_POST@
-PIDFILE=@localstatedir_POST@/$DAEMON.pid
-DAEMONOPTS="-pidfile $PIDFILE"
+PIDFILE=@localstatedir_POST@/run/$DAEMON.pid
+DAEMONOPTS="-P $PIDFILE"
STOP_TIMEOUT="10"
service_start()
@@ -32,6 +38,17 @@ service_stop()
return $RETVAL
}
+condrestart()
+{
+ if ! service_status > /dev/null; then
+ RETVAL=$1
+ return $RETVAL
+ fi
+
+ service_stop
+ service_start
+}
+
service_status()
{
status -p ${PIDFILE} $DAEMON_PATH/$DAEMON
@@ -41,9 +58,6 @@ case "$1" in
start)
service_start
;;
-status)
- service_status
-;;
stop)
service_stop
;;
@@ -51,7 +65,16 @@ restart)
service_stop
service_start
;;
+try-restart)
+ condrestart 0
+ ;;
+force-reload)
+ condrestart 7
+;;
+status)
+ service_status
+;;
*)
- echo "Usage: $0 {status|start|stop|restart}"
- exit 1
+ echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
+ exit 3
esac
diff --git a/system/netdata-lsb.in b/system/netdata-lsb.in
new file mode 100644
index 000000000..d81659775
--- /dev/null
+++ b/system/netdata-lsb.in
@@ -0,0 +1,100 @@
+#!/bin/bash
+#
+### BEGIN INIT INFO
+# Provides: netdata
+# Required-Start: $local_fs $remote_fs $network $named $time apache2 httpd squid nginx mysql named opensips upsd hostapd postfix lm_sensors
+# Required-Stop: $local_fs $remote_fs $network $named $time apache2 httpd squid nginx mysql named opensips upsd hostapd postfix lm_sensors
+# Should-Start: $local_fs $network $named $remote_fs $time $all
+# Should-Stop: $local_fs $network $named $remote_fs $time $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start and stop the netdata real-time monitoring server daemon
+# Description: Controls the main netdata monitoring server daemon "netdata".
+# and all its plugins.
+### END INIT INFO
+#
+set -e
+set -u
+${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
+
+DAEMON="netdata"
+DAEMON_PATH=@sbindir_POST@
+PIDFILE=@localstatedir_POST@/$DAEMON.pid
+DAEMONOPTS="-P $PIDFILE"
+
+test -x $DAEMON_PATH/$DAEMON || exit 0
+
+. /lib/lsb/init-functions
+
+# Safeguard (relative paths, core dumps..)
+cd /
+umask 022
+
+service_start() {
+ log_daemon_msg "Starting real-time performance monitoring" "netdata"
+ start_daemon -p $PIDFILE $DAEMON_PATH/$DAEMON $DAEMONOPTS
+ RETVAL=$?
+ log_end_msg $RETVAL
+ return $RETVAL
+}
+
+service_stop() {
+ log_daemon_msg "Stopping real-time performance monitoring" "netdata"
+ killproc -p ${PIDFILE} $DAEMON_PATH/$DAEMON
+ RETVAL=$?
+ log_end_msg $RETVAL
+
+ if [ $RETVAL -eq 0 ]; then
+ rm -f ${PIDFILE}
+ fi
+ return $RETVAL
+}
+
+condrestart() {
+ if ! service_status > /dev/null; then
+ RETVAL=$1
+ return
+ fi
+
+ service_stop
+ service_start
+}
+
+service_status() {
+ status_of_proc -p $PIDFILE $DAEMON_PATH/$DAEMON netdata
+}
+
+
+#
+# main()
+#
+
+case "${1:-''}" in
+ 'start')
+ service_start
+ ;;
+
+ 'stop')
+ service_stop
+ ;;
+
+ 'restart')
+ service_stop
+ service_start
+ ;;
+
+ 'try-restart')
+ condrestart 0
+ ;;
+
+ 'force-reload')
+ condrestart 7
+ ;;
+
+ 'status')
+ service_status && exit 0 || exit $?
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
+ exit 1
+esac
diff --git a/system/netdata-openrc.in b/system/netdata-openrc.in
index 299db5699..55808364c 100755..100644
--- a/system/netdata-openrc.in
+++ b/system/netdata-openrc.in
@@ -1,4 +1,4 @@
-#!/sbin/runscript
+#!/sbin/openrc-run
# The user netdata is configured to run as.
# If you edit its configuration file to set a different
@@ -25,7 +25,7 @@ extra_started_commands="getconf"
pidfile="/run/netdata.pid"
command="${NETDATA_INSTALL_PATH}/usr/sbin/netdata"
command_background="yes"
-command_args="-pidfile ${pidfile} ${NETDATA_EXTRA_ARGS}"
+command_args="-P ${pidfile} ${NETDATA_EXTRA_ARGS}"
# start_stop_daemon_args="-u ${NETDATA_OWNER}"
start_stop_daemon_args=""
diff --git a/system/netdata.conf b/system/netdata.conf
index df7ea1abe..6108d9086 100644
--- a/system/netdata.conf
+++ b/system/netdata.conf
@@ -9,3 +9,6 @@
run as user = netdata
web files owner = root
web files group = netdata
+ # Netdata is not designed to be exposed to potentially hostile networks
+ # See https://github.com/firehol/netdata/issues/164
+ bind to = localhost
diff --git a/system/netdata.logrotate.in b/system/netdata.logrotate.in
index e77d5ff72..a026a8a51 100644
--- a/system/netdata.logrotate.in
+++ b/system/netdata.logrotate.in
@@ -6,16 +6,8 @@
delaycompress
notifempty
sharedscripts
- #
- # if you add netdata to your init.d/system.d
- # comment su & copytruncate and uncomment postrotate
- # to have netdata restart when logs are rotated
- su netdata
- copytruncate
- #
- #postrotate
- # if service netdata status > /dev/null ; then \
- # service netdata restart > /dev/null; \
- # fi;
- #endscript
+ create 0664 netdata netdata
+ postrotate
+ /bin/kill -HUP `pidof netdata 2>/dev/null` 2>/dev/null || true
+ endscript
}
diff --git a/system/netdata.service.in b/system/netdata.service.in
index 91db6122d..e260e2738 100644
--- a/system/netdata.service.in
+++ b/system/netdata.service.in
@@ -1,17 +1,15 @@
[Unit]
-Description=Linux real time system monitoring, over the web
+Description=Real time performance monitoring
After=network.target httpd.service squid.service nfs-server.service mysqld.service named.service postfix.service
[Service]
-Type=forking
-WorkingDirectory=/tmp
-User=root
-Group=root
-PIDFile=@localstatedir_POST@/run/netdata.pid
-ExecStart=@sbindir_POST@/netdata -pidfile @localstatedir_POST@/run/netdata.pid
-KillMode=mixed
-KillSignal=SIGTERM
-TimeoutStopSec=30
+Type=simple
+User=netdata
+Group=netdata
+ExecStart=@sbindir_POST@/netdata -D
+
+# saving a big db on slow disks may need some time
+TimeoutStopSec=60
[Install]
WantedBy=multi-user.target