Changeset 208
- Timestamp:
- Feb 16, 2017, 7:58:44 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r207 r208 43 43 $SWITCH_LEVEL{$sw->{hostname}} = $sw->{level} || $DEFAULT{switch_level} || 2; 44 44 $SWITCH_DB{$sw->{hostname}} = $sw; 45 46 # SNMP parameter initialisation 47 my %session = ( -hostname => $sw->{hostname} ); 48 $session{-version} = $sw->{version} || 1; 49 $session{-port} = $sw->{snmpport} || $DEFAULT{snmpport} || 161; 50 if (exists $sw->{version} and $sw->{version} eq '3') { 51 $session{-username} = $sw->{username} || 'snmpadmin'; 52 } 53 else { 54 $session{-community} = $sw->{community} || $DEFAULT{community} || 'public'; 55 } 56 $sw->{snmp_param_session} = \%session; 45 57 } 46 58 @SWITCH_LIST = reverse sort { $SWITCH_LEVEL{$a->{hostname}} <=> $SWITCH_LEVEL{$b->{hostname}} } @{$KLASK_CFG->{switch}}; … … 2048 2060 2049 2061 my $sw = $SWITCH_DB{$switch_name}; 2050 my %session = ( -hostname => $sw->{hostname} ); 2051 $session{-version} = $sw->{version} || 1; 2052 $session{-port} = $sw->{snmpport} || $DEFAULT{snmpport} || 161; 2053 if (exists $sw->{version} and $sw->{version} eq '3') { 2054 $session{-username} = $sw->{username} || 'snmpadmin'; 2055 } 2056 else { 2057 $session{-community} = $sw->{community} || $DEFAULT{community} || 'public'; 2058 } 2059 $sw->{local_session} = \%session; 2060 2061 my ($session, $error) = Net::SNMP->session( %{$sw->{local_session}} ); 2062 my ($session, $error) = Net::SNMP->session( %{$sw->{snmp_param_session}} ); 2062 2063 print "$error \n" if $error; 2063 2064
Note: See TracChangeset
for help on using the changeset viewer.