Client Management Suite

 View Only
Expand all | Collapse all

Job to Check Service State and Send Alert

  • 1.  Job to Check Service State and Send Alert

    Posted Sep 03, 2012 05:00 AM

    I'm trying to make a job that checks a windows service state and sends an email if it isn't 'running'. The service state check is OK using existing tasks but I can't figure out the email side. Whenever I choose to add an existing task the email tasks are not shown. What's the best way to achieve this please?



  • 2.  RE: Job to Check Service State and Send Alert

    Posted Sep 03, 2012 04:36 PM

    I have CMS V7.0 - For some reason (that I cant understand) You can only add a send email task to a server job, not a client job. You could try that!

    Joe.

     



  • 3.  RE: Job to Check Service State and Send Alert

    Posted Sep 04, 2012 04:27 AM

    Thanks, the problem then is that you can't run that server task on the clients. I guess the clients themselves dont have an email capability but I was hoping it would be able to relay it via the server or something?



  • 4.  RE: Job to Check Service State and Send Alert

    Posted Sep 04, 2012 05:29 AM

    What server task can't you run on the client ?



  • 5.  RE: Job to Check Service State and Send Alert

    Posted Sep 04, 2012 06:10 AM

    If I create a server job, it doesn't give me the option to 'quick run' against a client, only schedule it. The job needs to check the service (on every client) and send an email alert if it isn't running...



  • 6.  RE: Job to Check Service State and Send Alert
    Best Answer

    Posted Sep 04, 2012 08:25 AM

    How time critical is it? Does it really need to run immediatelly? Rather build a automation policy with an SQL query for the service state. It gets reported by basic inventory.(standard basic inventory schedule is 1 day) So if you want to have it more immediate do the following.

    Just build a client job, first sending a task to the client to send the basic inventory ASAP.
    Second use one of the ASDK sample scripts to trigger the automation policy. Put this script in an task server task, this way it can be run in the client job. Just remember if you have other task servers then your NS you will need to install the ASDK components on it.



  • 7.  RE: Job to Check Service State and Send Alert

    Posted Sep 05, 2012 08:25 AM
    You could also utilize a power shell / vbscript on the local machine to check the service and then send an email from the client itself. The email wouldn't come directly through the console but it should still obtain what you're looking for.


  • 8.  RE: Job to Check Service State and Send Alert

    Trusted Advisor
    Posted Sep 05, 2012 09:46 AM

    The above post from JMP51483 is the approach I'd instinctively use here.



  • 9.  RE: Job to Check Service State and Send Alert

    Posted Sep 05, 2012 11:49 AM

    Not much at scripting.. anyone got a script that would do this ?

     



  • 10.  RE: Job to Check Service State and Send Alert

    Posted Sep 05, 2012 12:13 PM

    Thanks for your suggestions, I guess I would prefer server based just to remove the need for the clients to have to authenticate against email servers etc.. It isn't time critical so I'll check out the server method first!



  • 11.  RE: Job to Check Service State and Send Alert

    Posted Sep 06, 2012 06:13 AM

    Found a script that does this in case anyone needs it. :

     

    Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
    Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

    Const cdoAnonymous = 0 'Do not authenticate
    Const cdoBasic = 1 'basic (clear-text) authentication
    Const cdoNTLM = 2 'NTLM

    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "altiris Build Job Completed"
    objMessage.From = "from address@here.com"
    objMessage.To = recipient@here.com
    objMessage.TextBody = "Build Completed"

     
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "EXCHANGESERVER"
    'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoNTLM
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "domain\username"
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    objMessage.Configuration.Fields.Update

    objMessage.Send