I have a requirement to send emails to a list of users in a database. So I have an application which writes the emaillist to a local file on the hostmonitor machine. Is there a way to set a global macro variable with the contents of this file using HMScript? If not is there a way to set global macro variable from a system environment variable using HMScript?
I would really appreciate a quick response. Thanks
setting global variable from a file
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Re: setting global variable from a file
Could you be more specific, please?
Your script should be like this:
Regards,
Max
Do you just need to send emails out or you need to send it using Send E-mail action depending on certain test status?pgeorge wrote:I have a requirement to send emails to a list of users in a database.
Which format does such file have? One email address per line? Or all email adresses in one line, separated by ';'?pgeorge wrote:So I have an application which writes the emaillist to a local file on the hostmonitor machine.
Yes, it is. You may use SetUserVariable command. http://www.ks-soft.net/hostmon.eng/mfra ... #actScriptpgeorge wrote:Is there a way to set a global macro variable with the contents of this file using HMScript?
Your script should be like this:
Code: Select all
SetUserVariable udv_custom_name_mail custom@mail.com
SaveUserVariables
Sorry, HMS script engine does not resolve environment variables.pgeorge wrote:If not is there a way to set global macro variable from a system environment variable using HMScript?
Regards,
Max
thanks for the response. The requirement is when the one of the customer's web sites are down for X minutes, the customers who are enrolled in the system should get email saying that the system is down. Again when the system comes up again the customers should get a mail that the system is up. So I have created tests to monitor the sites and when the test fails twice, then send out the mail. I am using a global macro variable for the "to" address in the mail and I need to set this variable at run time. I have a web service which returns the email addresses of the customers from the database. If that web service fails too, then the system sends mails to a predefined administrator address. Now on the host monitor what is the best way to acheive this? I created an application which calls the web service and sets the environment variable, but since environment variables cannot be accessed from hm script this will not work. I could create a file with comma seperated email addresses , but I do not know how to open the file and use SetUserVariable for a variable using hmscript. Is there a way to call the webservice and get the value returned to set the global macro variable? I would appreciate any help.
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
I think I would suggest you simplified way. As you know, "Send e-mail" action allows you to use macro variables: http://www.ks-soft.net/hostmon.eng/mfra ... .htm#macro
For each test, you should specify certain email address (or more than one destination addresses separating with a semicolon) into Comment input box. Then you should create an action profile with Send E-mail action and specify %CommentLine1% variable into "To" input box of Action Properties window. So, now you may assign such action profile to any test, and HostMonitor will send e-mails to the recipient, which is specified within "Comment" field of the test.
If all alerts in certain folder should be sent with one certain subject, you may specify the text for subject into Folder Comment input box and use %FCommentLine% variable in "Action Propertis" window.
Does it suit your needs?
Regards,
Max
For each test, you should specify certain email address (or more than one destination addresses separating with a semicolon) into Comment input box. Then you should create an action profile with Send E-mail action and specify %CommentLine1% variable into "To" input box of Action Properties window. So, now you may assign such action profile to any test, and HostMonitor will send e-mails to the recipient, which is specified within "Comment" field of the test.
If all alerts in certain folder should be sent with one certain subject, you may specify the text for subject into Folder Comment input box and use %FCommentLine% variable in "Action Propertis" window.
Does it suit your needs?
Regards,
Max