- Subscribe to RSS Feed
- Mark as New
- Printer Friendly Page
- Report Inappropriate Content
NetMRI saving data to files using ARCHIVE
The ARCHIVE directive is used to save the output of a script command to a file which can later be retrieved, either for archiving or for external processing. To do this, just put ARCHIVE: in front of any line from your script’s Action-Commands or Trigger-Commands section:
ARCHIVE: sh ver
The default filename is <DeviceID>-<Index>.log. If ARCHIVE is used more than once in the same script (as in a Trigger that gets executed multiple times), the <Index> value will be incremented so each command gets logged to a separate file.
When the job has completed, the log file(s) for a given device can be retrieved from the GUI by going to the “Files” tab in the Job Details Viewer:
(In the above, the ARCHIVE data is in the three 32-x.log files). You can change the filenames by adding the desired name to the ARCHIVE statement (in parentheses), like this:
ARCHIVE (version): sh ver
ARCHIVE (running): sh running-config
ARCHIVE (startup): sh startup-config
which will produce files named version.txt, running.txt, and startup.txt.
Undocumented Feature Alert: In older versions of NetMRI, if you specified the same filename for more than command, the output of each command would be appended to the file. In NetMRI version 6.5 and later, this behavior has changed, and the file is overwritten by each command.
Note that. using names like the above, if the job runs for more than one device, the same filenames will be used for each one and the files will end up overwriting each other. To avoid this, you can use the built-in $ipaddress variable to include the device IP address in the filename.
Once a job batch completes, all of the related ARCHIVE files will automatically be copied into a single ZIP file, which can be collected from the “Files” tab of the Job Viewer (not the Job Details Viewer):
Undocumented Feature Alert: Note that this ZIP file only contains *.txt files. That means it will not be created unless you change the ARCHIVE filename to something besides the default (which has a .log extension instead of .txt).
Additionally, the most recently created ZIP file will also be available for download directly from the NetMRI, using this URL:http://<NetMRI_IP>/netmri/ccs/tx/common/GetArchive.tdf.
Regarding filenames… It is perfectly legal and reasonable to combine the use of $ipaddress with other variables as well. For example, a customer wanted to capture all the BGP routes for each VRF that was defined on his routers. The solution was to use a Trigger with the VRF name in a variable ($vrfname), and then to include this variable in the ARCHIVE filename along with the IP address:
ARCHIVE ($ipaddress-$vrfname): show ip route vrf $vrfname bgp
This produced a nicely-named list of files like:
Note that this works if the two variables are separated by hyphens, spaces, or other non-word characters (or by nothing at all). It specifically doesnot work when they are separated by underscores, since those are legal in Perl variable names – so something like $ipaddress_$vrfname would actually produce a file whose name only contained the $vrfname value, because the first part would be interpreted as a variable named “$ipaddress_” – which most likely does not exist in the script.