Today's download is a monitoring script I use on my revision 6.9 Deployment Servers. This logs engine activity and I use this in conjunction with Monitor Solution to alert me should the axengine.exe process hang.
This alert is important for us as engine hangs, although rare, are most confusing for Deployment console users. Everything appears to be good at the console, it's just that the clients will not execute any jobs. This script lets know in advance when the engine is down, allowing us to kill of the axengine.exe process automatically and restart the service.
The Script
As usual, this magic is done with a vbscript. Attached to this article you'll find a .zip file holding a single script file, AxEngine_Service_Check.vbs. In what follows, I'll assume you've put it on your deployment server in the folder C:\Maintenance\AxEngine Service\
To run the script, just type at the command line the following,
cscript AxEngine_Service_Check.vbs
The output will be a number followed by a colon as shown below,
This output reveals the number of jobs which the engine has scheduled within the last 15 minutes. So in the above example, we have 47 jobs scheduled in the last 15 minutes so we can be fairly confident at this point that the engine is running well.
Ensuring Engine Activity
Now, the problem with running this script in isolation is that there will be plenty of periods when the server has legitimately nothing to do. In this case the script output will throw a zero and any automation you have in place will alert you to engine inaction needlessly.
So what we do is create a job which executes a server-side script containing the single line,
REM Do Nothing (Server)
And have this task configured to execute even when the agent is disconnected. We then schedule this "Do Nothing" job on a machine which isn't likely to be deleted (like a WOL proxy) on a repeating schedule every 5minutes. This means that without fail the engine even when idling should be recording at least one job scheduling in that 15 minute period.
In short, once you've got a job with such a repeating schedule in place, you should never see no jobs scheduled in that 15minute window.
Running the script
You have a couple options for running this script. You can use a scheduled task to fire this off every 15 minutes, or what we do here is trigger it with Monitor Solution.
If you wanted you could put auto-remediation directly into the vbscript. In that case I'd advise checking for activity in the last half-hour (to be on the safe side!) and then add an email function to the script to let you know that automatic remediation has taken place.
Logging
By default, the script will log to the folder C:\Logs\Maintenance, and this can be changed simply by ammending the header of the script,
Dim ofso,StrLogfileStrLogPrefix="AxEngine_Job_Execution_"StrLogRoot="C:\Logs\Maintenance"
10/25/2013 1:10:54 PM - 7910/25/2013 1:25:53 PM - 5610/25/2013 1:40:54 PM - 12110/25/2013 1:55:54 PM - 14410/25/2013 2:10:56 PM - 7810/25/2013 2:25:52 PM - 7910/25/2013 2:40:51 PM - 13610/25/2013 2:55:51 PM - 10310/25/2013 3:10:51 PM - 11210/25/2013 3:25:51 PM - 7610/25/2013 3:40:51 PM - 9010/25/2013 3:55:51 PM - 2410/25/2013 4:10:51 PM - 5210/25/2013 4:25:51 PM - 5510/25/2013 4:40:51 PM - 6010/25/2013 4:55:51 PM - 9810/25/2013 5:10:51 PM - 7710/25/2013 5:25:51 PM - 1210/25/2013 5:40:51 PM - 110/25/2013 5:55:51 PM - 110/25/2013 6:10:51 PM - 3
How the Script Works
Dim qSQLQuery,intJobCountqSQLQuery="select COUNT(*) from event_schedule where DATEDIFF(MINUTE,end_time,GETDATE()) < 15"intJobCount=ExecuteSQL("Altiris eXpress Database",qSQLQuery)WriteLog intJobCountwscript.echo intJobCount & ":"wscript.quit
Hope you find this trick as useful as we have.