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