Network Change & Configuration Management

Reply
Accepted Solution

Gather Port Counts where Description contains STRING

Authority
Posts: 20
2832     0

I am looking for a way to automate a process that will count the number of switch ports that have a Description with a particular string value.  I would like to be able to run this against a Device Group of switches.

 

Scenario:  We have a 802.1x switched network and a few ports that are approved to be whitelisted from 802.1x.  Management would like to know on a weekly basis, how many of our switch ports are whitelisted.  To do this, we add the string "NONAC" to the description field on a interface, like below.

 

interface GigabitEthernet3/12

  description Server - NONAC
  switchport access vlan 500
  switchport voice vlan 700

 

Is there a way to automate counting these interfaces?

Re: Gather Port Counts where Description contains STRING

Adviser
Posts: 353
2833     0
You can get the complete list of these ports in a device group by using a custom report. Select the "Interfaces" data type when you go to create the custom report. Then, you can add columns and a filter to only get those ports.

This is not exactly what you want, I know. To do just what you want you would need to use a script against the API. It would be pretty simple - in fact this one call will return you the count the count of all such ports in device groups 2 and 3:

https://netmri/api/3/interfaces/find?op_ifDescr=like&val_c_ifDescr=%NONAC%&limit=1&DeviceGroupID=2,3<>



52
0
1
1

...it also returns one interface which you can ignore...



If you do it in the browser you get XML because of the headers the browser sends. To get JSON you would specify find.json, or it will default to JSON if you are using something like curl.

To get the list of device groups and their IDs:

http://netmri/api/3/device_groups?select=DeviceGroupID,GroupName


John

Re: Gather Port Counts where Description contains STRING

Adviser
Posts: 353
2833     0

Sorry, it stripped out the xml tags when I sent it via email. That response should be:

 

 

 

<response>
<total type="int">52</total>
<start type="int">0</start>
<limit type="int">1</limit>
<current type="int">1</current>
<interfaces type="array">
<interface>...it also returns one interface which you can ignore...</interface>
</interfaces>
</response>

 

 

 

Re: Gather Port Counts where Description contains STRING

Authority
Posts: 20
2833     0

Thanks.  I will give that a try and see what I get.  Ultimately, I would like to see a report with the switch name and a list of ports with the matching string and then a summary that shows the totals.

Showing results for 
Search instead for 
Do you mean 

Recommended for You