Converting reply value from text to a value?

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).
mrw
Posts: 195
Joined: Mon Oct 08, 2012 6:11 am

Converting reply value from text to a value?

Post by mrw »

Hi,
I´m monitoring a QNAP(a nas device) using SNMP and every single value I get from that device is in textformat. Like: "102.5 MB", "59.20 %" and "34 C/93 F".
Is there a way to convert these in Hostmon to something I can set alert thresholds on?

Thanks,
//Andreas..
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You may use Oprional status procession options.
e.g. you may use "Use Warning status if" option with expressions like the following:
"%SuggestedReply%" < "50 MB"
or
"%SuggestedReply%" > "30 %"
HostMonitor can automatically handle and compare such values.
While reply, like "34 C/93 F" will be comapred as text!

In such case (for reply like "34 C/93 F"), you should use different expression:
("%SuggestedReply%" getword 1) > "40"

Please check for details at:
Use Warning status option: http://www.ks-soft.net/hostmon.eng/mfra ... ningstatus
Logical expressions: http://www.ks-soft.net/hostmon.eng/mfra ... m#userexpr
mrw
Posts: 195
Joined: Mon Oct 08, 2012 6:11 am

Post by mrw »

Thanks alot!

The test for the CPU Usage and temperatures work fine now!

But the free mem test doesn´t.
It reports "111.4 MB" and I´m using "%SuggestedReply%" < "15 MB" as Warning status.
With those settings and reply I get the status "Warning".

Any ideas why?

//Andreas..
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

That's because HostMonitor doesn't recognize "111.4" as number on your system.
It looks like you have different Decimal Separator, specified in system settings (e.g. comma , ).
You may change Windows Regional Settings to use point as decimal separator.
Please note, if HostMonitor is started as Application, Decimal Separator should be changed for user account under which HostMonitor is started.
If HostMonitor is started as Service, Decimal Separator should be changed for System account.
Also a lot of SNMP enabled devices can have several OIDs in different format for the same counter. You may check device manual to find corresponding OIDs that return simple integer values.
mrw
Posts: 195
Joined: Mon Oct 08, 2012 6:11 am

Post by mrw »

I changed the decimal separator as you suggested but it didn´t change anything I´m afraid. Hostmon runs as a service but that service uses the administrator account and not Local system. So I guess that changing this when logged in with the administrator account should change the separator setting?
If not then how do I change that for the System account??

But if the decimal separator was the issue here, wouldn´t I have the same problem checking for CPU usage? That reports 45.65% aswell and that test works.

And we haven´t found any OIDs for the QNAP that provides these values an integers, or any other format, so we´re stuck with these.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

But if the decimal separator was the issue here, wouldn´t I have the same problem checking for CPU usage? That reports 45.65% aswell and that test works.
CPU Usage test uses different protocol (not SNMP) and it does not receive text input at all; also it always shows integer numbers.
Probably you are talking about SNMP Get test method that retrieves some string counter?
Are you sure it is processed correctly all the time? If wrong decimal separator is used, HostMonitor will compare these values as strings. Strings compared like "5"<"9" and "55"<"9" as well.

Regards
Alex
mrw
Posts: 195
Joined: Mon Oct 08, 2012 6:11 am

Post by mrw »

Yes, the CPU Usage test I mentioned is not the builtin test in hostmon but simply a snmp test.

Well, I´m not entirely sure it´s working for the CPU usage but it looks that way. If I change the threshold value above and below the actual CPU value I get a warning or not.

But when I do the same for the memtest it doesn´t work.
Both tests are otherwise identical except that the cputest alerts when the value is above 98% and the mem free test alerts when its below 15MB, but that shouldn´t be a problem I guess?

I´m also using the "Use 'Normal' status if" (%FailureIteration% > 0) and (%FailureIteration% < 3) optional status if there´s some conflict somewhere?

Is there a way I can verify how Hostmon interprets the recieved string? So I know that it´s detecting the decimal separator correctly for instance?
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

I changed the decimal separator as you suggested but it didn´t change anything I´m afraid. Hostmon runs as a service but that service uses the administrator account and not Local system. So I guess that changing this when logged in with the administrator account should change the separator setting?
If not then how do I change that for the System account??
If HostMonitor is started as Service, Decimal Separator should be changed for Local system account:
1. Check/Change Decimal Separator for current user account (Control Panel> Region and Language> Format tab > Additional Settings)
2. Click the Administrative Tab
3. Click 'Copy to reserved accounts'
4. Select 'System accounts (local system, local service, and network service)'.
5. Click OK/Apply
6. Restart HosrMonitor Service.
mrw
Posts: 195
Joined: Mon Oct 08, 2012 6:11 am

Post by mrw »

Ok, did those changes so all accounts should definately use "." as decimal separator now.
But it didn´t change the outcome of the test I´m afraid.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Could you enable Tune Up Reply value option and specify the following variable:
%SuggestedReply_Integer%
If Reply will show non-zero value - HostMonitor is able to convert Reply.
Otherwise, there are two options:
- HostMonitor still "sees" non-point Decimal Separator on your system
- SNMP Reply includes some other characters that can prevent correct conversion.
Also a lot of SNMP enabled devices can have several OIDs in different format for the same counter. You may check device manual to find corresponding OIDs that return simple integer values.
Have you tried to check for different (corresponding) OIDs that return Integer values ?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Both tests are otherwise identical except that the cputest alerts when the value is above 98% and the mem free test alerts when its below 15MB, but that shouldn´t be a problem I guess?
Its not a problem if your string can be converted to number.
Otherwise 15 and 98 is a big difference for string comparision (string that starts with "9" always > string that start with "1", e.g. "9">"155")

You are using different formats in your posts... What exactly value do you see?
"15 MB" or "15MB" (without space)?
"98%" or "98 %" (without space)?
HostMonitor will not convert 15MB to a number, only "15 MB"

Regards
Alex
mrw
Posts: 195
Joined: Mon Oct 08, 2012 6:11 am

Post by mrw »

If I enable %SuggestedReply_Integer% as Tune up Reply I get a large numeric value. Got "120586240", instead of "119.8 MB". It looks like it converted the 119.8 MB string to bytes as integer.
That would mean it converts it correctly I guess?

If I activate %SuggestedReply_Integer% as Tune up Reply on the CPU usage test it converts "45.30 %" to 45.

Perhaps I should just use that value to check if it is below 15000000?
Seems more reliable than comparing two strings.
Or does the tune up occurs after the Alert check?

Or what do you suggest?
Have you tried to check for different (corresponding) OIDs that return Integer values ?
Yes, there are no other values beside these strings I´m afraid.

And sorry for not being clear.
The mem free snmp test always replies with "xxx.x MB" with a space.
The cpu usage snmp test always replies with "xx.xx %" also with a space.
Last edited by mrw on Fri Mar 01, 2013 2:11 am, edited 2 times in total.
mrw
Posts: 195
Joined: Mon Oct 08, 2012 6:11 am

Post by mrw »

Just tried to compare the tuned up result to check if lower than 15000000 but it still fails.

Could I have typed some wrong values in somewhere? Some silly error?
Or some conflict between the first Alert check and then the Optional status processing checks?

It also seems the the tests that should alert when the value is > my set value works, but not those that check if the value is < my set value.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

If I enable %SuggestedReply_Integer% as Tune up Reply I get a large numeric value. Got "120586240", instead of "119.8 MB". It looks like it converted the 119.8 MB string to bytes as integer.
That would mean it converts it correctly I guess?
Yes, %SuggestedReply_Integer%<>0, this means HostMonitor is able to conver "115.0 MB" string into number.
But 120586240 = 115 MB. Are you sure SNMP Agent returns "119.8 MB" string??
Perhaps I should just use that value to check if it is below 15000000?
Seems more reliable than comparing two strings.
Or does the tune up occurs after the Alert check?
"Tune Up" option does not effect "Use Warning status" option but you may use %SuggestedReply_Integer% variable in any expression (e.g. use it to set Warning status).
Just tried to compare the tuned up result to check if lower than 15000000 but it still fails.
Fails?
1) Do you mean expression '%SuggestedReply_Integer%'<15000000 does not set Warning status?
It should not set Warning status because 120586240 actually greater than 15000000
2) I have no idea how you can "compare the tuned up result to check ..."
"Tune Up Result" and "Use Warning status" - 2 different options.
Could I have typed some wrong values in somewhere? Some silly error?
How do we know? We don't see your settings. You may export test settings into text file and send to support@ks-soft.net, plus screen shot with Reply value...

Regards
Alex
mrw
Posts: 195
Joined: Mon Oct 08, 2012 6:11 am

Post by mrw »

But 120586240 = 115 MB. Are you sure SNMP Agent returns "119.8 MB" string??
Free mem obviously changed between refresh after the changes in the test..
Fails?
Ofcourse I mean Bad or Warning status.
Do you mean expression '%SuggestedReply_Integer%'<15000000 does not set Warning status?
It should not set Warning status because 120586240 actually greater than 15000000
I tried that and as you say it should not warn, but it does. And that´s the problem.
I have no idea how you can "compare the tuned up result to check ..."
I am apparently not precise enough in my explanations. I meant that I ran a test with Tune Up active and compared that with a test with Tune Up not activated. I thought that perhaps the Tune Up converted the result before the actual status check, but as you stated it is not. And so my comparison proved that to be correct.
You may export test settings into text file and send to support@ks-soft.net, plus screen shot with Reply value...
I will do that asap.

Thanks
//Andreas..
Post Reply