added openrc startup
Costa Tsaousis (ktsaou) committed
Jan 30, 2016 at 15:05 UTC
f0e9e57ed96efadfe99389d4ad435e10b26b3213
3 files changed
+160
-7
conf.d/charts.d.conf
+42
-6
@@ -1,8 +1,44 @@
1
-nut=yes
2
-squid=yes
3
-postfix=yes
4
-sensors=yes
5
-cpufreq=yes
6
-mysql=yes
1
+#!/bin/sh
2
+
3
+# This is the configuration for charts.d.plugin
4
+
5
+# Each of its collectors can read configuration eiher from this file
6
+# or a NAME.conf file (where NAME is the collector name).
7
+# The collector specific file has higher precedence.
8
+
9
+# This file is a shell script too.
10
+
11
+# -----------------------------------------------------------------------------
12
+
13
+# number of seconds to run without restart
14
+# after this time, charts.d.plugin will exit
15
+# netdata will restart it, but a small gap
16
+# will appear in the charts.d.plugin charts.
17
+#restart_timeout=$[3600 * 4]
18
+
19
+# when making iterations, charts.d can loop more frequently
20
+# to prevent plugins missing iterations.
21
+# this is a percentage relative to update_every to align its
22
+# iterations.
23
+# The minimum is 10%, the maximum 100%.
24
+# So, if update_every is 1 second and time_divisor is 50,
25
+# charts.d will iterate every 500ms.
26
+# Charts will be called to collect data only if the time
27
+# passed since the last time the collected data is equal or
28
+# above their update_every.
29
+#time_divisor=50
30
+
31
+# -----------------------------------------------------------------------------
32
+
33
+# the default enable/disable for all charts.d collectors
34
+#enable_all_charts="yes"
35
+
36
+# per charts.d collector enable/disable
37
+#nut=yes
38
+#squid=yes
39
+#postfix=yes
40
+#sensors=yes
41
+#cpufreq=yes
42
+#mysql=yes
43
#example=yes
44
#load_average=yes
plugins.d/charts.d.plugin
+1
-1
@@ -77,7 +77,7 @@ charts_undescore="_"
77
# So, if update_every is 1 second and time_divisor is 50,
78
# charts.d will iterate every 500ms.
79
# Charts will be called to collect data only if the time
80
-# passes since the last time the collected data is equal or
80
+# passed since the last time the collected data is equal or
81
# above their update_every.
82
time_divisor=50
83
system/netdata-openrc
new
+117
@@ -0,0 +1,117 @@
1
+#!/sbin/runscript
2
+
3
+# The path netdata has been installed.
4
+# Leave it empty if netdata is installed in /
5
+NETDATA_INSTALL_PATH=${NETDATA_INSTALL_PATH-}
6
+
7
+# The user netdata is configured to run as.
8
+# If you edit its configuration file to set a different
9
+# user, set it here too, to have its files switch ownership
10
+NETDATA_OWNER=${NETDATA_OWNER-netdata:netdata}
11
+
12
+# The URL to download netdata config.
13
+NETDATA_CONFIG_URL=${NETDATA_CONFIG_URL-http://localhost:19999/netdata.conf}
14
+
15
+# The timeout in seconds to wait for netdata
16
+# to save its database on disk and exit.
17
+NETDATA_WAIT_EXIT_TIMEOUT=${NETDATA_WAIT_EXIT_TIMEOUT-15}
18
+
19
+# When set to 1, if netdata does not exit in
20
+# NETDATA_WAIT_EXIT_TIMEOUT, we will force it
21
+# to exit.
22
+NETDATA_FORCE_EXIT=${NETDATA_FORCE_EXIT-0}
23
+
24
+
25
+extra_started_commands="getconf"
26
+pidfile="/var/run/netdata/netdata.pid"
27
+command="${NETDATA_INSTALL_PATH}/usr/sbin/netdata"
28
+command_background="yes"
29
+
30
+depend() {
31
+ use logger
32
+ need net
33
+
34
+ # FIXME
35
+ # We should depend on these only if they are enabled:
36
+ # apache, squid, nginx, mysql, named, opensips, nut, hostapd, postfix, lm-sensors
37
+}
38
+
39
+start() {
40
+ local ret
41
+
42
+ if [ ! -d ${NETDATA_INSTALL_PATH}/var/cache/netdata ]
43
+ then
44
+ ebegin "Creating ${NETDATA_INSTALL_PATH}/var/cache/netdata"
45
+ mkdir -p ${NETDATA_INSTALL_PATH}/var/cache/netdata
46
+ chown ${NETDATA_OWNER} ${NETDATA_INSTALL_PATH}/var/cache/netdata
47
+ echo "${NETDATA_OWNER}" >${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner
48
+ eend $?
49
+ fi
50
+
51
+ if [ "$(cat ${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner 2>/dev/null)" != "${NETDATA_OWNER}" ]
52
+ then
53
+ ebegin "Switching ownership of ${NETDATA_INSTALL_PATH}/var/cache/netdata"
54
+ chown -R ${NETDATA_OWNER} ${NETDATA_INSTALL_PATH}/var/cache/netdata
55
+ echo "${NETDATA_OWNER}" >${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner
56
+ eend 0
57
+ fi
58
+
59
+ ebegin "Starting netdata"
60
+ start-stop-daemon --start --quiet --pidfile ${pidfile} --exec ${command} -- ${NETDATA_EXTRA_ARGS}
61
+ ret=$?
62
+ eend $ret
63
+
64
+ if [ $ret -eq 0 -a ! -f ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf ]
65
+ then
66
+ ebegin "Downloading default configuration to ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
67
+ sleep 2
68
+ curl -s -o ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new "${NETDATA_CONFIG_URL}"
69
+ ret=$?
70
+ if [ $ret -eq 0 -a -s ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new ]
71
+ then
72
+ mv ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf
73
+ else
74
+ ret=1
75
+ rm ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new 2>/dev/null
76
+ fi
77
+ eend $ret
78
+ fi
79
+}
80
+
81
+stop() {
82
+ local result ret=0 count=0 sigkill=0
83
+
84
+ ebegin "Stopping netdata"
85
+ start-stop-daemon --stop --quiet --pidfile ${pidfile}
86
+ result=$?
87
+ eend $result
88
+
89
+ ebegin "Waiting for netdata to save its database"
90
+ while [ -f "${pidfile}" ]
91
+ do
92
+ if [ $count -gt ${NETDATA_WAIT_EXIT_TIMEOUT} ]
93
+ then
94
+ sigkill=1
95
+ break
96
+ fi
97
+
98
+ count=$[count + 1]
99
+ kill -0 $(cat ${pidfile}) 2>/dev/null
100
+ ret=$?
101
+ test $ret -eq 0 && sleep 1
102
+ done
103
+ eend $sigkill
104
+
105
+ if [ $sigkill -eq 1 -a -f "${pidfile}" ]
106
+ then
107
+ ebegin "Netdata is taking too long to exit, forcing it to quit"
108
+ kill -SIGKILL $(cat ${pidfile}) 2>/dev/null
109
+ eend $?
110
+ fi
111
+}
112
+
113
+getconf() {
114
+ ebegin "Downloading configuration from netdata to /tmp/netdata.conf"
115
+ curl -o /tmp/netdata.conf "${NETDATA_CONFIG_URL}"
116
+ eend $?
117
+}