1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| #!/usr/bin/perl -w
use strict;
use warnings;
my $i;
my $choix;
my $nom;
my $ip;
my $telnet;
my $username="admin";
my $passwd="motsdepasse";
unshift(@INC,"C:/Perl/site/lib");
use Net::Telnet;
use Net::SNMP;
my $HOST=('$ip');
my $HOSTS=('$nom');
my $snmp_port = 161;
my $oid = « 1.3.6.1.4.1.318.1.1.12.1.5, 1.3.6.1.4.1.318.1.1.12.1.1 »;
my $host = « $ip »;
my $community = « private »
my ($session, $error) = Net::SNMP->session(-hostname = $host,-timeout = 3,-retries = 1,-community = $community,-port = $snmp_port);
do
{
print "vous voulez recherche par nom ou Par adresse Ip ?\n";
print "nom=1 et Adresse Ip=2 Quitter=3\n";
print"choix:";
$choix=<STDIN>;
if( $choix == 1 )
{
print"vous avez fait le choix 1 \n";
print"Saisir un nom : ";
$nom=<STDIN>;
$telnet->open($HOSTS);
$telnet->login($username, $passwd);
@ $oid
}
elsif( $choix == 2 )
{
print"vous avez fait le choix 2\n";
print"saisir une adresse IP :";
$ip=<STDIN>;
$telnet->open($HOST);
$telnet->login($username, $passwd);
@ $oid
}
else
{
print"vous avez fait aucun choix \n";
}
} until( $choix==3); |