]>
git.ipfire.org Git - people/jschlag/ipfire-2.x.git/blob - src/initscripts/init.d/collectd
bdb5ca2f0bcebf0dd095717dca65b24a47566627
2 # Begin $rc_base/init.d/collecd
8 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/main
/settings
)
10 if [ "$RRDLOG" = '' ]; then
16 # If run from init and collectd alrady started then exit silent
17 if [ "$(basename $0)" != "collectd" ]; then
18 if [ "$(ps -A | grep " collectd$
")" != "" ]; then
23 # ARM does not support to scan for sensors. In that case,
24 # we create an empty configuration file.
26 if [ "${machine:0:3}" = "arm" ]; then
27 touch /etc
/sysconfig
/lm_sensors
30 # At first run search for sensors with sensors-detect
31 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
32 boot_mesg
"Searching for Sensors..."
34 # pre scan and try to load modules
35 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
36 if [ -e /etc
/sysconfig
/lm_sensors
]; then
38 for modul
in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
39 modprobe
$modul > /dev
/null
2>&1;
44 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
47 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
48 echo "#No Sensors detected " > /etc
/sysconfig
/lm_sensors
52 # Load sensor modules only first start
53 if [ ! -e /var
/lock
/sensors_modules
]; then
54 touch /var
/lock
/sensors_modules
55 boot_mesg
-n "Loading Sensor Modules: "
56 for modul
in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
57 modprobe
$modul > /dev
/null
2>&1;
59 boot_mesg
-n "$SUCCESS$modul$NORMAL ";
61 boot_mesg
-n "$WARNING$modul$NORMAL ";
68 # Enable sensors plugin if sensors found
69 if [ "$( sensors 2>&1 | grep 'No sensors found!' | wc -l )" == "1" ]; then
70 sed -i -e "s|^LoadPlugin sensors|#LoadPlugin sensors|g" /etc
/collectd.conf
72 sed -i -e "s|^#LoadPlugin sensors|LoadPlugin sensors|g" /etc
/collectd.conf
75 # Enable thermal plugin if thermal_zone found
76 if [ ! -e /sys
/class
/thermal
/thermal_zone0
]; then
77 sed -i -e 's|^include "/etc/collectd.thermal"$|#include "/etc/collectd.thermal"|g' /etc
/collectd.conf
79 sed -i -e 's|^#include "/etc/collectd.thermal"$|include "/etc/collectd.thermal"|g' /etc
/collectd.conf
82 # Enable swap plugin if swap found
83 if [ "$(swapon -s | wc -l)" == "1" ]; then
84 sed -i -e "s|^LoadPlugin swap|#LoadPlugin swap|g" /etc
/collectd.conf
86 sed -i -e "s|^#LoadPlugin swap|LoadPlugin swap|g" /etc
/collectd.conf
89 boot_mesg
"Starting Collection daemon..."
90 /usr
/sbin
/collectd
-C /etc
/collectd.conf
94 boot_mesg
"Stopping Collection daemon..."
95 killproc
/usr
/sbin
/collectd
97 # Save the ramdisk at manual stop but not at shutdown
98 if [ "$(basename $0)" == "collectd" ]; then
99 /etc
/init.d
/tmpfs backup
108 statusproc
/usr
/sbin
/collectd
112 echo "Usage: $0 {start|stop|restart|status}"
117 # End $rc_base/init.d/collectd