forked from gwsystems/sledge-serverless-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpu_governor.sh
executable file
·58 lines (47 loc) · 1.06 KB
/
cpu_governor.sh
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
55
#!/bin/sh
# This script can check current cpu freq, scale it up or down.
# Provides help to user on how to use this script
usage() {
echo "usage $0 <check||up||down/>"
echo " check Check governor status"
echo " up Scale up"
echo " down Scale down"
}
# Check governor status
check() {
echo "CPU governor status: "
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
echo "CPU current freqs: "
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
echo "CPU available governors: "
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors
}
# Scale up
scale_up() {
echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
}
# Scale down
scale_down() {
echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
}
if [ $# -ne 1 ]; then
echo "incorrect number of arguments: $*"
usage "$0"
exit 1
fi
case $1 in
check)
check
;;
up)
scale_up
;;
down)
scale_down
;;
*)
echo "invalid option: $1"
usage "$0"
exit 1
;;
esac