|
| 1 | +After a recent migration, the client wanted a quick and reliable way to verify whether specific IP addresses were being discovered by ServiceNow Discovery, and if so, determine which Discovery Status records they were associated with. |
| 2 | + |
| 3 | +This requirement was critical to help the client: |
| 4 | + |
| 5 | +Identify IPs that were discovered successfully. |
| 6 | + |
| 7 | +Find those that were not rediscovered after migration. |
| 8 | + |
| 9 | +Diagnose potential discovery or configuration issues efficiently. |
| 10 | + |
| 11 | +The script provided below serves as a powerful troubleshooting utility. It allows administrators to instantly check which discovery job (status) a given IP address belongs to, enabling faster debugging and drastically reducing resolution time. |
| 12 | + |
| 13 | +What the Script Does |
| 14 | + |
| 15 | +The script performs the following steps: |
| 16 | + |
| 17 | +Takes a list of IP addresses as input. |
| 18 | + |
| 19 | +Looks up each IP in the cmdb_ci_computer table(It could be Linux, AIX,etc.) to find its corresponding Configuration Item (CI). |
| 20 | + |
| 21 | +Queries the Discovery Device History (discovery_device_history) to determine whether the CI was created or updated by a discovery process. |
| 22 | + |
| 23 | +Builds a JSON array mapping each IP address to its respective discovery status number (e.g., DIS123145). |
| 24 | + |
| 25 | +Prints the result in the system logs for quick review and validation. |
| 26 | + |
| 27 | +Example output: |
| 28 | + |
| 29 | +[ |
| 30 | + {"ip_address": "192.168.1.35", "discovery_status_number": "DIS123145"}, |
| 31 | + {"ip_address": "192.168.1.27", "discovery_status_number": "DIS123189"}, |
| 32 | + {"ip_address": "192.168.1.15", "discovery_status_number": "No discovery record found"} |
| 33 | +] |
| 34 | + |
| 35 | +Benefits |
| 36 | + |
| 37 | +Saves significant debugging and analysis time. |
| 38 | + |
| 39 | +Helps identify why certain CIs stopped being discovered after migration. |
| 40 | + |
| 41 | +Provides clear mapping between IP addresses and their last discovery statuses. |
| 42 | + |
| 43 | +Enables faster root cause analysis and improves operational efficiency. |
0 commit comments