KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Issue with Tune up and if else statement

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
genasea



Joined: 25 Sep 2002
Posts: 27

PostPosted: Sat Feb 01, 2020 11:25 am    Post subject: Issue with Tune up and if else statement Reply with quote

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
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12793
Location: USA

PostPosted: Sun Feb 02, 2020 11:54 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
genasea



Joined: 25 Sep 2002
Posts: 27

PostPosted: Tue Feb 04, 2020 1:19 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12793
Location: USA

PostPosted: Tue Feb 04, 2020 2:16 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index