Populating CMDB Network CIs using the Meraki Dashboard API
As part of our ServiceNow CMDB implementation, I found the Meraki Dashboard API to be a straight forward way to build out a representative CI heirarchy of our network environment. This includes building parent-child relationships from Organization to Networks, Networks to Devices and Networks to VLANs. The Meraki Dashboard API documentation is available here and you can use this guide to get started.
If you are not familiar with Meraki, they are a line of network equipment from Cisco that is entirely cloud-managed. By that, their equipment is configured almost exclusively through the Meraki Dashboard. Once a device is connected to a network with internet access, all configurations are retrieved from their secure, centralized configuration repository. The Meraki solution may not be for everyone but for organizations such as ours, where we support many small, remote networks with very few staff members, Meraki makes device management a breeze. Coupling Meraki with our ServiceNow IT Service Management capabilities streamlines our network management and enhances our vision across our environment.
Generally speaking, I followed these steps to accomplish the goal of ingesting Meraki Dashboard data on a recurring basis:
- Create an import table extending Import Set Row
- Create a CI table extending Configuration Item
- Create a Transform Map to move the data from the Import Set to the CI table
- Create a Scheduled Job containing the code that calls the Meraki API and populates the import table
- Create Parent-Child Relationship where applicable
- Use a Transform Script to Link the Parent-Child during the import process
- Alter List and Entity Views as needed
Here's a example of the Scheduled Job code:
gs.info("Start processing networks...");
var org = new GlideRecord("u_meraki_organizations");
org.query();
while(org.next()) {
var orgid = org.u_id.toString();
gs.info("Processing Org ID: "+orgid+" Org Name: "+org.name);
var r = new sn_ws.RESTMessageV2('Meraki Networks List', 'Default GET');
r.setStringParameter("orgid",orgid);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var parser = new JSONParser();
var parsed = parser.parse(responseBody);
// clear the table
var del = new GlideRecord("u_imp_networks");
del.query();
del.deleteMultiple();
// populate import table
for(i=0; i < parsed.length; i++) {
gr = new GlideRecord("u_imp_networks");
gr.u_id = parsed[i].id;
gr.u_name = parsed[i].name;
gr.u_time_zone = parsed[i].timeZone;
gr.u_type = parsed[i].type;
gr.u_org_id = parsed[i].organizationId;
gr.insert();
}
}
gs.info("Processing networks completed.");
Here's the transform script used to connect the Network to Organization, use onAfter for "When" to execute:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var org = new GlideRecord('u_meraki_organizations');
org.get('id',target.u_org_id);
if(org.u_id == target.u_org_id) {
log.debug("Parent found: "+org.name);
target.u_parent = org.sys_id;
} else {
log.debug("Parent not set for "+target.name);
}
target.update();
})(source, map, log, target);
Some of the ideas I have for improving our Meraki/ServiceNow integration are:
- Utilize the CMDB CI relationship capability
- Enabling network remote or self-diagnostics via Service Portal
- Create Tier 1 troubleshooting & actions for Support Staff
- Collecting Meraki network events for Incident and Problem Management
If you found this useful or have other ideas, please leave a comment. I look forward to expanding our use of the ServiceNow platform for managing our IT infrastructure and services will our small team here at Lansing Trade Group.
https://www.servicenow.com/community/itsm-articles/populating-cmdb-network-cis-using-the-meraki-dashboard-api/ta-p/2306964