]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/init.d/collectd
Fix ip-up sometime generate wrong host entry if ping.ipfire.org could not resolved
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / collectd
CommitLineData
a332b303
CS
1#!/bin/sh
2# Begin $rc_base/init.d/collecd
3
4
5. /etc/sysconfig/rc
6. $rc_functions
7
1c163c04
CS
8eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
9
f6b79dd2
CS
10if [ "$RRDLOG" = '' ]; then
11 RRDLOG=/var/log/rrd
12fi
13
a332b303
CS
14case "$1" in
15 start)
a68a74cb 16 # At first run search for sensors with sensors-detect
a3f2742f 17 if [ ! -e /etc/sysconfig/lm_sensors ]; then
1c163c04
CS
18 boot_mesg "Searching for Sensors..."
19 "yes" | /usr/sbin/sensors-detect > /dev/null
20 evaluate_retval
21
22 if [ ! -e /etc/sysconfig/lm_sensors ]; then
23 echo "#No Sensors detected " > /etc/sysconfig/lm_sensors
1c163c04 24 fi
a3f2742f
AF
25 fi
26
27 boot_mesg -n "Loading Sensor Modules..."
438bdd5b 28 for modul in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
1c163c04
CS
29 modprobe $modul > /dev/null 2>&1;
30 if [ ${?} = 0 ]; then
31 boot_mesg -n "$SUCCESS$modul$NORMAL ";
32 else
33 boot_mesg -n "$FAILURE$modul$NORMAL ";
34 fi
a3f2742f
AF
35 done
36 boot_mesg;
37 echo_ok;
38
a68a74cb
AF
39 # Enable sensors plugin if sensors found
40 if [ $( sensors 2>&1 | grep "No sensors found!" | wc -l ) == "1" ]; then
41 sed -i -e "s|^LoadPlugin sensors|#LoadPlugin sensors|g" /etc/collectd.conf
42 else
43 sed -i -e "s|^#LoadPlugin sensors|LoadPlugin sensors|g" /etc/collectd.conf
44 fi
45
46 # Enable thermal plugin if thermal_zone found
47 if [ ! -e /sys/class/thermal/thermal_zone0 ]; then
48 sed -i -e "s|^LoadPlugin thermal|#LoadPlugin thermal|g" /etc/collectd.conf
49 else
50 sed -i -e "s|^#LoadPlugin thermal|LoadPlugin thermal|g" /etc/collectd.conf
51 fi
52
53 # Enable swap plugin if swap found
54 if [ "$(swapon -s | wc -l)" == "1" ]; then
55 sed -i -e "s|^LoadPlugin swap|#LoadPlugin swap|g" /etc/collectd.conf
56 else
57 sed -i -e "s|^#LoadPlugin swap|LoadPlugin swap|g" /etc/collectd.conf
58 fi
59
a332b303
CS
60 boot_mesg "Starting Collection daemon..."
61 /usr/sbin/collectd -C /etc/collectd.conf
62 evaluate_retval
a332b303 63 ;;
a332b303 64 stop)
d34d9f3b
AF
65 # Save the ramdisk at manual stop but not at shutdown
66 if [ "$(basename $0)" == "collectd" ]; then
1bc535b6 67 /etc/init.d/tmpfs backup
d34d9f3b 68 fi
a332b303
CS
69 boot_mesg "Stopping Collection daemon..."
70 killproc /usr/sbin/collectd
71 evaluate_retval
72 ;;
a332b303 73 restart)
1c163c04 74 ${0} stop
a332b303 75 sleep 1
1c163c04
CS
76 ${0} start
77 ;;
a332b303
CS
78 status)
79 statusproc /usr/sbin/collectd
80 ;;
81
82 *)
83 echo "Usage: $0 {start|stop|restart|status}"
84 exit 1
85 ;;
86esac
87
88# End $rc_base/init.d/collectd