]>
git.ipfire.org Git - people/jschlag/ipfire-2.x.git/blob - src/initscripts/init.d/collectd
e5c35950d2dfdb4bf78d100472d6a3882e468e9b
2 # Begin $rc_base/init.d/collecd
7 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/main
/settings
)
9 if [ "$RRDLOG" = '' ]; then
16 boot_mesg
"Mounting RRD ramdisk..."
17 mount_ramdisk
"${RRDLOG}"
21 # If run from init and collectd alrady started then exit silent
22 if [ "$(basename $0)" != "collectd" ]; then
23 if [ "$(ps -A | grep " collectd$
")" != "" ]; then
28 # ARM does not support to scan for sensors. In that case,
29 # we create an empty configuration file.
31 if [ "${machine:0:3}" = "arm" ]; then
32 touch /etc
/sysconfig
/lm_sensors
35 # At first run search for sensors with sensors-detect
36 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
37 boot_mesg
"Searching for Sensors..."
39 # pre scan and try to load modules
40 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
41 if [ -e /etc
/sysconfig
/lm_sensors
]; then
44 .
/etc
/sysconfig
/lm_sensors
45 for modul
in $BUS_MODULES $HWMON_MODULES ; do
46 modprobe
$modul > /dev
/null
2>&1;
51 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
54 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
55 echo "#No Sensors detected " > /etc
/sysconfig
/lm_sensors
59 # Load sensor modules only first start
60 if [ ! -e /var
/lock
/sensors_modules
]; then
61 touch /var
/lock
/sensors_modules
63 boot_mesg
-n "Loading Sensor Modules: "
64 .
/etc
/sysconfig
/lm_sensors
65 for modul
in $BUS_MODULES $HWMON_MODULES ; do
66 modprobe
$modul > /dev
/null
2>&1;
68 boot_mesg
-n "$SUCCESS$modul$NORMAL ";
70 boot_mesg
-n "$WARNING$modul$NORMAL ";
77 # Enable sensors plugin if sensors found
78 if [ "$( sensors 2>&1 | grep 'No sensors found!' | wc -l )" == "1" ]; then
79 sed -i -e "s|^LoadPlugin sensors|#LoadPlugin sensors|g" /etc
/collectd.conf
81 sed -i -e "s|^#LoadPlugin sensors|LoadPlugin sensors|g" /etc
/collectd.conf
84 # Enable thermal plugin if thermal_zone found
85 if [ ! -e /sys
/class
/thermal
/thermal_zone0
]; then
86 sed -i -e 's|^include "/etc/collectd.thermal"$|#include "/etc/collectd.thermal"|g' /etc
/collectd.conf
88 sed -i -e 's|^#include "/etc/collectd.thermal"$|include "/etc/collectd.thermal"|g' /etc
/collectd.conf
91 # Enable swap plugin if swap found
92 if [ "$(swapon -s | wc -l)" == "0" ]; then
93 sed -i -e "s|^LoadPlugin swap|#LoadPlugin swap|g" /etc
/collectd.conf
95 sed -i -e "s|^#LoadPlugin swap|LoadPlugin swap|g" /etc
/collectd.conf
98 # sync after config update...
101 if [ $
(date +%Y
) -gt 2011 ]; then
102 boot_mesg
"Starting Collection daemon..."
103 /usr
/sbin
/collectd
-C /etc
/collectd.conf
106 boot_mesg
"collectd: cannot start with incorrect time ($(date))."
111 boot_mesg
"Stopping Collection daemon..."
112 killproc
/usr
/sbin
/collectd
115 # Umount the ramdisk (if any)
116 umount_ramdisk
"${RRDLOG}"
124 statusproc
/usr
/sbin
/collectd
128 echo "Usage: $0 {start|stop|restart|status}"
133 # End $rc_base/init.d/collectd