Script to check the Mid server status is up and running after the patching activity is completed.

Prasad61
Kilo Contributor

Can we configure a script to check after the completion of the patching activity of Midserver,  is up and running can info be shared to other system as an automation, please help me understand if this can be achieved if can, how can it be achieved. 

1 REPLY 1

Community Alums
Not applicable

This is not exactly what you are looking for, but it might help you along the way. I'm working on a Script Include to pick a up-and-running mid server with the least number of jobs (for a REST Outbound call I can't allow to fail). 

 

	/**Retrieves the name of the least busy running MID server based on pending and processing jobs.
	 * @returns {string} name of the least busy running MID server or a constant if not found.
	 */
	get_running_midserver_least_busy: function(){
		var mids = new GlideAggregate("ecc_agent_status");
		mids.addAggregate('SUM', 'pending_jobs');
		mids.addAggregate('SUM', 'processing_jobs'); 
		mids.groupBy('agent.name');
		mids.query(); 

		var least_jobs = Infinity; 
		var selected_mid_server = "";

		while (mids.next()) {
			var total_jobs = (parseInt(mids.getAggregate('SUM', 'pending_jobs')) || 0) + (parseInt(mids.getAggregate('SUM', 'processing_jobs')) || 0);

			if (total_jobs < least_jobs) {
					least_jobs = total_jobs; 
					selected_mid_server = mids.getValue('agent.name'); 
			}
		}
		return selected_mid_server || "MID_SERVER_NOT_FOUND";
	}

 

I found out the hard way that the best query to run on the ecc_agent table is 

"status=Up^validated=true"  (the MID server's status has to be UP and it should be validated as well).  I hope you can expand on this a lot eg., trigger events, etc., I guess you can also use other API's like 

MonitorMIDServer