Floating/Hanging CI's in a business serviceIssue <!-- div.margin{ padding: 10px 40px 40px 30px; } table.tocTable{ border: 1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); padding-top: .6em; padding-bottom: .6em; padding-left: .9em; padding-right: .6em; } table.noteTable{ border:1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); width: 100%; border-spacing:2; } table.internaltable { white-space:nowrap; text-align:left; border-width: 1px; border-collapse: collapse; font-size:14px; width: 85%; } table.internaltable th { border-width: 1px; padding: 5px; border-style: solid; border-color: rgb(245, 245, 245); background-color: rgb(245, 245, 245); } table.internaltable td { border-width: 1px; padding: 5px; border-style: solid; border-color: #E0E0E0; color: #000000; } .title { color: #D1232B; font-weight:normal; font-size:28px; } h1{ color: #D1232B; font-weight:normal; font-size:21px; margin-bottom:-5px } h2{ color: #646464; font-weight:bold; font-size:18px; } h3{ color: #000000; font-weight:BOLD; font-size:16px; text-decoration:underline; } h4{ color: #646464; font-weight:BOLD; font-size:15px; text-decoration:; } h5{ color: #000000; font-weight:BOLD; font-size:13px; text-decoration:; } h6{ color: #000000; font-weight:BOLD; font-size:14px; text-decoration:; } ul{ list-style: disc outside none; margin-left: 0; } li { padding-left: 1em; } --> Description The procedure to identify the problematic endpoints in a business service and remove the Floating/Hanging CI's. We encounter problems with maps showing 'floating' CIs. The most common problems are: CI was not added to the model because we reached the model depth limitCI was not added to the model since it does not comply with containment/hosting rule (until Jakarta)Missing relations from the CMDB (root cause not always clear) Procedure Run as background script to identifying those problems and reports on recommendation action. // script to identify Floating/Hanging CI's in a business service. var gr1 = new GlideRecord('cmdb_ci_service_discovered'); gr1.get(<service_id>'); //Replace the <service_id> part var layerId = gr1.layer; var layerGr = new GlideRecord('svc_layer'); layerGr.get(layerId); gs.print('env = ' + layerGr.environment); var allCis = sn_svcmod.ServiceContainerFactory.queryCIsAssociatedWithEnvironment(layerGr.environment); gs.print('Ci count: ' + allCis.length); // First path to build map var map = {}; for (var i in allCis) { var ci = allCis[i]; map[ci] = 1; } var problem = 0; for (var i in allCis) { var ci = allCis[i]; var epGr = new GlideRecord('cmdb_ci_endpoint'); if (!epGr.get(ci)) continue; // This is an endpoint. Check if it has implemented by relation var relGr = new GlideRecord('cmdb_rel_ci'); relGr.addQuery('parent', ci); relGr.addQuery('type', '45e94a74532221007c949096a11c0861'); relGr.query(); if (!relGr.next()) { // No implementing relation. Check if there are outgoing application flow relations. if there are such, and its not cmdb_ci_endpoint_ob_cluster, something is wrong if (relGr.sys_class_name == 'cmdb_ci_endpoint_ob_cluster') continue; var relGr1 = new GlideRecord('cmdb_rel_ci'); relGr1.addQuery('parent',ci); relGr1.addQuery('type', '85d98503ff100200d699ffffffffff8c'); relGr1.query(); if (relGr1.next()) { gs.print('PROBLEM: Endpoint: ' + ci + ' has outgoing app flows relations, but no outgoing implements relations. Recommended action: 1) try to resume discovery on the endpoint 2) if there is still a problem, delete all outgoing relations from this endpoint'); problem++; } continue; } // Check if the target CI is in the service if (!map[relGr.child]) { // Check if the endpoint is entry point in another service var entryPointGr = new GlideRecord('sa_m2m_service_entry_point'); entryPointGr.addQuery('cmdb_ci_endpoint', ci); entryPointGr.query(); if (!entryPointGr.next()) { gs.print('PROBLEM: CI ' + relGr.child + ' implementing endpoint ' + ci + ' is not in the service model. Check (1) if we exceeded the depth limitation (2)consistency of this CI with the identification engine containment and hosting rules'); problem++; } } } gs.print("Problem count = " + problem); Example of output: *** Script: env = 018c1294139e3640b53afabed144b0fe *** Script: Ci count: 3195 *** Script: PROBLEM: CI c35a67c9135a4304d36c75c36144b03b implementing endpoint 75f8a3c5135a4304d36c75c36144b049 is not in the service model. Check (1) if we exceeded the depth limitation (2)consistency of this CI with the identification engine containment and hosting rules ** Script: PROBLEM: Endpoint: 6444d3174fcc32009d64bc218110c7ae has outgoing app flows relations, but no outgoing implements relations. Recommended action: delete all outgoing relations from this endpoint *** Script: Problem count = 159 2) Based on the output, identify the problematic endpoints and remove the applicative flow relations from those endpoints. 3) Once the above step is completed, execute the recompute Business service UI action and return to the discovery on the business service