Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

Network Change & Configuration Management

Reply
Highlighted
Accepted Solution

Get Config

Techie
Posts: 9
8936     0

Recently I made modifications to several Cisco IOS devices via snmpset from a command line.  Now when I run a report from NetMRI I do not see the changes I have made. My question is how can I get NetMRI get a fresh config from all these devices I have changed? Is there a get config API I can script?

Highlighted

Re: Get Config

Adviser
Posts: 423
8937     0

You can use CCS Smiley Happy

 

Script-Filter:             true

Action:                    Get Configs Test

Action-Description:        Demonstrates the Get Configs functionality via CCS

Action-Commands:

         # Request another Get Configs operation to audit the above change. Since this

         # is the end of the script and there is no need to block until the Get Configs

         # operation has completed, the asynchronous mode is used.

 

         GET-CONFIGS: asynchronous

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh
Highlighted

Re: Get Config

Expert
Posts: 235
8937     0

For IOS devices, the ccmHistory table is polled numerous times/day (every 1.5 hours?)  The timestamp for the last change to the running-config should have been updated, causing NetMRI to launch a new config collection and CVS comparison.

 

I've never tested it, but does a config change via SNMP-set cause a "CONFIG" syslog message to be generated?  If so, and if the device is sending those messages to the NetMRI, a triggered collection should be performed.

Highlighted

Re: Get Config

[ Edited ]
Authority
Posts: 32
8937     0

The previous replies are both correct -- you can use the CCS command GET-CONFIGS: to perform an on-demand config collection for a device.  And, for Cisco devices,NetMRI should automatically detect the config change via its SNMP polling of the ccmHistory OID.

 

If, as you suggested, you prefer to script this via the API, you can use the get_configs API call.  Here's an extended example of how this could work.  For clarity, I'm going to just use HTTP API calls, but Perl would be very similar.

 

First, you need to know the DeviceID of the device.  If you do not already know it, you can do something like


   /api/3/devices/index/?DeviceIPDotted=10.10.10.4

 

which will return a lot of device data, e.g.:

   <device>
     <DeviceID type="int">2</DeviceID>
     <DeviceIPDotted>10.10.10.4></DeviceIPDotted>
     <DeviceModel>catalyst37xxStack</DeviceModel>
     <DeviceName>DEMO-SWRT-04</DeviceName>
   </device>

 

 

With the DeviceID, you can then use get_configs to start an on-demand config collection:

 

   /api/3/config_revisions/get_configs?DeviceID=2

 

This returns a TrackingID which uniquely identifes that particular config collection request:

 

   <TrackingID type="int">42</TrackingID>

 

 

You can use that to confirm when the config collection has completed, using get_configs_status:

 

   /api/3/config_revisions/get_configs_status?TrackingID=42

 

 At first, it will have a status of "Running":


   <Status>Running</Status>

   <Timestamp nil="true"/>

 

...but it will eventually change to OK (assuming a successful collection), and return the timestamp of the collection:

 

   <Status>OK</Status>

   <Timestamp type="datetime">2016-03-02 10:40:31</Timestamp>

 

 

That's all you really need in order to be assured that a config collection was performed successfully.  But if you need the script to actually retrieve the config contents (perhaps to validate the changes were made correctly), you can use the Timestamp from above to determine the ConfigRevisionID:

 

   /api/3/config_revisions/find?DeviceID=2&LastCollected=2016-03-02 10:40:31

 

...which will show the matching config revision records:

 

   <config_revision>

     <ConfigRevisionID type="int">17985</ConfigRevisionID>

     <ConfigType>Running</ConfigType>

     <DeviceID type="int">2</DeviceID>

     <LastCollected type="datetime">2016-03-02 10:40:31</LastCollected>

   </config_revision>

   

   <config_revision>

     <ConfigRevisionID type="int">17986</ConfigRevisionID>

     <ConfigType>Saved</ConfigType>

     <DeviceID type="int">2</DeviceID>

     <LastCollected type="datetime">2016-03-02 10:40:31</LastCollected>

   </config_revision>

 

(There are two records because both a "running" and a "saved" configs were collected.)

 

You can then use the ConfigRevisionID to retrieve the actual config file contents:

 

   /api/3/config_revisions/text?ConfigRevisionID=17985

 

 

Please note that some of these API call are fairly resource-hungry and can potentially delay other processing.  The get-configs call itself will insert a new config collection at the front of the queue, to be performed ahead of any others that have been queued up -- so if you perform more than a few of these at any one time, there is a chance that normal config collection will be blocked for some time.  So I would recommend that you use these sparingly and only when needed.

Highlighted

Re: Get Config

Authority
Posts: 32
8937     0

 

Actually, you probably would not really want to use find to search for the config revisions based on the collection timestamp in this case.  If another config collection for the device has taken place subsequently, the LastCollected time would no longer be a match for this timestamp.  That may be pretty unlikely, but it's not impossible.

 

It would probably better to just use the running_config and saved_config calls to get the needed ConfigRevisionIDs for the most recently collected configs:

 

   /api/3/devices/running_config?DeviceID=2

 

and

 

   /api/3/devices/saved_config?DeviceID=2

 

 

 

Highlighted

Re: Get Config

Techie
Posts: 9
8937     0

That's the first thing I looked for. SNMP-set does not cause a Config message to be generated. Figured I could also do an adHoc call with config terminal and exit, which would generate a config message so NetMRI would fetch a new config for each device. 

Highlighted

Re: Get Config

Techie
Posts: 9
8937     0

Works great. 

Thanks

Highlighted

Re: Get Config

Posts: 6
8937     0

Will this pull information such as NTP, Syslog, SSH, etc.?

Showing results for 
Search instead for 
Do you mean 

Recommended for You