mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			74 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| # (c) 2013, 2014, f0o@devilcode.org
 | |
| # This program is free software: you can redistribute it and/or modify
 | |
| # it under the terms of the GNU General Public License as published by
 | |
| # the Free Software Foundation, either version 3 of the License, or
 | |
| # (at your option) any later version.
 | |
| # 
 | |
| # This program is distributed in the hope that it will be useful,
 | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | |
| # GNU General Public License for more details.
 | |
| # 
 | |
| # You should have received a copy of the GNU General Public License
 | |
| # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |
| 
 | |
| BASE='.1.3.6.1.2.1.31.1.1.1.18'
 | |
| ID=$(cut -d . -f 13 <<< $2)
 | |
| cache=$(ip l)
 | |
| 
 | |
| if [ -z "$ID" ]; then
 | |
| 	ID=0
 | |
| fi
 | |
| 
 | |
| if [ "$1" = "-n" ]; then
 | |
| 	IFS="
 | |
| "
 | |
| 	for dev in $(grep mtu <<<"$cache" | cut -d : -f 1|sort -n); do
 | |
| 		if [ "$LAST" == "$ID" ]; then
 | |
| 			ID=$dev
 | |
| 			BRK=1
 | |
| 			break
 | |
| 		else
 | |
| 			LAST=$dev
 | |
| 		fi
 | |
| 	done
 | |
| 	if [ -z "$BRK" ]; then
 | |
| 		exit 0
 | |
| 	fi
 | |
| fi
 | |
| 
 | |
| IFACE=$(grep "^${ID}: " <<<"$cache" | sed 's/[:@]\s/ /g'| cut -d " " -f 2)
 | |
| 
 | |
| echo ${BASE}.${ID}
 | |
| if [ "X${IFACE}" = "X" ]; then
 | |
| 	echo noSuchName
 | |
| else
 | |
| 	echo "string"
 | |
| 	if [ -x /usr/bin/distro ]; then
 | |
| 		case $(distro | cut -d " " -f 1) in
 | |
| 			Debian)
 | |
| 				cnf="/etc/network/interfaces"
 | |
| 			;;
 | |
| 			Gentoo)
 | |
| 				cnf="/etc/conf.d/net"
 | |
| 			;;
 | |
| 			CentOS|RedHat|SuSE|Mandriva|Mandrake)
 | |
| 				cnf="/etc/sysconfig/network-scripts/ifcfg-$IFACE"
 | |
| 			;;
 | |
| 			Archlinux)
 | |
| 				cnf="/etc/conf.d/net-conf-$IFACE"
 | |
| 			;;
 | |
| 			*)
 | |
| 				cnf=""
 | |
| 			;;
 | |
| 		esac
 | |
| 	fi
 | |
| 	if [ -n "$cnf" ]; then
 | |
| 		echo $(grep -i "^# $IFACE:" $cnf | sed "s/^# $IFACE: //i")
 | |
| 	else
 | |
| 		echo
 | |
| 	fi
 | |
| fi
 | |
| exit 0
 |