Collecting device configurations from Cisco RME using Perl

To collect configuration file from Cisco RME

  • Browse to the folder: PATH:\CSCOpx\files\rme\dcma\devfiles
  • Inside the directory there are multiple sub-directories, such as 1, 2, 3, 4, 5, etc.
    These are device entries. In each of the directories there is a PRIMARY folder.
    The PRIMARY then it splits to RUNNING and STARTUP. We would collect last version of running-config.
  • Additionally, perhaps in RUNNING we have several directories: 1,2,3
    The directory corresponds to the version. The newer version is the highest number.
  • E.g. In a directory "1" there is an "assoc" folder and a configuration file.

Naming conventions is: 75-20071107230633, which correspond to:

  • 75 - device number
  • 2007 - year
  • 11 - month
  • 07 - date
  • 23 - hour
  • 06 - minutes
  • 33 - seconds

With our script we would be able to collect last "running" configurations from all of the RME controlled devices.

Change $rootpath and destination folder D:\\CONFIGS.

use File::Copy;
$rootpath = "D:\\Program Files\\CSCOpx\\files\\rme\\dcma\\devfiles";
opendir(DIRHANDLE, $rootpath) || die "Cannot opendir: $!";
foreach $name (readdir(DIRHANDLE)) {
if ($name != "." || $name != "..") {
#print "Dir: $name\n";
opendir(DIRHANDLE1, $rootpath."\\".$name);
foreach $name1 (readdir(DIRHANDLE1)) {
# if ($name1 != "." || $name1 != "..") {
#print "-->".$name1."\n";
opendir(DIRHANDLE2, $rootpath."\\".$name."\\".$name1."\\PRIMARY\\RUNNING");
foreach $name2 (readdir(DIRHANDLE2)) {
if ($name2 != "." || $name2 != "..") {
#print "--->".$name2."\n";
opendir(DIRHANDLE3, $rootpath."\\".$name."\\".$name1."\\PRIMARY\\RUNNING\\".$name2);
foreach $name3 (readdir(DIRHANDLE3)) {
if ($name3 != "." || $name3 != "..") {
if( $name3 =~ /cfg/) {
#print "---->";
print $name3;
print "\n";
open(WRFILE, '>D:\\CONFIGS\\'.$name3);
open(ROFILE, $rootpath."\\".$name."\\".$name1."\\PRIMARY\\RUNNING\\".$name2."\\".$name3);
while ($line = ) {
print WRFILE $line;
print "\n";
}
close(ROFILE);
close(WRFILE);
}
}
}
closedir(DIRHANDLE3);
}
}
closedir(DIRHANDLE2);
# }
}
closedir(DIRHANDLE1);
#print "\n";
}
}
closedir(DIRHANDLE);

Moving your apps to Amazon or Miscrosoft Clouds?

We can help you analyze your existing infrastructure, identify the cost savings we can achieve by migrating to a cloud provider. We can then execute end-to-end migration plan of your infrastructure and bringing down your TCO.

Cloud Computing

Ready for IPv6 Migration?

The Internet is running out of the equivalent of phone numbers - familiar problem, non-trivial solution.

The world has to move to IPv6, with its 128-bit addresses. But that's easier said than done.

IPv6 Migration

Are you fluent in "Linux"?

Learn Linux from a leading expert and quickly master you Linux skills.

Learn how to simplify your workflow and increase your productivity using tips and techniques of the pros.

Ideal training for Corporate IT Beginners and Advanced IT Admins alike.

Corporate Linux Training

Who's Online

We have 3 guests and no members online