ltgjsears
Kilo Explorer

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:

  1. Create an import table extending Import Set Row
  2. Create a CI table extending Configuration Item
  3. Create a Transform Map to move the data from the Import Set to the CI table
  4. Create a Scheduled Job containing the code that calls the Meraki API and populates the import table
  5. Create Parent-Child Relationship where applicable
  6. Use a Transform Script to Link the Parent-Child during the import process
  7. 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:

  1. Utilize the CMDB CI relationship capability
  2. Enabling network remote or self-diagnostics via Service Portal
  3. Create Tier 1 troubleshooting & actions for Support Staff
  4. 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.

 

Comments
benrollins
Kilo Expert

I am currently planning the same type of integration for our environment, this looks like it will definitely help me get a good start.  I'm very interested in finding out if you've been able to implement more since the date of this posting.

russelgl
Tera Contributor

Any updates on this project?

benrollins
Kilo Expert

I was able to successfully implement the gathering of Organizaitons, Networks and Devices using the information provided by the OP. 

First query will create an ORG CI for each organization the service account has read access against.
Next query uses the ORG number from each ORG CI to return a list of all networks, defines the CI and sets the parent as the ORG.
Third query uses the Network ID for every record in that table to return a list of all devices, defines the device CI and sets the parent as the appropriate Network.

My official project was put on hold for several months, but it's starting back up again now, so I expect to start adding more functionality in the very near future.

Head's up, one of the issues I encountered was that the network devices for Meraki are all part of the same query, but in the CMDB world they belong to three different classes: Firewall, Switch and Access Point. (and cameras, phones, managed OS if you're using those, we aren't at the moment, so I'm uncertain if they will show up in the same devices query, or if there is another call to be used)

You will have to use regex against the first two characters of the model value to determine the table where the CI should be created.

Shiyue Cheng
Kilo Explorer

Hi team, there is now a new organization-wide devices API endpoint that you can use to get all Meraki devices in a dashboard organization, as opposed to previously iterating through networks getting the devices of each network. This should help reduce the time and number of API calls needed in this process.

Inactive_Us1596
Tera Contributor

Hi Benrollins,

 

have you implemented following :

implement automation between Meraki Dashboard and Snow.

Also to create new interfaces for the team.
⦁       Create automatic reports for SLA & KPIs by using data in Snow & Meraki Dashboard  
⦁       Update the CMDB with assets in Meraki Dashboard  
⦁       Create automatic tickets in Snow when alerts from Meraki Dashboard  
⦁       Create a new dashboard with a project view, to report statistics to the customer

 

if so can you please help me on this!

 

Thanks in advance

Anand45
Kilo Contributor

Hello Ben,

Could you please provide the details about the implementation. we have similar kind of requirement like gathering of Organizaitons, Networks and Devices. How can we establish the connection in servicenow.

Thanks in advance,

Anand.

Dhivya Sivamani
Tera Explorer

how it is different from Servicneow discovery

Ben131
Tera Contributor

@Dhivya Sivamani ultimately it can achieve the same result and CMDB structure in the end, but there is no need to setup Discovery with this integration.
One benefit being, if your ServiceNow instance does not have Discovery, this will still build the CMDB and relationships.  Another benefit being the simplicity, especially for Meraki environments with multiple defined Org's and networks, you do not need to configure a MID Server (or multiple MID servers) with network access to all of those different subnets, everything already centrally reports back to the Meraki Admin dashboard, so why not just grab your data from there? 
This method will also be aware of devices if they are offline, where Discovery will just miss them.  For Meraki especially, you're typically paying for your licenses on a per-device basis, even if it's offline, so you want to know about everything that's registered to your company, not just everything that's online.

Version history
Last update:
‎07-04-2018 04:54 AM
Updated by: