
View previous topic :: View next topic 
Author 
Message 
seelye
Joined: 17 Sep 2005 Posts: 35 Location: USA

Posted: Thu Nov 30, 2017 3:31 pm Post subject: Tune up Reply Syntax using getnumber 


As part of a larger if/then/else setup I'm trying to get the numeric value from a the previous result of this test and subtract that from the most recent result
The background. I'm taking a numeric value from an SNMP GET of the UpTime Counter and doing a Tune up of the value to present the original TimeTicks along with a more human readable values. So my %Reply% after the Tune UP actually looks more like this
Ticks: 52154  Seconds: 521  Minutes: 8  Hours: 0 since last reboot
The above is easy. I've got that part.
However I want the UPTIME test to tell me when a device rebooted.
So I'm started with this:
['%Reply%' getnumber 1]
This is perfect I get the 52154 back. Remember %Reply% when used in Tune up, is the previous test cycle Reply, which is exactly what I want!
However I cannot seem to do anything else with that extracted number. When I try the following variations I get a 'Error in Expression'
[%SuggestedReply%  '%Reply%' getnumber 1]
[%SuggestedReply%  ['%Reply%' getnumber 1]]
[%SuggestedReply%  ('%Reply%' getnumber 1)]
I'm looking for the difference between the numbers and if it's less than Zero, I can confident the device rebooted. Granted this won't catch all device reboots but most and will work for my purposes.
I just cannot seem to determine the correct syntax. Can you help?
Ultimately I'll be using something like this: Bold being where I cannot get it to work
if ([%SuggestedReply%  '%Reply%' getnumber 1] < 0) Ticks: [%SuggestedReply%]  Seconds: [%SuggestedReply% div 100]  Minutes: [%SuggestedReply% div 6000]  Hours: [%SuggestedReply% div 360000] **REBOOTED**; else Ticks: [%SuggestedReply%]  Seconds: [%SuggestedReply% div 100]  Minutes: [%SuggestedReply% div 6000]  Hours: [%SuggestedReply% div 360000] since last reboot;
Alternatively, if I could do math in a Mail Template, I may be able to move all of this logic to the Mail Template, but the last I knew I couldn't do this kind of math in a Mail Template body.
Also, I found that the following from your documentation examples does NOT work
('wordA wordB 21.10,15.00' getnumber 2) NOTE the wrapping in parenthesis. it appears it really needs square bracks [ ] However that example with parenthesis was taken directly from the HTML Help documentation for HM in the Tune Up section. You may want to fix that 

Back to top 


KSSoft
Joined: 03 Apr 2002 Posts: 11934 Location: USA

Posted: Thu Nov 30, 2017 4:41 pm Post subject: 


if ('%SuggestedReply%' < ('%Reply%' getnumber 1)) Ticks: [%SuggestedReply%]  Seconds: [%SuggestedReply% div 100]  Minutes: [%SuggestedReply% div 6000]  Hours: [%SuggestedReply% div 360000] **REBOOTED**; else Ticks: [%SuggestedReply%]  Seconds: [%SuggestedReply% div 100]  Minutes: [%SuggestedReply% div 6000]  Hours: [%SuggestedReply% div 360000] since last reboot;
You don't need [] for if statement, just to set Reply value
Regards
Alex 

Back to top 


seelye
Joined: 17 Sep 2005 Posts: 35 Location: USA

Posted: Thu Nov 30, 2017 5:02 pm Post subject: 


Worked perfectly! I just couldn't see the forest!!! Thank you. HM is a wonderful thing!
And for the sake of anyone else reading this in the future, below is the final tuneup I used. It makes it very readable in the alert we send out: This all assume %SuggestedReply% div 100 = seconds. If your time counter is a different ratio then adjust accordingly.
if ('%SuggestedReply%' < ('%Reply%' getnumber 1)) [%SuggestedReply%] Ticks  [%SuggestedReply% div 8640000] Days, [(%SuggestedReply% mod 8640000) div 360000] Hours, [(%SuggestedReply% mod 360000) div 6000] Minutes, [(%SuggestedReply% mod 6000) div 100] seconds **REBOOTED**; else [%SuggestedReply%] Ticks  [%SuggestedReply% div 8640000] Days, [(%SuggestedReply% mod 8640000) div 360000] Hours, [(%SuggestedReply% mod 360000) div 6000] Minutes, [(%SuggestedReply% mod 6000) div 100] Seconds since last reboot;
Lots of math but the replies look like this:
151099 Ticks  0 Days, 0 Hours, 25 Minutes, 10 Seconds since last reboot
or
494 Ticks  0 Days, 0 Hours, 0 Minutes, 4 seconds **REBOOTED**
I then look for **REBOOTED** in %Reply in my custom send mail action.
Working well thus far. 

Back to top 


KSSoft
Joined: 03 Apr 2002 Posts: 11934 Location: USA

Posted: Fri Dec 01, 2017 9:41 am Post subject: 


You are welcome
Regards
Alex 

Back to top 




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
