]> arthur.barton.de Git - netdata.git/commitdiff
added openrc startup
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 30 Jan 2016 13:05:43 +0000 (15:05 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 30 Jan 2016 13:05:43 +0000 (15:05 +0200)
conf.d/charts.d.conf
plugins.d/charts.d.plugin
system/netdata-openrc [new file with mode: 0755]

index 553e3ede64a1161a1a0c7734a34c0dfc4fa526b1..f284c3b77cc9e0164cc312aa82e7aa9e875f5067 100644 (file)
@@ -1,8 +1,44 @@
-nut=yes
-squid=yes
-postfix=yes
-sensors=yes
-cpufreq=yes
-mysql=yes
+#!/bin/sh
+
+# This is the configuration for charts.d.plugin
+
+# Each of its collectors can read configuration eiher from this file
+# or a NAME.conf file (where NAME is the collector name).
+# The collector specific file has higher precedence.
+
+# This file is a shell script too.
+
+# -----------------------------------------------------------------------------
+
+# number of seconds to run without restart
+# after this time, charts.d.plugin will exit
+# netdata will restart it, but a small gap
+# will appear in the charts.d.plugin charts.
+#restart_timeout=$[3600 * 4]
+
+# when making iterations, charts.d can loop more frequently
+# to prevent plugins missing iterations.
+# this is a percentage relative to update_every to align its
+# iterations.
+# The minimum is 10%, the maximum 100%.
+# So, if update_every is 1 second and time_divisor is 50,
+# charts.d will iterate every 500ms.
+# Charts will be called to collect data only if the time
+# passed since the last time the collected data is equal or
+# above their update_every.
+#time_divisor=50
+
+# -----------------------------------------------------------------------------
+
+# the default enable/disable for all charts.d collectors
+#enable_all_charts="yes"
+
+# per charts.d collector enable/disable
+#nut=yes
+#squid=yes
+#postfix=yes
+#sensors=yes
+#cpufreq=yes
+#mysql=yes
 #example=yes
 #load_average=yes
index db4dc0d8af5b44d46ea3bf9d689967f9d9dfec15..0210cfb4a75666af871d480d016d05585b5f518f 100755 (executable)
@@ -77,7 +77,7 @@ charts_undescore="_"
 # So, if update_every is 1 second and time_divisor is 50,
 # charts.d will iterate every 500ms.
 # Charts will be called to collect data only if the time
-# passes since the last time the collected data is equal or
+# passed since the last time the collected data is equal or
 # above their update_every.
 time_divisor=50
 
diff --git a/system/netdata-openrc b/system/netdata-openrc
new file mode 100755 (executable)
index 0000000..70d4da1
--- /dev/null
@@ -0,0 +1,117 @@
+#!/sbin/runscript
+
+# The path netdata has been installed.
+# Leave it empty if netdata is installed in /
+NETDATA_INSTALL_PATH=${NETDATA_INSTALL_PATH-}
+
+# The user netdata is configured to run as.
+# If you edit its configuration file to set a different
+# user, set it here too, to have its files switch ownership
+NETDATA_OWNER=${NETDATA_OWNER-netdata:netdata}
+
+# The URL to download netdata config.
+NETDATA_CONFIG_URL=${NETDATA_CONFIG_URL-http://localhost:19999/netdata.conf}
+
+# The timeout in seconds to wait for netdata
+# to save its database on disk and exit.
+NETDATA_WAIT_EXIT_TIMEOUT=${NETDATA_WAIT_EXIT_TIMEOUT-15}
+
+# When set to 1, if netdata does not exit in
+# NETDATA_WAIT_EXIT_TIMEOUT, we will force it
+# to exit.
+NETDATA_FORCE_EXIT=${NETDATA_FORCE_EXIT-0}
+
+
+extra_started_commands="getconf"
+pidfile="/var/run/netdata/netdata.pid"
+command="${NETDATA_INSTALL_PATH}/usr/sbin/netdata"
+command_background="yes"
+
+depend() {
+       use logger
+       need net
+
+       # FIXME
+       # We should depend on these only if they are enabled:
+       # apache, squid, nginx, mysql, named, opensips, nut, hostapd, postfix, lm-sensors
+}
+
+start() {
+       local ret
+
+       if [ ! -d ${NETDATA_INSTALL_PATH}/var/cache/netdata ]
+               then
+               ebegin "Creating ${NETDATA_INSTALL_PATH}/var/cache/netdata"
+               mkdir -p ${NETDATA_INSTALL_PATH}/var/cache/netdata
+               chown ${NETDATA_OWNER} ${NETDATA_INSTALL_PATH}/var/cache/netdata
+               echo "${NETDATA_OWNER}" >${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner
+               eend $?
+       fi
+
+       if [ "$(cat ${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner 2>/dev/null)" != "${NETDATA_OWNER}" ]
+               then
+               ebegin "Switching ownership of ${NETDATA_INSTALL_PATH}/var/cache/netdata"
+               chown -R ${NETDATA_OWNER} ${NETDATA_INSTALL_PATH}/var/cache/netdata
+               echo "${NETDATA_OWNER}" >${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner
+               eend 0
+       fi
+
+       ebegin "Starting netdata"
+       start-stop-daemon --start --quiet --pidfile ${pidfile} --exec ${command} -- ${NETDATA_EXTRA_ARGS}
+       ret=$?
+       eend $ret
+
+       if [ $ret -eq 0 -a ! -f ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf ]
+               then
+               ebegin "Downloading default configuration to ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
+               sleep 2
+               curl -s -o ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new "${NETDATA_CONFIG_URL}"
+               ret=$?
+               if [ $ret -eq 0 -a -s ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new ]
+                       then
+                       mv ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf
+               else
+                       ret=1
+                       rm ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new 2>/dev/null
+               fi
+               eend $ret
+       fi
+}
+
+stop() {
+       local result ret=0 count=0 sigkill=0
+
+       ebegin "Stopping netdata"
+       start-stop-daemon --stop --quiet --pidfile ${pidfile}
+       result=$?
+       eend $result
+
+       ebegin "Waiting for netdata to save its database"
+       while [ -f "${pidfile}" ]
+       do
+               if [ $count -gt ${NETDATA_WAIT_EXIT_TIMEOUT} ]
+                       then
+                       sigkill=1
+                       break
+               fi
+
+               count=$[count + 1]
+               kill -0 $(cat ${pidfile}) 2>/dev/null
+               ret=$?
+               test $ret -eq 0 && sleep 1
+       done
+       eend $sigkill
+
+       if [ $sigkill -eq 1 -a -f "${pidfile}" ]
+               then
+               ebegin "Netdata is taking too long to exit, forcing it to quit"
+               kill -SIGKILL $(cat ${pidfile}) 2>/dev/null
+               eend $?
+       fi
+}
+
+getconf() {
+       ebegin "Downloading configuration from netdata to /tmp/netdata.conf"
+       curl -o /tmp/netdata.conf "${NETDATA_CONFIG_URL}"
+       eend $?
+}