Looking for Script to delete duplicate CI's according to serial number.

vikashbhasin
Kilo Explorer

Anbody have a script to delete duplicate CI's according to serial number.

3 REPLIES 3

Chuck Tomasi
Tera Patron

Vik,

Deleting CIs is a slippery slope. It's hard to tell if the record you intend to delete has any references to it (e.g. a computer from incident, problem, or change.) If you come up with two or three apparent duplicates, it could cause some "broken link" issues if you delete the wrong one.

Recommendation 1: Don't delete CIs.
Recommendation 2: Change the state to something like 'obsolete'

If you're really bold, you could write a UI Action (and instantiate it as a form menu for an admin) to search for references in other tables to that CI to ensure it has no references, then remove it safely. I might be able to find a version used on sys_user I used earlier this year for cleaning up duplicate users. Using this manual method would take some time to clean up if you had a lot of duplicates.

Here are some alternate options (although a bit riskier)

Option 1: Write a script that goes through and compares creation and/or update dates and make a logical comparison to determine which is best to delete. For example, if you know you ran discovery today and ended up with 100 duplicates, you could say "search for any CIs created after 6/11 and delete those."

Option 2: Delete all CIs and re-run discovery (see Recommendation 1). Only use this if you are absolutely sure you haven't used any CIs on any other tables (dev or test would be a good use of this practice - production would be a LOT riskier depending on how long you've been using the CMDB.)


Chuck Tomasi
Tera Patron

Vik,

You might also consider this information from Aleck on duplicate CIs

Discovery Scan CI and duplicates


Hi Chuk,

how we are handling cmdb_ci_dns_name for Duplicate CI in De-Duplication task. 

i can see, post remediation of duplicate task, its still persist in system. (merge Duplicate CI with Master CI). & during remediation task i cant see attribute here to change the state or add/update name of it, if i want to.

 

find_real_file.png

Thanks in advance.

 

Bharat