Answer the question
In order to leave comments, you need to log in
Bulk hardware configuration (again), replacing SNMP-server name -> hostname?
Hello!
I'll put aside the formalities like: "I just started working in the field of administration and ran into the problem of mass configuration of equipment ... With the development of scripts, I'm on" you ", but if you wish ... and blah blah blah" The
task is to replace the SNMP-server name to hostname.
I googled, found options from which to push off:
smart-bit.livejournal.com/9060.html
www.lissyara.su/articles/freebsd/coding/zyxel_conf...
And everything would be fine, but how to request a hostname from a piece of iron (i.e. . exactly what is written before the "#" sign)?
Please tell me how this can be implemented, or share a ready-made solution.
Answer the question
In order to leave comments, you need to log in
Already forgot about this issue. Meanwhile, I solved the problem as follows:
The script accesses the txt file, which contains the addresses and the necessary names in the format "255.255.255.255|hostname", separates the address from the text, puts them into separate variables, then goes to the address specified in the variable with the address and performs the required operations. In a name replacement operation, substitutes a variable with a hostname in the command text. Saves the settings and leaves the device. The cycle repeats until the end of the text file.
#while (<$IPadd>)
while (defined($Source = <TEMP>))
{
($IPadd, $Hostname) = (split/\|/ , $Source);
my ($command1)="$Hostname";
print "$Source $IPadd\n $Hostname";
$counter++;
chomp ($_);
$t->open($IPadd);
$t->waitfor('/:$/i');
$t->print($username);
$t->waitfor('/:$/i');
$t->print($passwd);
$t->print ("$ena");
$t->print ("$conf");
$t->print("hostname $command1");
$t->print("$command_exit");
my @command= $t->cmd(Timeout => 60, String =>"$command_wrmem");
@command= $t->cmd(Timeout => 60, String => 'y');
$t->print("$command_exit");
#$t->print("$command_exit");
print "$counter",' ';
}
close TEMP;
print ('done on ',"$counter",' ');
[email protected]: $ snmpwalk -v2c -c secretCommunity 172.32.5.254 SNMPv2-MIB::sysName.0
SNMPv2-MIB::sysName.0 = STRING: Shestaka_12_DGS
[email protected]: $
Please tell me how it can be implementedIn my opinion, the easiest way to implement this is with expect/pexpect. You should (programmatically) log in to each device, get the hostname (from the greeting or configuration), form a new command (snmp-server name ) and execute it. There is a suspicion that it will be difficult to implement this using SNMP.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question