3 # This shell script if placed in /etc/apcupsd will be
4 # called by /etc/apcupsd/apccontrol when the UPS goes
7 # We scale the CPU clock frequency back to save power
8 # and send an email message to root to notify him.
10 # NOTE: Assumes Linux-2.6.x kernel with CPUFREQ
11 # support for your chipset. Enable appropriate
12 # modprobe line below to match your hardware.
14 APCUPSD_MAIL
="/bin/mail"
16 # Load the appropriate cpufreq module. This is best done
17 # in boot scripts, but throw it here to make sure it has
20 #modprobe cpufreq-nforce2
23 #modprobe speedstep-smi
25 # Give the cpufreq module a chance to initialize
28 # Iterate over all CPUs, enabling the userspace governor
29 # and programming the current clock speed to the minimum.
30 # This is redundant on hyperthread siblings, but it
31 # doesn't hurt anything and it keeps the code simple.
32 for CPU
in /sys
/devices
/system
/cpu
/cpu
*/cpufreq
; do
33 echo -n userspace
> $CPU/scaling_governor
34 cat $CPU/scaling_min_freq
> $CPU/scaling_setspeed
37 # Send an email to root
39 MSG
="$HOSTNAME Power Failure!"
46 for CPU
in `ls -1 /sys/devices/system/cpu` ; do
47 echo -n "$CPU freq scaled to "
48 cat /sys
/devices
/system
/cpu
/$CPU/cpufreq
/scaling_setspeed |
tr -d '\n'
52 /sbin
/apcaccess status
53 ) |
$APCUPSD_MAIL -s "$MSG" $SYSADMIN