From 99f06a2e3c2b6e040895ac7fe5963ae7ba8298d5 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sun, 9 Dec 2018 13:38:50 +0100 Subject: bin/realtime-suggestions: Guarding against non-existing cpufreq dir in /sys, when running check_cpu_governor(). Mentioning default value in check_max_user_watches(). --- bin/realtime-suggestions | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/realtime-suggestions b/bin/realtime-suggestions index c5e7355..9235651 100755 --- a/bin/realtime-suggestions +++ b/bin/realtime-suggestions @@ -97,23 +97,28 @@ check_max_user_watches() { local minimum=524288 local proc_file="/proc/sys/fs/inotify/max_user_watches" if [ "$(cat "$proc_file")" -lt $minimum ]; then - echo "$change Consider increasing 'fs.inotify.max_user_watches>$minimum' - the maximum amount of files inotify can watch $sysctl_ref" + echo "$change Consider increasing 'fs.inotify.max_user_watches>$minimum' (default) - the maximum amount of files inotify can watch $sysctl_ref." fi } check_cpu_governor() { + local governor_dir="/sys/devices/system/cpu/cpufreq/" local cpupower_ref="(see \`man cpupower\` for reference)" local governor="" local policy_no="" local cpu_no="" - for governor_file in /sys/devices/system/cpu/cpufreq/policy*/scaling_governor; do - governor="$(cat "$governor_file")" - policy_no="$(echo "$governor_file"| cut -d'/' -f7)" - cpu_no="${policy_no//policy}" - if [[ "$governor" != "performance" ]]; then - echo "$change CPU $cpu_no has governor $governor set. Set it to 'performance' $cpupower_ref." - fi - done + if [ -d "${governor_dir}" ]; then + for governor_file in /sys/devices/system/cpu/cpufreq/policy*/scaling_governor; do + governor="$(cat "$governor_file")" + policy_no="$(echo "$governor_file"| cut -d'/' -f7)" + cpu_no="${policy_no//policy}" + if [[ "$governor" != "performance" ]]; then + echo "$change CPU $cpu_no has governor $governor set. Set it to 'performance' $cpupower_ref." + fi + done + else + echo "$warning Unable to detect any CPU governor on your machine. ${governor_dir} does not exist!" + fi } check_config_high_res_timers() { -- cgit v1.2.3-54-g00ecf