Kaseya Community

Send email based on custom field

  • Hello,

     

    I've made a custom field in machine info. In this field i put an email address.

    Based on that address i made a procedure that will read that field with SQL VIEW DATA. vSystemInfoManual/Email

    When a server is went offline it need to send a mail by running the script. But if a server is offline it cant send mail so the script is running on the local kserver. But if the script start running i get the following error:

     

    FAILED in processing THEN step 1, Get Variable, with error SQL query failed to return data in GetVariable task, SELECT Email FROM vSystemInfoManual WHERE (Machine_GroupID=''kaseya.root.kserver'')

    that is true because the emailfield on that server is empty. So i need to run a mailscript when server A is down on the KServer with the emailcontact of server A.

     

     

     

  • seems like if you're just tring to email yourself when a server goes off-line you could use the agent status alert under monitoring. Something so obvious leaves me to beleive that you're running something (script/procedure) other then just an email against the off-line server. If that's the case, run the agent procedure from within the alert section still  and instead of trying to use a sql query just set up some global variables and put your email addresses there and you're set. That would be easier in my opinion, plus you can run the scripts against any server not just your kserver and the global var's you can assign to anywhere as well. Hope this helps

  • i imagine (or my perception anyway) the idea here is that the email is different per client and as such using a global variable will still present the same issue... if you can't run the script against an offline agent how do you customise the alert email to go to the relevant client email address.

  • If you were to set the action to Run Script xyz on your KServer, then pass some of the Alert Variables to script xyz, would that not work? I have not tested it, but this was the first option I thought of when I saw this. Here is a link to the Alert Variables.

    http://help.kaseya.com/WebHelp/EN/VSA/6020000/4240.htm

     



    [edited by: jchamness at 3:03 PM (GMT -7) on 3-22-2012] Wrong link posted previously
  • If the agent is offline, other than being alerted to that fact, what do you want an agent procedure to do?

    Perhaps srozemuller is not aware of the offline alerting. Sroze did you know about this feature and that you can have each agent send to individually specified email addresses when they go offline?

  • mmartin: we fill in an other address than the address representing that network. So an external address like gmail or something.

    danrche: We are working with policies  that monitors the agent status. If we fill in the address in the monitoring part we have to create different policies. A policy for each customer. we want to have one policy with  a script in it that runs when a server goes offline. it have to send a mail to the address which is filled in into the custom field.

    jchamness: if i fill in the custom field i get the mail variable. So the address is know by the script. Only if i run the script on the offline server it see the correct address. But an offline server cant send mail. so you have to get the variable of the offline server and run the script on the Kserver. But if run it know the script will capture the variable of the Kserver and not of the offline server.

    ghettomaster: if the server goes offline. it have to send a mail to some address (filled in into the custom field.) We have now different policies (each per customer) to send mail when an agent goes offline. We want to generalize it to one policy and update the customers info to send the mail.

  • You must ensure the script called that will send the email runs on any other machine that you can guarantee will always be on .. so the VSA is a good choice.

    As the script is initiated by the VSA for the machine going offline then the actual machine id i.e. #id# and other variables will flow through to the script even though it is actually running on another machine .. which also means the script can  retrieve variables from views  which in your case would be an email address stored in a custom field

    This works perfectly .. the only caveat is that the script should not be "Run Now" from the agent procedure menu as I suspect you will have other variables used within your email that relate to the alarm condition ... and as these would not be present if you do a Run Now the script would more than likely fail with no email been sent.

    Cheers

    Paul

  • Paul do you have an example for that.