]>
git.ipfire.org Git - people/ms/ipfire-2.x.git/blob - src/initscripts/system/collectd
2 # Begin $rc_base/init.d/collecd
7 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/main
/settings
)
10 touch /var
/lock
/sensors_search
11 # pre scan and try to load modules
12 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
13 if [ -e /etc
/sysconfig
/lm_sensors
]; then
16 .
/etc
/sysconfig
/lm_sensors
17 for modul
in $BUS_MODULES $HWMON_MODULES ; do
18 modprobe
$modul > /dev
/null
2>&1;
23 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
25 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
26 echo "#No Sensors detected " > /etc
/sysconfig
/lm_sensors
28 rm /var
/lock
/sensors_search
31 if [ "$RRDLOG" = '' ]; then
38 boot_mesg
"Mounting RRD ramdisk..."
39 mount_ramdisk
"${RRDLOG}"
43 # If run from init and collectd alrady started then exit silent
44 if [ "$(basename $0)" != "collectd" ]; then
45 if [ "$(ps -A | grep " collectd$
")" != "" ]; then
50 # ARM does not support to scan for sensors. In that case,
51 # we create an empty configuration file.
53 if [ "${machine:0:3}" = "arm" ]; then
54 touch /etc
/sysconfig
/lm_sensors
56 if [ "${machine:0:7}" = "aarch64" ]; then
57 touch /etc
/sysconfig
/lm_sensors
60 # Do not search for sensors when running on AWS
61 if [ -e "/var/run/aws-instance-id" ]; then
62 touch /etc
/sysconfig
/lm_sensors
65 # At first run search for sensors with sensors-detect
66 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
67 # Don't run at next boot again
68 touch /etc
/sysconfig
/lm_sensors
69 boot_mesg
-n "Searching for Sensors..."
74 if [ -e /var
/lock
/sensors_search
]; then
75 for (( i
=1; i
<30; i
++)) do
76 if [ ! -e /var
/lock
/sensors_search
]; then
85 # Load sensor modules only first start
86 if [ ! -e /var
/lock
/sensors_modules
]; then
87 touch /var
/lock
/sensors_modules
89 boot_mesg
-n "Loading Sensor Modules: "
90 .
/etc
/sysconfig
/lm_sensors
91 for modul
in $BUS_MODULES $HWMON_MODULES ; do
92 modprobe
$modul > /dev
/null
2>&1;
94 boot_mesg
-n "$SUCCESS$modul$NORMAL ";
96 boot_mesg
-n "$WARNING$modul$NORMAL ";
103 # Enable sensors plugin if sensors found
104 if [ "$( sensors 2>&1 | grep 'No sensors found!' | wc -l )" == "1" ]; then
105 sed -i -e "s|^LoadPlugin sensors|#LoadPlugin sensors|g" /etc
/collectd.conf
107 sed -i -e "s|^#LoadPlugin sensors|LoadPlugin sensors|g" /etc
/collectd.conf
110 # Enable thermal plugin if thermal_zone found
111 if [ ! -e /sys
/class
/thermal
/thermal_zone0
]; then
112 sed -i -e 's|^include "/etc/collectd.thermal"$|#include "/etc/collectd.thermal"|g' /etc
/collectd.conf
114 sed -i -e 's|^#include "/etc/collectd.thermal"$|include "/etc/collectd.thermal"|g' /etc
/collectd.conf
117 # Enable cpufreq plugin if cpufreq found
118 if [ ! -e /sys
/devices
/system
/cpu
/cpu
0/cpufreq
/scaling_cur_freq
]; then
119 sed -i -e "s|^LoadPlugin cpufreq|#LoadPlugin cpufreq|g" /etc
/collectd.conf
121 sed -i -e "s|^#LoadPlugin cpufreq|LoadPlugin cpufreq|g" /etc
/collectd.conf
124 # Enable swap plugin if swap found
125 if [ "$(swapon -s | wc -l)" == "0" ]; then
126 sed -i -e "s|^LoadPlugin swap|#LoadPlugin swap|g" /etc
/collectd.conf
128 sed -i -e "s|^#LoadPlugin swap|LoadPlugin swap|g" /etc
/collectd.conf
131 # sync after config update...
134 if [ $
(date +%Y
) -gt 2011 ]; then
135 boot_mesg
"Starting Collection daemon..."
136 /usr
/sbin
/collectd
-C /etc
/collectd.conf
139 boot_mesg
"collectd: cannot start with incorrect time ($(date))."
144 boot_mesg
"Stopping Collection daemon..."
145 killproc
/usr
/sbin
/collectd
148 # Umount the ramdisk (if any)
149 umount_ramdisk
"${RRDLOG}"
157 statusproc
/usr
/sbin
/collectd
161 # Backup all data if ramdisk is used
162 if mountpoint
"${RRDLOG}" &>/dev
/null
; then
168 echo "Usage: $0 {start|stop|restart|status|backup}"
173 # End $rc_base/init.d/collectd