- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
NETMRI gather show version information and export to a file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-13-2014 08:59 AM
Hi All,
Our team is very comfortable creating and running scripts within NetMRI. Here is where we are stuck. We need the sh ver | inc flash command from all our Cisco devices.
Since the information isn't normally stored in NetMRI because it is not a part of sh run or SNMP information, I need to run a script to get the data.
Once I get the results, how would I approach exporting it to some sort of file. With thousands of devices I was hopefully for a way to get this information easily and quickly.
Any advice on an approach would be appreciated.
Susan
You can have a script fire a custom issue
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-13-2014 09:49 AM
I'm unclear what you're actually attempting to gather out of "show ver | i flash". That exact result will vary from nothing, to the boot image filename, depending on the device you choose and what types of memory it has. Are you trying to get the capacity of flash RAM (" xxxxxK bytes of Flash")? Note upper case.
Some years ago I needed to get the capacity of both DRAM and flash RAM, and while I was at it, grabbed the IOS version and actual image filename. The script just shoved those into the arg list for a custom issue. After the batch completed, the issue details could be sorted in place or exported as a CSV and imported into a spreadsheet.
Does that help?
You could also store it in a
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-13-2014 09:56 AM
You could also store it in a custom field for the device, then you can pull out the list of devices from the UI via a CSV export.
John,
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-13-2014 11:52 AM
John,
I like the custom field idea, but I am unsure how to take the script results and push those into a custom field.
Marty,
Unlike the OS version, the actual flash filename provides more details about the code and what it supports.
Susan
Susan,
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-13-2014 12:29 PM
Susan,
You'll need to use a Perl script to set custom fields in a script, you can't do it in CCS. There is an example in the API docs in the tutorial section. See the Tools > Network > API Documentation screen.
John
Some time next week I will
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-29-2014 08:58 AM
Some time next week I will post a PERL Script that will accomplish this for you.
I need to clean it up and add some comments to it.
Twitter: https://twitter.com/sifbaksh
https://sifbaksh.com
I am also interested in this script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-15-2014 06:57 AM
Susan, sorry it took so long
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-15-2014 04:14 PM
Susan, sorry it took so long ot post this but like John stated it's in our API documentation:
Updating Custom Fields
To demonstrate how to set and update custom fields, we will write a Network Automation script which finds the serial number for a Cisco device and writes that value into a custom field "chasis_serial_number". This script starts with the usual declarations needed by the Perl compiler and the Network Automation Job engine, and opening a connection to the Network Automation by creating an instance of NetMRI_Easy.
# BEGIN-SCRIPT-BLOCK # # Script-Filter: # $Vendor eq "Cisco" # # END-SCRIPT-BLOCK use strict; use warnings; use NetMRI_Easy; # Connect to the Network Automation my $easy = new NetMRI_Easy;We create the custom field in case it does not already exist using the create_field method on the CustomFields broker.
$easy->broker->custom_fields->create_field({ model => 'Device', name => 'chasis_serial_number', type => 'string', });Determine the serial number for the device. This method may not work on all Cisco devices and there are some caveats, but it should be sufficient as an example.
my $serial_number; # The method for retrieving the serial number via the # CLI depends on the type of device. if($easy->device->DeviceType eq 'Router') { my @inventory = split /\r?\n/, $easy->send_command('show inventory'); while(my $line = shift @inventory) { if($line =~ /^NAME: \\?"\d+ chassis\\?"/ && $inventory[0] =~ /SN:\s*(\S+)\s*$/) { $serial_number = $1; last; } } } else { foreach my $line (split /\r?\n/, $easy->send_command('show version')) { if($line =~ /^System serial number\s*:\s*(.*)\s*$/) { $serial_number = $1; } } }Finally, if the serial number was discovered in the execution of this script we use the set_custom_field method on the NetMRI::API::Remote:
evice object for the target device. You can also use get_custom_field to retrieve the custom field at a later time.
if(defined $serial_number) { # Note the serial number in the log and update the field $easy->log_message('info', "updated chasis serial number $serial_number"); $easy->device->set_custom_field(chasis_serial_number => $serial_number); }
Twitter: https://twitter.com/sifbaksh
https://sifbaksh.com
TFTP Copy to a switch or Router via NetMri using line by line
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-26-2015 01:38 PM
ONeil,
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-26-2015 02:39 PM
ONeil,
Should have started a new post
This is all you need
copy tftp://10.96.0.140/c2900-universalk9-mz.SPA.153-3.M4.bin flash:c2900-universalk9-mz.SPA.153-3.M4.bin \r
Reason for that is that NEtMRI does to look that the prompt as a vlaid prompt.
Sif
Twitter: https://twitter.com/sifbaksh
https://sifbaksh.com
Sif Baksh
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-27-2015 05:59 AM
Can you post the script or
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-27-2015 09:14 AM
Can you post the script or the error you are seeing?
Twitter: https://twitter.com/sifbaksh
https://sifbaksh.com
Two \r are needed
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-27-2015 10:04 AM
Actually two \r are needed -- one for the confirmation of the source and one more for the confirmation of the destination:
copy tftp://10.96.0.140/c2900-universalk9-mz.SPA.153-3.M4.bin flash:c2900-universalk9-mz.SPA.153-3.M4.bin\r\r
But I'm pretty sure that's also going to fail because the file size is much larger than 32MB and that's the limit for TFTP. You'll need to use FTP or HTTP or HTTPS.
NETMRI gather show version information and export to a file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2015 09:42 AM
Rahul,
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2015 09:58 AM
Rahul,
If you use Archive this way:
ARCHIVE ($ipaddress): show version
Run it on 50 devices you will see a ZIP file appear under Job Viewer files
It will contain 50 files of the "show version" for each device. You can use any "Well Known" variables($name,$sysname..etc)
You can also take your show command and add them to a List in NetMRI
So capture the DeviceName or DeviceDottedIPAddress and update a list with that information
Look at the PERL API Guide for List or search getListValue()
I hope this helps,
Sif
Twitter: https://twitter.com/sifbaksh
https://sifbaksh.com
Hi Sif,
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2015 01:14 PM
I believe you should be able
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2015 01:24 PM
I believe you should be able to just open a file in append mode in Perl and print to that. However, I don't think it would be available for download in the UI, only in the admin shell. Also, if you are in a distributed environment, there will be one per collector.
You could copy it off the sandbox to some location at the end of the script, but this runs into needing to know which device is "last" - you should be able to determine this by looking at the job details status via the API, but it's a little difficult.
Hi John,
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2015 02:27 PM
