YAMVQ - Yet Another Macro Variable Question

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).
User avatar
greyhat64
Posts: 246
Joined: Fri Mar 14, 2008 9:10 am
Location: USA

YAMVQ - Yet Another Macro Variable Question

Post by greyhat64 »

OK, I'm ready to be embarrassed. I fixed one problem with formula syntax, but I think I've looked at this till I'm cross-eyed :o and can't see the obvious.

I want to set up an advanced action in my alert profile that emails a manager if
  • (assume a 10 minute test interval)
  • test is 'bad'
  • Test is unacknowledged for four or more hours
  • Note: I would like for this to occur once, but would settle for four hour increments.
So far I've played with various versions of:

Code: Select all

('%SimpleStatus%'=='DOWN' AND %AckRecurrences%==0) AND
(%CurrentStatusDuration_sec% > (%Interval_Sec%*3)) AND
((%CurrentStatusDuration_sec% mod 14400)<=%Interval_Sec%)
The %CurrentStatusDuration_sec% > (%Interval_Sec%*3) statement gets it past my simple "Start when 3 consecutive 'Bad' results occur" action.
I think my problem is with the 'mod' statement, but I've run aground trying to figure it out on my own. HELP!

Commentary: Boy it would be nice if I could have a simple "Start after ## min/hours of consecutive 'Bad' results occur" option to go with the "Start after ## consecutive 'Bad' results occur" option. :D

BTW - The 'Reset selected items' resets all counters I've encountered EXCEPT %CurrentStausDuration_sec%?
I'm not sure if that's a good thing or a bad thing :-?, just an observation, though there are times when I want to 'Flush all counters', including this one - like when I'm testing an advanced formula :wink:
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I think you just need to add couple parentheses..
('%SimpleStatus%'=='DOWN') AND (%AckRecurrences%==0) AND
(%CurrentStatusDuration_sec% > (%Interval_Sec%*3)) AND
((%CurrentStatusDuration_sec% mod 14400)<=%Interval_Sec%)
The 'Reset selected items' resets all counters I've encountered EXCEPT %CurrentStausDuration_sec%
This is correct behavior. "Reset" function resets statistic counter (i.e. history) while keeps test status, reply, recurrences and all related "current" counters.

Regards
Alex
User avatar
greyhat64
Posts: 246
Joined: Fri Mar 14, 2008 9:10 am
Location: USA

Post by greyhat64 »

Alex,
Thanks, just as I suspected - embarrassment :oops:
One other thing that's bugging me. The test method I was using to figure this out is a File/Folder exists test. Even when %SuggestedSimpleStatus% shows 'UP' or 'DOWN' the %Status% variable comes up 'Not tested'.

AHM v7.72 (I'm waiting on my production box 'till v8 )
As proof I inserted a 'Tune Reply' string of:

Code: Select all

['%Status%'] ['%SuggestedSimpleStatus%']  [%AckRecurrences%] [%CurrentStatusDuration_sec%] [%CurrentStatusDuration_sec% mod 1800] [%Interval_Sec%]
The most recent results, after a forced change of status - 'Not tested' 'DOWN' 0 9635 635 600. Even after multiple refreshes the %Status% variable comes up the same.

This goofs things up because the [%CurrentStatusDuration_sec% variable is based on the %Status% variable results. So why does it show as 'Not tested'?

Am I crazy or is this another known result that I'm puzzling over. :-?
Worse yet, is it something that has been addressed in a more recent version and I'm just behind the times? :x
Worst of all, have you already answered this question before and I just missed it? :evil: Yet another opportunity for embarrassment!
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Are you sure test was performed at least 2 times? What status do you see on screen?

Regards
Alex
User avatar
greyhat64
Posts: 246
Joined: Fri Mar 14, 2008 9:10 am
Location: USA

Post by greyhat64 »

Status column shows 'Bad'
I haven't changed the status since my last post. Current Reply:
'Not tested' 'DOWN' 0 10491 1491 600
I currently have it looking for a non-existant file.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

H'm... theoretically HostMonitor 7.72 should show "Checking" status when you are using %Status% variable for "tune up reply" expression. May be there was some mistake in the code. We changed this code in version 7.94+...
On the other hand, you should not use %Status% in this expression at all. You should use %SuggestedStatus% variable instead.

Regards
Alex
User avatar
greyhat64
Posts: 246
Joined: Fri Mar 14, 2008 9:10 am
Location: USA

Post by greyhat64 »

I realize that, but you miss the point. %CurrentStatusDuration_sec% never resets if %Status% doesn't change. (see previous examples)

So, now I set the test to Status:'OK' by providing the named file.
Reply Results: 'Not tested' 'UP' 0 12830 230 600.

As you can see the %CurrentStatusDuration_sec% variable just keeps marching along, oblivious to the real status change.

I would think that the 'Status' column in RCC is tied to the same logic as the %Status% variable, but that obviously isn't the case. How else could these be different?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

That because you are using variable in "Tune up Reply" expression.
Quote from the manual:
1) HostMonitor performs the test;
2) processes "Reverse alert" option;
3) sets "suggested" macro variables (%SuggestedStatus%, %SuggestedSimpleStatus%, %SuggestedReply%, %SuggestedRecurrences% and %FailureIteration%) without touching regular counters (%Status%, %Reply%, %Recurrences%, etc);
4) then HostMonitor evaluates "Warning", "Normal" and "Tune up Reply" expressions and finally modifies current test status, reply field and statistics counters (Status, Reply, Alive%, Passed tests, Failed tests, etc).
As you can see the %CurrentStatusDuration_sec% variable just keeps marching along, oblivious to the real status change
There is no "real status" defined yet. Just SuggestedStatus.

Regards
Alex
User avatar
greyhat64
Posts: 246
Joined: Fri Mar 14, 2008 9:10 am
Location: USA

Post by greyhat64 »

See, I knew there had to be a valid and equally embarrassing answer! :oops:
Thanks again, Alex for gently reminding me to RTM. I've actually read that several times, but it's yet to sink in. :o

So the follow up question is this - How do I best debug 'Advanced Alert' and other areas where I use complex or compounded formulas? It would be nice to see 'realtime' values for variables and the resulting 'answer' to the formula as you are building the formula. Or, at least, have a [Test] button to see the current result in the formula builder dialog box. It would sure save me a lot of time trying to find that missing % sign, or when I inverse '=>' for '>=', for instance.
Paul_NHS
Posts: 59
Joined: Wed Feb 25, 2009 6:17 am

Post by Paul_NHS »

I knew someone else would need an expression tester.
http://www.ks-soft.net/cgi-bin/phpBB/vi ... php?t=5187

cheers, Paul
User avatar
greyhat64
Posts: 246
Joined: Fri Mar 14, 2008 9:10 am
Location: USA

Post by greyhat64 »

Alex,
After sleeping on this something still doesn't make sense. I still don't see how the %CurrentStatusDuration_sec% does not reset at any time, even after multiple refreshes? I kinda understand %Status% being "Not tested" in the Tune up Reply, but if %CurrentStatusDuration_sec% is based on the actual Status (as seen in the Status column) it should change at some point. Could you explain - beyond the helps quote given earlier.

Paul_NHS,
Yeah, I saw your request earlier and thought about piping in on your thread, but saw an opportunity here to add teeth :D to it with this example. While we're at it why don't we ask for an HTML 'viewer' to use when we're composing mail body templates that render the page with the variables translated. - so we get a view of what it will look like before we commit the change.

BTW - I had a working update to the 'Freespace' script earlier this week and screwed it up by reworking some of the code to the point that I couldn't get back to where I was. And NO, I was too arrogant to have a backup :evil:
I'd love to share some other tricks with you sometime. At the moment I'm trying to pull together some best in class templates for different server types (IIS, Exchange, SharePoint, MSSQL, Apache, PostGRE, etc.) I've gotten some feedback from a couple of other avid users - you wanta join in? Once compiled I'll send 'em out to everyone that contributed. Eventually I'd like to post these for all to see.

Alex,
Have you thought about having a 'Members only' part of the Forum for this kind of exchange?
A sort of 'AHM Wiki' / AHM UsersGroup User driven area to vet out different thoughts, ideas, frustrations (there are so few, right?), templates, and 'Best Practices' models. Once settled the 'best of the best' could make it to the general knowledgebase that many of these forums (FAQ, Library, Reports) have become.
Additional features (chat, file exchange, etc.) could be added to that space that you generaly wouldn't want here.
It would be nice! :)
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

After sleeping on this something still doesn't make sense. I still don't see how the %CurrentStatusDuration_sec% does not reset at any time, even after multiple refreshes?
Have you used this variable for some action?
So the follow up question is this - How do I best debug 'Advanced Alert' and other areas where I use complex or compounded formulas? It would be nice to see 'realtime' values for variables and the resulting 'answer' to the formula as you are building the formula. Or, at least, have a [Test] button to see the current result in the formula builder dialog box. It would sure save me a lot of time trying to find that missing % sign, or when I inverse '=>' for '>=', for instance.
I don't see easy way to do this :roll:
Action can be assigned to hundreds of test items. Which one should be used for testing? Probably HostMonitor should provide some special test item and allow you to specify "run-time" test properties: status, reply, recurrences and even Alive%/Ded% counters... I have added task into "do to" list. Not sure when and how it will be implemented.
Have you thought about having a 'Members only' part of the Forum for this kind of exchange?
A sort of 'AHM Wiki' / AHM UsersGroup User driven area to vet out different thoughts, ideas, frustrations (there are so few, right?), templates, and 'Best Practices' models. Once settled the 'best of the best' could make it to the general knowledgebase that many of these forums (FAQ, Library, Reports) have become.
There are "Library", "Reports" and "Other" forums however I do not see much posts there.

Regards
Alex
User avatar
greyhat64
Posts: 246
Joined: Fri Mar 14, 2008 9:10 am
Location: USA

Post by greyhat64 »

See my earlier results - each following multiple 'Refreshes':
'Not tested' 'DOWN' 0 9635 635 600
'Not tested' 'DOWN' 0 10491 1491 600
'Not tested' 'UP' 0 12830 230 600
I set up another test, this time using an email body template with the following results:
Two strings:
First string - Simple %Status:%Reply%
Note: %Reply% uses the same variables found in the 'Tune up Reply' variable string:
XXXXX['%Status%'] ['%SuggestedSimpleStatus%'] [%AckRecurrences%] [%CurrentStatusDuration_sec%] _
XXXXX[%CurrentStatusDuration_sec% mod 1800] [%Interval_Sec%]

XXXXXResult: Ok:'UP' 0 94589 989 600

Second string - %AckRecurrences%:%CurrentStatusDuration_sec%:%Interval_Sec%

XXXXXResult: 0:4:600

Subsequent refreshes and changes of status show String1 continuing to increment the %CurrentStatusDuration_sec% while String2 resets it, as I would expect.
They act as if they are two different variables. While this might be the behavior you were expecting I can't, from a practical standpoint, see where this would be of any use to anyone. The first is no more than a 'lifetime' counter for the number of seconds the test has been in existence and active.

According to your last point:
4) then HostMonitor evaluates "Warning", "Normal" and "Tune up Reply" expressions and finally modifies current test status, reply field and statistics counters (Status, Reply, Alive%, Passed tests, Failed tests, etc).
That being the case, then the %CurrentStatusDuration_sec% variable in the %Reply% string should modify on the first refresh and (if I'm understanding this correctly) present itself correctly on the second refresh.
So why doesn't it?

I'll respond to your other responses in a later post. I want to get this behind me first - it's bugging me too much at this point to let it go.
Paul_NHS
Posts: 59
Joined: Wed Feb 25, 2009 6:17 am

Post by Paul_NHS »

Alex,
I'm trying to pull together some best in class templates for different server types
I would be really interested in the Exchange template.

cheers, Paul
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

1) Have you tried to use variables for the action? It works as it should, right?
2) Do you really need these variables for "Tune up Reply" option? Then we will make some changes in the code

Regards
Alex
Post Reply