Changeset 210
- Timestamp:
- Feb 16, 2017, 9:49:10 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r209 r210 1970 1970 1971 1971 sub cmd_enable { 1972 my $switch = shift; 1973 my $port = shift; 1972 @ARGV = @_; 1973 1974 my $verbose; 1975 1976 GetOptions( 1977 'verbose|v' => \$verbose, 1978 ); 1979 1980 my $switch_name = shift @ARGV || q{}; 1981 my $port = shift @ARGV || q{}; 1982 1983 if ($switch_name eq q{} or $port eq q{}) { 1984 die "Usage: klask disable SWITCH_NAME PORT\n"; 1985 } 1986 1987 if (not defined $SWITCH_DB{$switch_name}) { 1988 die "Switch $switch_name must be defined in klask configuration file\n"; 1989 } 1990 1991 my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port; 1992 print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose; 1993 1994 my $sw = $SWITCH_DB{$switch_name}; 1995 my ($session, $error) = Net::SNMP->session( %{$sw->{snmp_param_session}} ); 1996 print "$error \n" if $error; 1997 1998 my $result = $session->set_request( 1999 -varbindlist => [$search_portstatus, INTEGER, 1], 2000 ); 2001 2002 $session->close; 1974 2003 1975 2004 #snmpset -v 1 -c community X.X.X.X 1.3.6.1.2.1.2.2.1.7.NoPort = 1 (up) 1976 2005 #snmpset -v 1 -c community X.X.X.X 1.3.6.1.2.1.2.2.1.7.NoPort = 2 (down) 1977 system "snmpset -v 1 -c public $switch 1.3.6.1.2.1.2.2.1.7.$port = 1";2006 #system "snmpset -v 1 -c public $switch 1.3.6.1.2.1.2.2.1.7.$port = 1"; 1978 2007 return; 1979 2008 } 1980 2009 1981 2010 sub cmd_disable { 1982 my $switch = shift; 1983 my $port = shift; 1984 1985 system "snmpset -v 1 -c public $switch 1.3.6.1.2.1.2.2.1.7.$port = 2"; 2011 @ARGV = @_; 2012 2013 my $verbose; 2014 2015 GetOptions( 2016 'verbose|v' => \$verbose, 2017 ); 2018 2019 my $switch_name = shift @ARGV || q{}; 2020 my $port = shift @ARGV || q{}; 2021 2022 if ($switch_name eq q{} or $port eq q{}) { 2023 die "Usage: klask disable SWITCH_NAME PORT\n"; 2024 } 2025 2026 if (not defined $SWITCH_DB{$switch_name}) { 2027 die "Switch $switch_name must be defined in klask configuration file\n"; 2028 } 2029 2030 my $search_portstatus = $OID_NUMBER{'portUpDown'} .'.'. $port; 2031 print "Info: switch $switch_name port $port SNMP OID $search_portstatus\n" if $verbose; 2032 2033 my $sw = $SWITCH_DB{$switch_name}; 2034 my ($session, $error) = Net::SNMP->session( %{$sw->{snmp_param_session}} ); 2035 print "$error \n" if $error; 2036 2037 my $result = $session->set_request( 2038 -varbindlist => [$search_portstatus, INTEGER, 2], 2039 ); 2040 2041 $session->close; 2042 2043 #system "snmpset -v 1 -c public $switch 1.3.6.1.2.1.2.2.1.7.$port = 2"; 1986 2044 return; 1987 2045 } … … 2486 2544 2487 2545 klask enable switch port 2488 klask disable swit h port2546 klask disable switch port 2489 2547 klask status swith port 2490 2548 … … 2526 2584 This command activate a port on a switch by SNMP. 2527 2585 So you need to give the switch and the port number on the command line. 2586 Actually, port number must be a number and not the name alias... 2528 2587 2529 2588 … … 2532 2591 This command deactivate a port on a switch by SNMP. 2533 2592 So you need to give the switch and the port number on the command line. 2593 Actually, port number must be a number and not the name alias... 2534 2594 2535 2595 … … 2538 2598 This command return the status of a port number on a switch by SNMP. 2539 2599 So you need to give the switch name and the port number on the command line. 2600 Actually, port number must be a number and not the name alias... 2540 2601 2541 2602
Note: See TracChangeset
for help on using the changeset viewer.