Friday, June 22, 2018

Get Instance name from script in ServiceNow

Get the instance name from BusinessRule  in ServiceNow to avoid Hardcoding.

Create a Global variable  and assign the instance to it and here is the code below:

//Getting the instance name -- Check sys_properties table and find the value of instance_name

var instancename = gs.getProperty('instance_name');
gs.log('instance name is -->' +instancename);

var env = ' ';

//check if instance name contains dev or uat or anything
if(instancename.indexOf('dev') > -1)
{
env = "DEV";
gs.log('it is instance-->' +env);
}else if(instancename.indexOf('uat') > -1 )
{
env = "UAT";
gs.log('it is instance-->' +env);
}else
{
env = "PROD";
gs.log('it is instance-->' +env);
}

var midserver = 'MIDServer_'+env+'15_1';

var mid = new GlideRecord('ecc_agent');
mid.addQuery('name',midserver);
mid.query();
if(mid.next())
{
}

Monday, June 11, 2018

Error: Authentication Failure with the local MID Server Service Credentials.


Error:      Authentication Failure with the local MID Server Service Credentials.


Cause:   When Discovery is scheduled for the Windows devices, It checks all the credentials for Windows in our instance for the device  we are trying to discover. After Powershell tries all the credentials in the instance and it fails to logon with any of them. Next by default, It attempts to logon by using MID Server service credentials.

Solution:   Add a configuration parameter to the MID Server.

Mid.powershell.local_mid_service_credential_fallback = false

Note: After changing the parameter, please make sure to restart the MID Server.







Test Results:

  1. Run Discovery again for the device failing with error
  2. Open the “Input” XML file for WMI in ECC Queue.



Before Change:



After Change:



Error: [ecc_agent_status] table record missing for MIDSERVER "Midserver name" : no thrown error in Logs.

Error Log - [ecc_agent_status] table record missing for MIDSERVER "Midserver name" : no thrown error in Logs.


Cause: (Cloning is causing this error. You did not add all related midserver tables to your exclude tables in clone configuration)
Each MIDServer should have a matching record in ecc_agent_status table. So, if you have 10 MIDServers, you will have its 10 corresponding ecc_agent_status records.
If you see an empty record(MIDServer is empty) in ecc_agent_status table, then you will get an error for a MIDServer.




The sys_id (Open the empty record, then right click on header and click  show xml – copy the value mentioned in agent display_value  and open your production instance and open MIDServers table, and check in the filter if sysid is agent display value you got. You will find the record in production. They must have overwritten this table  in DEV on a previous clone from production.
When we look into the Exclude tables from cloning we can see that the  list of MID servers have been excluded from the clone but not ecc_agent_status so this brought the wrong references to MID servers in the ecc_agent_status table, therefore these MID server entries were blanked out. So, this cloning has got the whole errors.



Resolution:
1.     Delete all the empty records from ecc_agent_status table.
2.     Create a new record in ecc_agent_status table by just adding your missing midserver name.



You will not see any errors in the logs anymore.

To prevent this error in future add below tables to the Excluded and Preserved lists in the Clone configuration in the instance:

These tables are missing:

ecc_agent_status - Leading to MID Servers missing from the MID Server Dashboard, and lots of Errors in the system log
ecc_agent_issue
 ecc_agent_config
ecc_agent_application / ecc_agent_application_m2m
 ecc_agent_ip_range / ecc_agent_ip_range_m2m
 ecc_agent_capability / ecc_agent_capability_m2m
ecc_agent_property
ecc_agent_thread
ecc_agent_metric / ecc_agent_counter_metric / ecc_agent_memory_metric / ecc_agent_rgr_metric / ecc_agent_scalar_metric
ecc_agent_privileged_command_m2m

















Discovery troubleshooting | Error messages

  Discovery troubleshooting | Error messages - Support and Troubleshooting (servicenow.com) Description Learn how to resolve common Discover...