Updating CI attributes with Discovery

jesusemelendezm
Mega Guru

Hi SN folks,

 

What information is updated when you run discovery against an existing CI. Given the scenario, I have two CIs and I manually update the location and status of these two CIs. Once the discovery runs against these two CIs. Will the discovery change the location and status that I manually input in the record? How about the field class? what If I update it manually... will discovery re-classify this CI?

 

I have done- some testing and I know the result, I want to confirm if what I am getting is the the proper output or/and how to change these parameters.

Thanks,

 

Jesus E.

1 ACCEPTED SOLUTION

Sharon Hobart
Mega Guru


The status of the CI's are not affected or updated by Discovery except on initial creation.   After that the status field is maintained by process.



For location, it will remain blank and discovery will not overlay any manual information with a "blank".   But if you have a discovery schedule created and you have populated the location field on the discovery schedule itself, then that location will be applied to that CI and will overlay any other information that was manually populated in that field.



If you change the class of a CI from Windows Server to Server as an example, on the next discovery run it will create a new CI back under the Windows Server class. So you will have two - one under Windows Server class and one under the Server class.     Of course, this is based on the "matching rules" in place for CI's.   But I believe we are using what is out-of-the-box.



We are going to test a matching criteria rule that is "false" out of the box to match only a serial number without class being part of that decision.


View solution in original post

9 REPLIES 9

That's the thing, I run scheduled of a range of IPs by location. I have the location name with the discovery schedule.


Ankush13
Kilo Guru

If you are mentioning location with your discovery run, CI will be updated wrt location each time you run discovery. If you have good CMDB and don't want location to be updated with discovery runs, find the location attribute in sensor and comment it out.


Thanks Ankush


kumar37
Kilo Contributor

Hi all,

am new to service now.please accept my apologies if there is anything wrong in the code.

i have the similar requirement,based on my understanding i have written the below code. but it is not giving the expected output. can any one please help me on this.

below are the requirement details and written code.

I have a requirement to update the location of the server in CMDB_CI_SERVER table w.r.to discovery schedule location.

We have OOB feature to update the location, but for some servers location is not updating, so we want to customize this.

1)   Discovery schedule has location field with one value, the same should be updated for servers in CMDB_CI_SERVER table w.r.to their IP ranges.

2) For every discovery schedule we have defined some IP ranges .the server which is present in the above tables IP range will fall in the defined range.

I have written below business rule for this .script is executing fine, but location is not populating in the CMDB_CI_SERVER table.

 

Business rule:

 

function location(){

var sysID ='8d7eb7ed4f302e842967ef4f0310c789';  

var serverip = new GlideRecord('cmdb_ci_server');

serverip.addQuery('sys_id',sysID);

serverip.Query();

while(serverip.next()){

var iprange = new GlideRecord('discovery_range_item');

var discsche = new GlideRecord('discovery_schedule');

if( serverip.getValue('ip_address') >= iprange.getValue('start_ip_address')   && serverip.getValue('ip_address') <= iprange.getValue('end_ip_address') ){

    answer = iprange.getValue('schedule');

    gs.log('answer');

    continue;  

  }

  if( answer = discsche.getValue('name')){

      answer2   = discsche.getValue('location');

    continue;  

  }

  if( answer2 != serverip.getValue('location')){

    answer3 = answer2;

  }

    serverip.location= answer3;

serverip.update();

  }

  }

 

 

Thanks,

kumar

cyked
Mega Guru

To add to hobar1's response, some of the discovery managed fields have cached results.  So for the probe, if the data is cached and you change a value on the CI the value of the CI will NOT update if the data from the probe matches what is cached.

Example: if the probe which gathers the server model detail is cached and on the server CI you change the model from X to Y and run discovery the probe will return X as the model, which matches the existing cache from discovery it will NOT overwrite Y with X until the value returned from the probe is something other than X. 

There is a "cache results" value on the probes table you can reference.  Also, if you're using the new identification engine it depends on your rules setup and your script includes as to whether you end up with a new CI on discovery if you reclass a windows server to linux or server.  If the evaluation is configured properly you can reclass a windows server to an IP switch manually and have discovery reclass it to windows sever on discovery because the identification happens at cmdb_ci_hardware and not the specific classified table of the device.