Tune Up Question - Scaling/Decimal Point

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
timn
Posts: 184
Joined: Thu Nov 20, 2003 9:57 am
Location: United States

Tune Up Question - Scaling/Decimal Point

Post by timn »

I'm calling Linux shell script "SYSTEM: Average Load for past 5 minutes". It returns the system load without a decimal point. For example, if system load is "1.14", script returns "114".

To restore original decimal point, I have used the following TUNE UP string:
[%SuggestedReply% div 100].[%SuggestedReply% mod 100]
This works well UNLESS fractional part of the system load is between 0.01 and 0.09. For example, system load of 1.08 becomes 1.8

What is the easiest way to restore my missing decimal point?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You may modify Shell Script
#!/bin/sh
if [ $# -ge 1 ]
then
uptime | awk '{load=substr($(NF-1),1,4)remove *100; if (load>'$1') {printf("ScriptRes:Bad:%2.2f\n",load)} else {printf("ScriptRes:Ok:%2.2f\n",load)}; exit;}'
else
echo 'ScriptRes:Unknown:not enough parameters specified'
fi

Another solution, use "Tune up reply" option. Expression should look like
['%SuggestedReply%' div 100].['%SuggestedReply%' mod 100 div 10]['%SuggestedReply%' mod 10]

Regards
Alex
timn
Posts: 184
Joined: Thu Nov 20, 2003 9:57 am
Location: United States

Post by timn »

Alex,

Just tried both of your suggestions. Both work equally well! Thanks so much. AHM rocks. :D

Now I think it's clear I should start learning awk. I beginning to see the infinite possibilities here.
Post Reply