Jump to content

Check if Agent is Online

Recommended Posts

I'm very new to SQL scripting and automation scripting in general, so pardon if this is a silly question...

At the start of a script I am writing I want to ensure the target computer is online and exit the script if it is not (since the script will just queue up to run when the computer does come online by default, which is not what I want in this instance). My thought process was...

  1. Check if agent is online.
  2. Log a script log message if the agent is offline and exit the script.

To check if the agent is online I imagine I could either check if the one of the core agent services is running on the target computer, though I'm not sure which service I'd check, or I would use a SQL Get Value function and store the results into a variable, but I'm not sure what SQL value I'd be looking for to see if the agent is online. Aside from some help in figuring out how to script one of these methods, preferably the SQL Get Value option, can someone clarify for me if the script will execute until it reaches a step it cannot because the target computer is offline, or if the entire script will just queue when the agent is offline?

Maybe I'm going about this the wrong way and what I really need is a monitor which alerts me if a script is queued because the target computer was offline and so it could not/did not attempt to execute...




Share this post

Link to post
Share on other sites

If a script is marked online, it will be queued, but will not start until the computer checks in. If the computer is offline, obviously the script just sits waiting. 

If the script is an online script and the machine goes offline after the script starts, the script will hang on the next remote command until it comes online, OR until the script engine cleans house and kills the script (within an hour I think).

If the script is offline, it will run without waiting. If there is a remote command in the script, the script will hang until the computer checks in, or the script engine kills it (after 2 days?)

To test the computer status, check out my Scriptlets pack in the downloads area. One of them is to verify that the agent is online.  

  • Thanks 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...