Thursday 20 November 2014

Sitescope Unix CPU script monitor

CPU script monitor created after building a script and deploying the same in scripts.remote folder.

Script used:
Idle=`mpstat -P ALL 2 3 | grep ^Average | awk '{print $11}' | head -n 2 | tail -n 1`
Wait=`mpstat -P ALL 2 3 | grep ^Average | awk '{print $6}' | head -n 2 | tail -n 1`
echo "scale=2; 100-"${Idle}+${Wait}"" |  bc –l

Note : Here print $ value positions may change

Logic:
Here the 1st command fetches the 11th value in the average row say “A”
Second command fetches the 6th value in the average row say “B”
Third command adds the above two values (A+B) and subtracts the results from 100 to give the %utilization.

Formula:
%Utilization = 100 – (%Idle + %Wait)