The following script will return the average CPU utilization (averaged over number of CPU's) for system, user and total utilization. It could easily be modified to be a feed into MRTG for graphing purposes.
Script
#
# Sample glance script showing average CPU utilization across all CPU's
#
headersprinted = 0
total_total = 0
total_sys = 0
total_user = 0
count = 0
# For each CPU
cpu loop {
# print headers if this is the first row
if headersprinted == 0 then {
print " Sys CPU User CPU Total CPU"
headersprinted = 1
}
total_total=total_total+GBL_CPU_TOTAL_UTIL
total_sys=total_sys+GBL_CPU_SYS_MODE_UTIL
total_user=total_user+GBL_CPU_USER_MODE_UTIL
count = count + 1
}
print total_sys/count, " ", total_user/count, " ", total_total/count
Output
# glance -j 5 -adviser_only -syntax cpu.cfg -iterations 3
Welcome to GlancePlus
Sys CPU User CPU Total CPU
8 30 38
Sys CPU User CPU Total CPU
5 31 35
Sys CPU User CPU Total CPU
4 24 28
Glance Adviser Script - Averaged over # of CPU's
sábado, 21 de julho de 2012
Labels: GlancePlus