]>
git.ipfire.org Git - people/jschlag/ipfire-2.x.git/blob - src/initscripts/init.d/collectd
24187d21583649ef684eba6bc4289d6482cffa13
2 # Begin $rc_base/init.d/collecd
7 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/main
/settings
)
9 if [ "$RRDLOG" = '' ]; then
17 if ! mountpoint
$RRDLOG &>/dev
/null
; then
18 boot_mesg
"Mount rrd Ramdisk..."
19 if [ $
(find "$RRDLOG" |
wc -l) -ne 1 ]; then
20 backup_ramdisk
"$RRDLOG"
22 mount_ramdisk
"$RRDLOG"
25 #restore old values to ramdisk if exist
26 restore_ramdisk
"$RRDLOG"
29 restore_ramdisk
"$RRDLOG"
32 # If run from init and collectd alrady started then exit silent
33 if [ "$(basename $0)" != "collectd" ]; then
34 if [ "$(ps -A | grep " collectd$
")" != "" ]; then
39 # ARM does not support to scan for sensors. In that case,
40 # we create an empty configuration file.
42 if [ "${machine:0:3}" = "arm" ]; then
43 touch /etc
/sysconfig
/lm_sensors
46 # At first run search for sensors with sensors-detect
47 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
48 boot_mesg
"Searching for Sensors..."
50 # pre scan and try to load modules
51 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
52 if [ -e /etc
/sysconfig
/lm_sensors
]; then
55 .
/etc
/sysconfig
/lm_sensors
56 for modul
in $BUS_MODULES $HWMON_MODULES ; do
57 modprobe
$modul > /dev
/null
2>&1;
62 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
65 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
66 echo "#No Sensors detected " > /etc
/sysconfig
/lm_sensors
70 # Load sensor modules only first start
71 if [ ! -e /var
/lock
/sensors_modules
]; then
72 touch /var
/lock
/sensors_modules
74 boot_mesg
-n "Loading Sensor Modules: "
75 .
/etc
/sysconfig
/lm_sensors
76 for modul
in $BUS_MODULES $HWMON_MODULES ; do
77 modprobe
$modul > /dev
/null
2>&1;
79 boot_mesg
-n "$SUCCESS$modul$NORMAL ";
81 boot_mesg
-n "$WARNING$modul$NORMAL ";
88 # Enable sensors plugin if sensors found
89 if [ "$( sensors 2>&1 | grep 'No sensors found!' | wc -l )" == "1" ]; then
90 sed -i -e "s|^LoadPlugin sensors|#LoadPlugin sensors|g" /etc
/collectd.conf
92 sed -i -e "s|^#LoadPlugin sensors|LoadPlugin sensors|g" /etc
/collectd.conf
95 # Enable thermal plugin if thermal_zone found
96 if [ ! -e /sys
/class
/thermal
/thermal_zone0
]; then
97 sed -i -e 's|^include "/etc/collectd.thermal"$|#include "/etc/collectd.thermal"|g' /etc
/collectd.conf
99 sed -i -e 's|^#include "/etc/collectd.thermal"$|include "/etc/collectd.thermal"|g' /etc
/collectd.conf
102 # Enable swap plugin if swap found
103 if [ "$(swapon -s | wc -l)" == "0" ]; then
104 sed -i -e "s|^LoadPlugin swap|#LoadPlugin swap|g" /etc
/collectd.conf
106 sed -i -e "s|^#LoadPlugin swap|LoadPlugin swap|g" /etc
/collectd.conf
109 # sync after config update...
112 if [ $
(date +%Y
) -gt 2011 ]; then
113 boot_mesg
"Starting Collection daemon..."
114 /usr
/sbin
/collectd
-C /etc
/collectd.conf
117 boot_mesg
"collectd: cannot start with incorrect time ($(date))."
122 boot_mesg
"Stopping Collection daemon..."
123 killproc
/usr
/sbin
/collectd
125 backup_ramdisk
"$RRDLOG"
126 umount_ramdisk
"$RRDLOG"
127 # sync after backup...
136 statusproc
/usr
/sbin
/collectd
140 echo "Usage: $0 {start|stop|restart|status}"
145 # End $rc_base/init.d/collectd