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