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