Issue with Tune up and if else statement

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
genasea
Posts: 28
Joined: Wed Sep 25, 2002 6:00 pm

Issue with Tune up and if else statement

Post by genasea »

Hello,

I am using HM v.11.98

I am attempting to parse a snmp oid that returns values like the following:

F-RMQL*66th_Main^CC+RM0195XYZ%R$01

Where I want to pull out the CC near the middle of this string (I am obtaining the next two characters after the ^ character is found). I can do this with the tune up reply function, but the issue is I want to modify the reply as the following:

if 'CC' then Comm Closet
if 'CF' then Comm Facility

I am getting the CC just fine, but I cannot get it to match on my if statement:

Here is my syntax:

if ([substr('%SuggestedReply%',indexof('%SuggestedReply%','^')+1,2)]="CC") Comm Closet; if ([substr('%SuggestedReply%',indexof('%SuggestedReply%','^')+1,2)]="CF") Comm Facility; else [substr('%SuggestedReply%',indexof('%SuggestedReply%','^')+1,2)]

I have also tried this syntax:

if (getword([substr('%SuggestedReply%',indexof('%SuggestedReply%','^')+1,2)],1)=='CC') Comm Closet; if (getword([substr('%SuggestedReply%',indexof('%SuggestedReply%','^')+1,2)],1)=='CF') Comm Facility; else [substr('%SuggestedReply%',indexof('%SuggestedReply%','^')+1,2)]

In each case, the reply field in HM returns CC (which should match on the first if stmt, but something is wrong in my syntax so it is executing the 'else' portion of the syntax)

I have also tried different variations on the =="CC" (== CC, == 'CC', =='CC', = CC, = 'CC', = "CC", =CC, ='CC', ="CC") - however, none of these has any affect on the outcome.

What am I doing wrong?

thank you
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

String functions cannot be used in IF (statement) - substr, indexof, replace
While string operators can be used - getword, endword, getnumberwithdot, etc.

You can tune up Reply using simple expression like
[substr('%SuggestedReply%',indexof('%SuggestedReply%','^')+1,2)]

If reply from SNMP agent could have space charactes like "F-RMQL*66th_Main ^CC +RM0195XYZ%R$01"
then you could use IF expressions with getword operator, e.g.
if (('%SuggestedReply%' getword 2)=='^CC') Comm Closet; if (('%SuggestedReply%' getword 2)=='^CF') Comm Facility; else [substr('%SuggestedReply%',indexof('%SuggestedReply%','^')+1,2)]

Regards
Alex
genasea
Posts: 28
Joined: Wed Sep 25, 2002 6:00 pm

Post by genasea »

Alex, thank you for your response. I got the new syntax working as you suggested based upon changing the snmp format.

Also, for anyone else stumbling across this post. If you want to use getword to extract a value from a string by itself (not using getword as part of an IF statement), you MUST place it in square brackets like this:

this works - ['%SuggestedReply%' getword 1]

This does not work - ('%SuggestedReply%' getword 1)
and this does not work - '%SuggestedReply%' getword 1

However, when using getword as part or an if statement, parenthesis or square brackets will work

this works - if (('%SuggestedReply%' getword 1)=='x')

Thank you
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Yes, use () for IF statements, use [] for other expressions that should be calculated. Do not use any brackets if you need just text.

Regards
Alex
Post Reply