CMDB Health - Orphan Remediation

Tom104
Tera Expert

Hi All,

I'm looking into remediating several health issues with our CMDB.

One significant issue is the number of Orphan Records on the estate, currently circa 50k+

Will using remediation rules therefore generate 50k tasks, one per CI, or just one task?
I've tried to report on this in list view, but can't find any way to generate the list of CIs to allow manual deletion. 


Failing this, is there any suggestion as to how I can bulk delete the Orphan CIs, we're only targeting the application class currently?

Current Metric is "Application" has no Runs "On:Runs" relationship.

Thanks

6 REPLIES 6

You could query to the Health results and from there to the cmdb_ci table for the found CI's to do a multi delete, but you are correct. The answer given deletes the health result records. Not very helpful from a ServiceNow Employee.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Sandeep90
ServiceNow Employee
ServiceNow Employee

The health result has classname and ci value and multi delete that is suggested is on the classname of the ci and not on the health result. Nothing needs to be deleted from the health result, when the health job runs again it automatically deletes the invalid(deleted CI) records. 

 

Script would look something like this and replace required class names and would suggest to do a dry run before deleting records. 

gs.trace(true);
var cis = [];
var gr = new GlideRecord('cmdb_health_result');
gr.addQuery('class_name','cmdb_ci_linux_server');//linux class
gr.addQuery('metric','bac72b5137130200f212cc028e41f1b8'); //required metric
gr.query();
while(gr.next()){
cis.push(gr.getValue('ci'));
}
 
var deleteGr = new GlideRecord('cmdb_ci_linux_server');
deleteGr.addQuery('sys_id', cis);
deleteGr.deleteMultiple();
gs.trace(false);