Name

sn_agent.MidMonitoringUtils

Description

Set of utilities to be used used by checks for MID health

Script

var MidMonitoringUtils = Class.create();
MidMonitoringUtils.prototype = {
  initialize: function() {
  },

  extractLogFile : function (midCiGr) {
      if (!midCiGr.running_process)
  		return;
  	
      var processGr = new GlideRecord('cmdb_running_process');
      if (!processGr.get(midCiGr.running_process)) {
  		gs.debug('process not found');
  		return;
  	}
  	
  	// We now pick the parent
  	if (!processGr.parent) {
  		gs.debug('Parent process is empty');
  		return;
  	}
  	
      var parentProcessGr = new GlideRecord('cmdb_running_process');
      if (!parentProcessGr.get(processGr.parent)) {
  		gs.debug('parent process not found');
  		return;
  	}
  	
  	var commandLine = parentProcessGr.command;
      if (!commandLine) {
  		gs.debug('running_process_command is not found in process ' + parentProcessGr.name + ' ' + processGr.getUniqueValue());
  		return;
  	}
  	
      // Example of command line: C:\mids\automationItonGold\agent\jre\bin\java.exe
      var agentIndex = commandLine.indexOf('\\agent');
      if (agentIndex < 0) {
  		gs.debug('String \\agent not found in command');
  		return;
  	}
  	
      var logPath = '"' + commandLine.substring(0, agentIndex + 7) + 'logs\\agent0.log.0"';
      return logPath.toUpperCase();
  },
  
  extractPid : function (midCiGr) {
      if (!midCiGr.running_process)
  		return;
  	
      var processGr = new GlideRecord('cmdb_running_process');
      if (!processGr.get(midCiGr.running_process))
  		return;
  
  	return processGr.pid;
  	
  },
  
  type: 'MidMonitoringUtils'
};

Sys ID

0b9834c4c3c313002a6f741e81d3ae46

Offical Documentation

Official Docs: