diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-05-12 18:38:48 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-05-12 18:40:54 -0700 |
commit | ab587ce0c92b5aeeb26eb678946a7e1faa6f9db1 (patch) | |
tree | 93a9ef4f52ffc332c3a76e842c614a03d389fc03 /scripts | |
parent | 8f2edd81ecdbfa74beff7f54deac1d83dab82416 (diff) | |
download | vyatta-cfg-system-ab587ce0c92b5aeeb26eb678946a7e1faa6f9db1.tar.gz vyatta-cfg-system-ab587ce0c92b5aeeb26eb678946a7e1faa6f9db1.zip |
Better version of SNMP IPv6 support
Need to use different syntax for community values on IPv6
versus IPv4
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/snmp/vyatta-snmp.pl | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/scripts/snmp/vyatta-snmp.pl b/scripts/snmp/vyatta-snmp.pl index 3adb37b7..e3aa3fc1 100644 --- a/scripts/snmp/vyatta-snmp.pl +++ b/scripts/snmp/vyatta-snmp.pl @@ -93,6 +93,8 @@ sub snmp_get_constants { print "sysDescr Vyatta $version\n"; print "sysObjectID 1.3.6.1.4.1.30803\n"; print "sysServices 14\n"; + print "agentaddress unix:/var/run/snmpd.socket,udp:161,udp6:161\n"; + print "smuxpeer .1.3.6.1.4.1.3317.1.2.2\n"; # ospfd print "smuxpeer .1.3.6.1.4.1.3317.1.2.5\n"; # bgpd print "smuxpeer .1.3.6.1.4.1.3317.1.2.3\n"; # ripd @@ -106,44 +108,38 @@ sub randhex { return join "", map { unpack "H*", chr(rand(256)) } 1..($length/2); } +# output snmpd.conf file syntax for community +sub print_community { + my ($config, $community, $type) = @_; + $config->setLevel("service snmp $type $community"); + + my $auth = $config->returnValue('authorization'); + $auth = 'ro' unless $auth; + $auth .= $type; # rocommunity + + my @address = $config->returnValues('client'); + push @address, $config->returnValues('network'); + + if (@address) { + foreach my $addr (@address) { + print "$auth $community $addr\n"; + } + } else { + print "$auth $community\n"; + } +} + sub snmp_get_values { my $config = new Vyatta::Config; - $config->setLevel("service snmp community"); - my @communities = $config->listNodes(); - + my @communities = $config->listNodes("service snmp community"); + foreach my $community (@communities) { + print_community($config, $community, 'community'); + } + + @communities = $config->listNodes("service snmp community6"); foreach my $community (@communities) { - my $authorization = $config->returnValue("$community authorization"); - my @clients = $config->returnValues("$community client"); - my @networks = $config->returnValues("$community network"); - - if (scalar(@clients) == 0 and scalar(@networks) == 0){ - if (defined $authorization and $authorization eq "rw") { - print "rwcommunity $community\n"; - } else { - print "rocommunity $community\n"; - } - } else { - if (scalar(@clients) != 0) { - foreach my $client (@clients){ - if (defined $authorization and $authorization eq "rw") { - print "rwcommunity $community $client\n"; - } else { - print "rocommunity $community $client\n"; - } - } - } - if (scalar(@networks) != 0){ - foreach my $network (@networks){ - if (defined $authorization and $authorization eq "rw") { - print "rwcommunity $community $network\n"; - } else { - print "rocommunity $community $network\n"; - } - - } - } - } + print_community($config, $community, 'community6'); } $config->setLevel($snmp_level); |