Kaseya Community

Variable for Service Name

  • HI All,

     

    I'm trying to create an agent procedure that will check to see if a service is running.  The issue is that I won't know the service name every time.  Is there a way to pass the Log object Name from the Alarm to the agent procedure method for checking a services?

     

    Thanks for the Help

    Steven 

  • hummm, I think I can help you.... can you give me some more info.... are you triggering this all from an alarm? if so what are you looking at, alarm from the assign monitoring or an event set?

    At quick glance I'd use a vbscript as a trigger pushed from the alarm to do all the work. You can use wmi calls in the vbs to find the service from a log file (or event log) and use that to create a variable, send that to a simple Win32_service query and output to stdout which can be reclaimed by Kaseya via the "Execute Shell Command - Get Results to Variable".

    What service changes names? or is this the same service but named differently on each system you're monitoring across?

  • I'm triggering this from an alarm that is checking service.  When I add a new server to Kaseya I do an update list by scan.  Then I add that to monitor set.   So the service is a different name on each server.  What I really need is something to check if the service is back up after the alarm and then send me email.  The only way I know how to get an up alarm is by do an agent procedure to check if the service is running then if it is I send an email say the service is up.  

    Thanks

  • AHHHH ok, I think I get it now.

    You are currently set up to receive email alerts showing the service went down. You'd like to also have an email when it comes back up as well, but would like it to be generic so that you can kick it off on an alert and use it for every service you're monitoring/alerting on. Correct?

  • Yes that is correct.  

  • I can give you a script that writes to an email, or a log file all services that are in the started or running state. I'll have to look a bit deeper for something to reference the alert to find the service. I'm fairly sure there's a way to do that though. give me a day or so to look into this. I think we could use this ourselves.

  • Thank you so much.  I know there is a variable #ln# that passes the log object name which is the service name.  The issue is can't pass to any thing but the send email method in the agent procedure.

    Thanks for all the help.

  • smwein,

    running through some command line settings This is DO_ABLE ! I'm heading home for the day, but will have something for you to test with tomorrow. I'll post it with instructions.

  • Another option would be to instead of generating an alarm with the Service Monitoring to execute an Agent procedure.

    What this will mean is you will need a matching agent procedure for each service monitor set. If you do it this way then you can specify the variables in each matching agent procedure. Something that you could add to your Agent Procedure is a fake process that could trigger an Alarm via Process monitoring set for if the Agent Procedure is unable to remedy the service issue.

    An easy to use  function that allows passing Variables from Monitor Alarm would be a handy feature, many Advanced Monitoring systems can do this out of the box and I think it was a feature request that I have raised a few times with Kaseya.

  • Thanks HardKnoX I'm trying avoid making agent procedure for each service.  I want generic agent procedure base on an alarm.  

  • I use a monitoring set that monitors for *ALL auto services, and if one fails, instead of sending an e-mail it kicks off a script I created. The variable that's built into Kaseya for the service name that the alarm is generated for is #ln#. My script has a bunch of If-Then statements where it checks if #ln# is equal to a bunch of services we've deemed ignorable, like ShellHWDetection, TBS, sppscv, etc... It will then try to start the service using that #ln# variable again in a command line step, then it waits a few minutes and checks if that service is running. If it is, the script stops, if it's not, then the script sends an e-mail to our NOC so we can look into it.



    [edited by: kcears at 7:31 AM (GMT -7) on 10-27-2011] typed server instead of service in a few places
  • I believe you could use one of the SQL views for this as well, but I have not tried it. There is a view under the Monitor Alarm Group for vMonitorAlarmService that will provide you with the Service name. I will see if I can put some time to this and test it out. I will post back my findings. I think the only hurdle would be how many open alarms you currently have, and making sure that the specific one will be the one that is run in the procedure. There is an event time field that may be able to assist in this.

  • @smwein I personally don't think what you asking for is possible with the current available functionality in Kaseya and/or without a great deal of investigation and work that may or may not pay off however I hope you guys can figure it out as it sure would be great if it is possible and wish you best of luck :)

  •  

    I have a vbscript that pulls the input from kaseya and runs on the server to verify if the service is up or down then reports back to kaseya to send off as an email. I can also use relay services if you like to exclude Kaseya all together after the mon-set is triggered. Either way, this is SO Doable. If you've been able to use the monitor sets to trigger an alert I can get you the verification of up down status. I need to test my scripts in my test environment before I post them. Talk to you guys tomorrow :D



    [edited by: danrche at 7:07 PM (GMT -7) on 10-26-2011] dd
  • If you assign the monitor set for a service to create an alarm and run a script, you can retrieve the service name by using the vMonitorAlarmService.MonitorName. Right now, I have only tested this by writing the value to the Procedure Log, but this is a great first step in moving towards what you are looking for. I will finish up the entire procedure and post it here when I am complete.