Passing extra info from shell script to email action

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
Harry
Posts: 8
Joined: Wed Oct 10, 2018 12:05 am

Passing extra info from shell script to email action

Post by Harry »

We have several tests using a VB script to check some values in databases (like messages processed, log table records, status checks)
For example we have a reply from the test script "2 unprocessed messages in my_queue_table" which will trigger an alert action sending an mail using the %Reply% in the body.

The end of the current VB script which will pass the %status% and %reply% back to Hostmonitor:

Code: Select all

WScript.StdOut.Write statusBad 'const statusBad = "scriptRes:Bad:"
WScript.StdOut.Write replyText 'variable replyText filled from query result in first part of the script
But I'm looking for a way to pass more details / info back to HM, to use it in the email.
But only %status% and %reply% can be used.

For example, I'm looking at some kind of this output with record details in the mail fetched by the query in the VB script:
2 unprocessed messages in my_queue_table:
#1 11:09:53 Sender1 Destionation22 MsgTypeXYZ
#2 11:10:16 Sender2 Destionation33 MsgTypeABC
I was trying to use WScript.StdOut.WriteLine instead of Write. But only 1 line will be passed back to HM.
I thought another option was to use <BR> into the replyText. But this will result in unreadable / dirty reply values in HM it selves (with a whole list of 'lines'). And also the <BR> will be encoded as <br> into the mail body and shown as <BR> in the text instead of give a linefeed

I'm looking into a solution to pass more details into the alert email like an extra variable which could be set. For example set a variable like %ReplyFullDetails% with all the details build up in the script containing CR's. And then be used this %ReplyFullDetails% in the mail template. But as far I know you can not set any other variable (or misuse an existing one) in a test script.

Any suggestions?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Looks like we need new variable, something like %Reply_AsIs% or %Reply_withBRtags% so HostMonitor will not process <br> tags when you use variable in HTML report or HTML e-mail.
What version of HostMonitor do you use?
Could you please send your registration name or order number to support@ks-soft.net?

Regards
Alex
Harry
Posts: 8
Joined: Wed Oct 10, 2018 12:05 am

Post by Harry »

Thanks for your reply and your suggestion.
Currently using v 11.97 and will send you the registration details.

Is it also possible to catch the script output with line breaks into the the new %New_Reply_Variable% variable?
And to fill the current %Reply% value only with the first line as it is now.
Or fill the %New_Reply_Variable% with full details in another way?
For example

Code: Select all

WScript.StdOut.Write statusBad
WScript.StdOut.WriteLine "2 unprocessed messages in my_queue_table:" 'This line will come into the %Reply% value
'after line break the next values wont come into the %Reply% value
'Loop trough the records
WScript.StdOut.WriteLine record_id record_time record_sender record_dest record_type "<BR> or /c/r " 'This lines will come into the %New_Reply_Variable% value
Advantage is that the short/simple/normal %Reply% value will be presented in the GUI without a lot of text / lines / details and will be easier to handle in conditions in other steps. And the full reply is available in the mail actions.

Also want to suggest for processing the html tags (<BR> in this case) to make a checkbox in the mail template or mail action properties "Process variables as is" to disable processing any HTML tags instead of make 1 variable specific for 1 html tag like the %Reply_withBRtags% suggest to do
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

We sent you update, added %Reply_AsIs%
We will not change script behavior, at least in version 11, may be in version 12..

Regards
Alex
Harry
Posts: 8
Joined: Wed Oct 10, 2018 12:05 am

Post by Harry »

Thanks for the %Reply_AsIs% extension. This will answer my requirements to put more script output data into a mail from alert profile in a bit structured way.
For the long term I like the idea to manipulate / fill more variables from the scripting host. But I understood this can not be delivered in the current version.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

We sent you e-mail with another update and instructions how to setup test for your needs.

Regards
Alex
Kris
Posts: 375
Joined: Wed May 12, 2010 3:22 am

Post by Kris »

Interesting 8)

Is this feature available in the 11.99 beta version?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

No
If you need update, please send request to support@ks-soft.net

Regards
Alex
Harry
Posts: 8
Joined: Wed Oct 10, 2018 12:05 am

Post by Harry »

KS-Soft wrote:We sent you e-mail with another update and instructions how to setup test for your needs.
Thanks for the suggestion, I've implemented this and will start 'playing' with some variations.

Really appreciate the quick response and making small modifications!
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You are welcome

Regards
Alex
Post Reply