HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: //opt/perf/examples/adviser/cpu_util_adv
# The below adviser script outputs the per CPU usage of the system.
# This script runs as a console app similar to 'top'. It helps to detect
# which CPU cores are most used in each interval and the nature of usage (sys/user).
# A color of 'Red' indicates the CPU core is operating at a higher rate than the set 
# thresholds. 

# Invoke this script as :
# glance -aos cpu_util_adv



# cpu_util_adv : cpu-usage-by-color
exec "clear"
print "--------"
print " "
print gbl_stattime
total_util_per_cpu_threshold = 10
user_util_per_cpu_threshold = 6
sys_util_per_cpu_threshold = 4

exec "echo -e \"\\033[1mProcessor #: \\033[0m\\c\""
cpu loop
exec "echo -e \"", bycpu_id|5|0, " \\c\""
print ""
exec "echo -e \"\\033[1mtotal util: \\033[0m\\c\""
cpu loop
if (bycpu_cpu_total_util > total_util_per_cpu_threshold) then {
exec "echo -e \"\\033[0;31m", bycpu_cpu_total_util|6|2, "\\033[0m\\c\""
} else {
exec "echo -e \"\\033[0;32m", bycpu_cpu_total_util|6|2, "\\033[0m\\c\""
}
print " global = ", gbl_cpu_total_util, "%"
exec "echo -e \"\\033[1muser util:  \\033[0m\\c\""
cpu loop
if (bycpu_cpu_user_mode_util > user_util_per_cpu_threshold) then {
exec "echo -e \"\\033[0;31m", bycpu_cpu_user_mode_util|6|2, "\\033[0m\\c\""
} else {
exec "echo -e \"\\033[0;32m", bycpu_cpu_user_mode_util|6|2, "\\033[0m\\c\""
}
print " global = ", gbl_cpu_user_mode_util, "%"
exec "echo -e \"\\033[1msystem util:\\033[0m\\c\""
cpu loop
if (bycpu_cpu_sys_mode_util > sys_util_per_cpu_threshold) then {
exec "echo -e \"\\033[0;31m", bycpu_cpu_sys_mode_util|6|2, "\\033[0m\\c\""
} else {
exec "echo -e \"\\033[0;32m", bycpu_cpu_sys_mode_util|6|2, "\\033[0m\\c\""
}
print " global = ", gbl_cpu_sys_mode_util, "%"
print " "
# use time metrics to compare with normalized utils:
exec "echo -e \"\\033[1muser time:  \\033[0m\\c\""
cpu loop
exec "echo -e \"", bycpu_cpu_user_mode_time|6|0, "\\c\""
print " global = ", gbl_cpu_user_mode_time, "s"
exec "echo -e \"\\033[1msystem time:\\033[0m\\c\""
cpu loop
exec "echo -e \"", bycpu_cpu_sys_mode_time|6|0, "\\c\""
print " global = ", gbl_cpu_sys_mode_time, "s"