/usr/share/doc/apcupsd/examples/onbattery.cpufreq is in apcupsd-doc 3.14.10-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #!/bin/sh
#
# This shell script if placed in /etc/apcupsd will be
# called by /etc/apcupsd/apccontrol when the UPS goes
# on batteries.
#
# We scale the CPU clock frequency back to save power
# and send an email message to root to notify him.
#
# NOTE: Assumes Linux-2.6.x kernel with CPUFREQ
# support for your chipset. Enable appropriate
# modprobe line below to match your hardware.
SYSADMIN=root
APCUPSD_MAIL="/bin/mail"
# Load the appropriate cpufreq module. This is best done
# in boot scripts, but throw it here to make sure it has
# been done.
modprobe p4_clockmod
#modprobe cpufreq-nforce2
#modprobe powernow-k6
#modprobe powernow-k8
#modprobe speedstep-smi
# Give the cpufreq module a chance to initialize
sleep 1
# Iterate over all CPUs, enabling the userspace governor
# and programming the current clock speed to the minimum.
# This is redundant on hyperthread siblings, but it
# doesn't hurt anything and it keeps the code simple.
for CPU in /sys/devices/system/cpu/cpu*/cpufreq ; do
echo -n userspace > $CPU/scaling_governor
cat $CPU/scaling_min_freq > $CPU/scaling_setspeed
done
# Send an email to root
HOSTNAME=`hostname`
MSG="$HOSTNAME Power Failure!"
#
(
echo "Subject: $MSG"
echo " "
echo "$MSG"
echo " "
for CPU in `ls -1 /sys/devices/system/cpu` ; do
echo -n "$CPU freq scaled to "
cat /sys/devices/system/cpu/$CPU/cpufreq/scaling_setspeed | tr -d '\n'
echo " MHz"
done
echo " "
/sbin/apcaccess status
) | $APCUPSD_MAIL -s "$MSG" $SYSADMIN
exit 0
|