]>
git.ipfire.org Git - people/jschlag/ipfire-2.x.git/blob - src/initscripts/init.d/collectd
2 # Begin $rc_base/init.d/collecd
8 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/main
/settings
)
9 eval $
(/usr
/local
/bin
/readhash
/etc
/sysconfig
/ramdisk
)
11 if [ "$RRDLOG" = '' ]; then
17 if [ "$FORCE" == '1' ] ||
[ "$(mem_amount)" -gt "490" ];then
19 if ! mountpoint
$RRDLOG &>/dev
/null
; then
20 boot_mesg
"Mount rrd Ramdisk..."
21 if [ $
(find "$RRDLOG" |
wc -l) -ne 1 ]; then
22 backup_ramdisk
"$RRDLOG"
24 mount_ramdisk
"$RRDLOG"
27 if [ -e $RRDLOG.bak
/cron
/new.root
]; then
28 if [ -e $RRDLOG.bak
/cron
/root
]; then
29 rm -f $RRDLOG.bak
/cron
/new.root
32 #restore old values to ramdisk if exist
33 restore_ramdisk
"$RRDLOG"
36 restore_ramdisk
"$RRDLOG"
39 # Move /var/spool/cron to ramdisk and make a symlink
41 if [ ! -L /var
/spool
/cron
]; then
42 mv /var
/spool
/cron
/var
/log
/rrd
/cron
43 ln -s /var
/log
/rrd
/cron
/var
/spool
/cron
46 # If run from init and collectd alrady started then exit silent
47 if [ "$(basename $0)" != "collectd" ]; then
48 if [ "$(ps -A | grep " collectd$
")" != "" ]; then
53 # ARM does not support to scan for sensors. In that case,
54 # we create an empty configuration file.
56 if [ "${machine:0:3}" = "arm" ]; then
57 touch /etc
/sysconfig
/lm_sensors
60 # At first run search for sensors with sensors-detect
61 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
62 boot_mesg
"Searching for Sensors..."
64 # pre scan and try to load modules
65 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
66 if [ -e /etc
/sysconfig
/lm_sensors
]; then
69 .
/etc
/sysconfig
/lm_sensors
70 for modul
in $BUS_MODULES $HWMON_MODULES ; do
71 modprobe
$modul > /dev
/null
2>&1;
76 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
79 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
80 echo "#No Sensors detected " > /etc
/sysconfig
/lm_sensors
84 # Load sensor modules only first start
85 if [ ! -e /var
/lock
/sensors_modules
]; then
86 touch /var
/lock
/sensors_modules
88 boot_mesg
-n "Loading Sensor Modules: "
89 .
/etc
/sysconfig
/lm_sensors
90 for modul
in $BUS_MODULES $HWMON_MODULES ; do
91 modprobe
$modul > /dev
/null
2>&1;
93 boot_mesg
-n "$SUCCESS$modul$NORMAL ";
95 boot_mesg
-n "$WARNING$modul$NORMAL ";
102 # Enable sensors plugin if sensors found
103 if [ "$( sensors 2>&1 | grep 'No sensors found!' | wc -l )" == "1" ]; then
104 sed -i -e "s|^LoadPlugin sensors|#LoadPlugin sensors|g" /etc
/collectd.conf
106 sed -i -e "s|^#LoadPlugin sensors|LoadPlugin sensors|g" /etc
/collectd.conf
109 # Enable thermal plugin if thermal_zone found
110 if [ ! -e /sys
/class
/thermal
/thermal_zone0
]; then
111 sed -i -e 's|^include "/etc/collectd.thermal"$|#include "/etc/collectd.thermal"|g' /etc
/collectd.conf
113 sed -i -e 's|^#include "/etc/collectd.thermal"$|include "/etc/collectd.thermal"|g' /etc
/collectd.conf
116 # Enable swap plugin if swap found
117 if [ "$(swapon -s | wc -l)" == "0" ]; then
118 sed -i -e "s|^LoadPlugin swap|#LoadPlugin swap|g" /etc
/collectd.conf
120 sed -i -e "s|^#LoadPlugin swap|LoadPlugin swap|g" /etc
/collectd.conf
123 # sync after config update...
126 if [ $
(date +%Y
) -gt 2011 ]; then
127 boot_mesg
"Starting Collection daemon..."
128 /usr
/sbin
/collectd
-C /etc
/collectd.conf
131 boot_mesg
"collectd: cannot start with incorrect time ($(date))."
136 boot_mesg
"Stopping Collection daemon..."
137 killproc
/usr
/sbin
/collectd
139 backup_ramdisk
"$RRDLOG"
140 umount_ramdisk
"$RRDLOG"
141 # sync after backup...
150 statusproc
/usr
/sbin
/collectd
154 echo "Usage: $0 {start|stop|restart|status}"
159 # End $rc_base/init.d/collectd