]>
git.ipfire.org Git - people/pmueller/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
)
9 if [ "$RRDLOG" = '' ]; then
16 boot_mesg
"Mounting RRD ramdisk..."
17 mount_ramdisk
"${RRDLOG}"
21 # If run from init and collectd alrady started then exit silent
22 if [ "$(basename $0)" != "collectd" ]; then
23 if [ "$(ps -A | grep " collectd$
")" != "" ]; then
28 # ARM does not support to scan for sensors. In that case,
29 # we create an empty configuration file.
31 if [ "${machine:0:3}" = "arm" ]; then
32 touch /etc
/sysconfig
/lm_sensors
34 if [ "${machine:0:7}" = "aarch64" ]; then
35 touch /etc
/sysconfig
/lm_sensors
38 # Do not search for sensors when running on AWS
39 if [ -e "/var/run/aws-instance-id" ]; then
40 touch /etc
/sysconfig
/lm_sensors
43 # At first run search for sensors with sensors-detect
44 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
45 boot_mesg
"Searching for Sensors..."
47 # pre scan and try to load modules
48 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
49 if [ -e /etc
/sysconfig
/lm_sensors
]; then
52 .
/etc
/sysconfig
/lm_sensors
53 for modul
in $BUS_MODULES $HWMON_MODULES ; do
54 modprobe
$modul > /dev
/null
2>&1;
59 "yes" |
/usr
/sbin
/sensors-detect
> /dev
/null
62 if [ ! -e /etc
/sysconfig
/lm_sensors
]; then
63 echo "#No Sensors detected " > /etc
/sysconfig
/lm_sensors
67 # Load sensor modules only first start
68 if [ ! -e /var
/lock
/sensors_modules
]; then
69 touch /var
/lock
/sensors_modules
71 boot_mesg
-n "Loading Sensor Modules: "
72 .
/etc
/sysconfig
/lm_sensors
73 for modul
in $BUS_MODULES $HWMON_MODULES ; do
74 modprobe
$modul > /dev
/null
2>&1;
76 boot_mesg
-n "$SUCCESS$modul$NORMAL ";
78 boot_mesg
-n "$WARNING$modul$NORMAL ";
85 # Enable sensors plugin if sensors found
86 if [ "$( sensors 2>&1 | grep 'No sensors found!' | wc -l )" == "1" ]; then
87 sed -i -e "s|^LoadPlugin sensors|#LoadPlugin sensors|g" /etc
/collectd.conf
89 sed -i -e "s|^#LoadPlugin sensors|LoadPlugin sensors|g" /etc
/collectd.conf
92 # Enable thermal plugin if thermal_zone found
93 if [ ! -e /sys
/class
/thermal
/thermal_zone0
]; then
94 sed -i -e 's|^include "/etc/collectd.thermal"$|#include "/etc/collectd.thermal"|g' /etc
/collectd.conf
96 sed -i -e 's|^#include "/etc/collectd.thermal"$|include "/etc/collectd.thermal"|g' /etc
/collectd.conf
99 # Enable cpufreq plugin if cpufreq found
100 if [ ! -e /sys
/devices
/system
/cpu
/cpu
0/cpufreq
/scaling_cur_freq
]; then
101 sed -i -e "s|^LoadPlugin cpufreq|#LoadPlugin cpufreq|g" /etc
/collectd.conf
103 sed -i -e "s|^#LoadPlugin cpufreq|LoadPlugin cpufreq|g" /etc
/collectd.conf
106 # Enable swap plugin if swap found
107 if [ "$(swapon -s | wc -l)" == "0" ]; then
108 sed -i -e "s|^LoadPlugin swap|#LoadPlugin swap|g" /etc
/collectd.conf
110 sed -i -e "s|^#LoadPlugin swap|LoadPlugin swap|g" /etc
/collectd.conf
113 # sync after config update...
116 if [ $
(date +%Y
) -gt 2011 ]; then
117 boot_mesg
"Starting Collection daemon..."
118 /usr
/sbin
/collectd
-C /etc
/collectd.conf
121 boot_mesg
"collectd: cannot start with incorrect time ($(date))."
126 boot_mesg
"Stopping Collection daemon..."
127 killproc
/usr
/sbin
/collectd
130 # Umount the ramdisk (if any)
131 umount_ramdisk
"${RRDLOG}"
139 statusproc
/usr
/sbin
/collectd
143 # Backup all data if ramdisk is used
144 if mountpoint
"${RRDLOG}" &>/dev
/null
; then
150 echo "Usage: $0 {start|stop|restart|status|backup}"
155 # End $rc_base/init.d/collectd