File: offbattery.cpufreq

package info (click to toggle)
apcupsd 3.14.14-7
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,904 kB
  • sloc: ansic: 24,826; cpp: 9,230; sh: 4,484; makefile: 1,200; tcl: 368; objc: 317; php: 107
file content (42 lines) | stat: -rwxr-xr-x 1,180 bytes parent folder | download | duplicates (10)
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
#!/bin/sh
#
# This shell script if placed in /etc/apcupsd will be
# called by /etc/apcupsd/apccontrol when the UPS goes
# back on to the mains after a power failure.
#
# We scale the CPU clock frequency to maximum and
# send an email message to root to notify him.
#
# NOTE: Assumes Linux-2.6.x kernel with CPUFREQ 
# support for your chipset. 
SYSADMIN=root
APCUPSD_MAIL="/bin/mail"

# Iterate over all CPUs, enabling the userspace governor
# and programming the current clock speed to the maximum.
# 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_max_freq > $CPU/scaling_setspeed
done

# Send an email to root
HOSTNAME=`hostname`
MSG="$HOSTNAME Power has returned"
#
(
   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