]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/init.d/collectd
Fixed connection tracking bug (also in Core 27).
[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 18 boot_mesg "Searching for Sensors..."
5b55f2f8 19
888541fc 20 # pre scan and try to load modules
5b55f2f8 21 "yes" | /usr/sbin/sensors-detect > /dev/null
888541fc
AF
22 if [ -e /etc/sysconfig/lm_sensors ]; then
23 # Module load
24 for modul in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
25 modprobe $modul > /dev/null 2>&1;
26 done
27 fi
5b55f2f8 28
888541fc 29 # Final scan
1c163c04
CS
30 "yes" | /usr/sbin/sensors-detect > /dev/null
31 evaluate_retval
32
33 if [ ! -e /etc/sysconfig/lm_sensors ]; then
34 echo "#No Sensors detected " > /etc/sysconfig/lm_sensors
1c163c04 35 fi
a3f2742f
AF
36 fi
37
888541fc 38 boot_mesg -n "Loading Sensor Modules: "
438bdd5b 39 for modul in `cat /etc/sysconfig/lm_sensors | grep '^MODULE_' | cut -d"=" -s -f2`; do
1c163c04
CS
40 modprobe $modul > /dev/null 2>&1;
41 if [ ${?} = 0 ]; then
42 boot_mesg -n "$SUCCESS$modul$NORMAL ";
43 else
888541fc 44 boot_mesg -n "$WARNING$modul$NORMAL ";
1c163c04 45 fi
a3f2742f
AF
46 done
47 boot_mesg;
48 echo_ok;
49
a68a74cb
AF
50 # Enable sensors plugin if sensors found
51 if [ $( sensors 2>&1 | grep "No sensors found!" | wc -l ) == "1" ]; then
52 sed -i -e "s|^LoadPlugin sensors|#LoadPlugin sensors|g" /etc/collectd.conf
53 else
54 sed -i -e "s|^#LoadPlugin sensors|LoadPlugin sensors|g" /etc/collectd.conf
55 fi
56
57 # Enable thermal plugin if thermal_zone found
58 if [ ! -e /sys/class/thermal/thermal_zone0 ]; then
59 sed -i -e "s|^LoadPlugin thermal|#LoadPlugin thermal|g" /etc/collectd.conf
60 else
61 sed -i -e "s|^#LoadPlugin thermal|LoadPlugin thermal|g" /etc/collectd.conf
62 fi
63
64 # Enable swap plugin if swap found
65 if [ "$(swapon -s | wc -l)" == "1" ]; then
66 sed -i -e "s|^LoadPlugin swap|#LoadPlugin swap|g" /etc/collectd.conf
67 else
68 sed -i -e "s|^#LoadPlugin swap|LoadPlugin swap|g" /etc/collectd.conf
69 fi
70
a332b303
CS
71 boot_mesg "Starting Collection daemon..."
72 /usr/sbin/collectd -C /etc/collectd.conf
73 evaluate_retval
a332b303 74 ;;
a332b303 75 stop)
d34d9f3b
AF
76 # Save the ramdisk at manual stop but not at shutdown
77 if [ "$(basename $0)" == "collectd" ]; then
1bc535b6 78 /etc/init.d/tmpfs backup
d34d9f3b 79 fi
a332b303
CS
80 boot_mesg "Stopping Collection daemon..."
81 killproc /usr/sbin/collectd
82 evaluate_retval
83 ;;
a332b303 84 restart)
1c163c04 85 ${0} stop
a332b303 86 sleep 1
1c163c04
CS
87 ${0} start
88 ;;
a332b303
CS
89 status)
90 statusproc /usr/sbin/collectd
91 ;;
92
93 *)
94 echo "Usage: $0 {start|stop|restart|status}"
95 exit 1
96 ;;
97esac
98
99# End $rc_base/init.d/collectd