📄 cfgmaker
字号:
#! /usr/sepp/bin/perl# -*- mode: Perl -*-################################################################### MRTG 2.8.12 -- Config file creator################################################################### Created by Tobias Oetiker <oetiker@ee.ethz.ch># this produces a config file for one router, by pulling info# off the router via snmp################################################################### Distributed under the GNU copyleftuse BER "0.57";use SNMP_Session "0.59";use SNMP_util "0.57";use Getopt::Long;use Socket;use strict;use vars '$DEBUG';my $DEBUG = 0;my (%optctl) = ();my ($session, %ipaddr, %iphost);sub main { snmpmapOID('ipAdEntAddr' => '1.3.6.1.2.1.4.20.1.1', 'ipAdEntIfIndex' => '1.3.6.1.2.1.4.20.1.2', 'sysObjectID' => '1.3.6.1.2.1.1.2.0', 'CiscolocIfDescr' => '1.3.6.1.4.1.9.2.2.1.1.28', 'ifAlias' => '1.3.6.1.2.1.31.1.1.1.18'); my(%ifType_d)=('1'=>'Other', '2'=>'regular1822', '3'=>'hdh1822', '4'=>'ddnX25', '5'=>'rfc877x25', '6'=>'ethernetCsmacd', '7'=>'iso88023Csmacd', '8'=>'iso88024TokenBus', '9'=>'iso88025TokenRing', '10'=>'iso88026Man', '11'=>'starLan', '12'=>'proteon10Mbit', '13'=>'proteon80Mbit', '14'=>'hyperchannel', '15'=>'fddi', '16'=>'lapb', '17'=>'sdlc', '18'=>'ds1', '19'=>'e1', '20'=>'basicISDN', '21'=>'primaryISDN', '22'=>'propPointToPointSerial', '23'=>'ppp', '24'=>'softwareLoopback', '25'=>'eon', '26'=>'ethernet-3Mbit', '27'=>'nsip', '28'=>'slip', '29'=>'ultra', '30'=>'ds3', '31'=>'sip', '32'=>'frame-relay', '33'=>'rs232', '34'=>'para', '35'=>'arcnet', '36'=>'arcnetPlus', '37'=>'atm', '38'=>'miox25', '39'=>'sonet', '40'=>'x25ple', '41'=>'iso88022llc', '42'=>'localTalk', '43'=>'smdsDxi', '44'=>'frameRelayService', '45'=>'v35', '46'=>'hssi', '47'=>'hippi', '48'=>'modem', '49'=>'aal5', '50'=>'sonetPath', '51'=>'sonetVT', '52'=>'smdsIcip', '53'=>'propVirtual', '54'=>'propMultiplexor', '55'=>'100BaseVG', #### New IF Types added 9/24/98 by Russ Carleton (roccor@livenetworking.com) #### based on the IANA file updated at ftp://ftp.isi.edu/mib/ianaiftype.mib '56'=>'Fibre Channel', '57'=>'HIPPI Interface', '58'=>'Obsolete for FrameRelay', '59'=>'ATM Emulation of 802.3 LAN', '60'=>'ATM Emulation of 802.5 LAN', '61'=>'ATM Emulation of a Circuit', '62'=>'FastEthernet (100BaseT)', '63'=>'ISDN & X.25', '64'=>'CCITT V.11/X.21', '65'=>'CCITT V.36', '66'=>'CCITT G703 at 64Kbps', '67'=>'Obsolete G702 see DS1-MIB', '68'=>'SNA QLLC', '69'=>'Full Duplex Fast Ethernet (100BaseFX)', '70'=>'Channel', '71'=>'Radio Spread Spectrum (802.11)', '72'=>'IBM System 360/370 OEMI Channel', '73'=>'IBM Enterprise Systems Connection', '74'=>'Data Link Switching', '75'=>'ISDN S/T Interface', '76'=>'ISDN U Interface', '77'=>'Link Access Protocol D (LAPD)', '78'=>'IP Switching Opjects', '79'=>'Remote Source Route Bridging', '80'=>'ATM Logical Port', '81'=>'AT&T DS0 Point (64 Kbps)', '82'=>'AT&T Group of DS0 on a single DS1', '83'=>'BiSync Protocol (BSC)', '84'=>'Asynchronous Protocol', '85'=>'Combat Net Radio', '86'=>'ISO 802.5r DTR', '87'=>'Ext Pos Loc Report Sys', '88'=>'Apple Talk Remote Access Protocol', '89'=>'Proprietary Connectionless Protocol', '90'=>'CCITT-ITU X.29 PAD Protocol', '91'=>'CCITT-ITU X.3 PAD Facility', '92'=>'MultiProtocol Connection over Frame/Relay', '93'=>'CCITT-ITU X213', '94'=>'Asymetric Digitial Subscriber Loop (ADSL)', '95'=>'Rate-Adapt Digital Subscriber Loop (RDSL)', '96'=>'Symetric Digitial Subscriber Loop (SDSL)', '97'=>'Very High Speed Digitial Subscriber Loop (HDSL)', '98'=>'ISO 802.5 CRFP', '99'=>'Myricom Myrinet', '100'=>'Voice recEive and transMit (voiceEM)', '101'=>'Voice Foreign eXchange Office (voiceFXO)', '102'=>'Voice Foreign eXchange Station (voiceFXS)', '103'=>'Voice Encapulation', '104'=>'Voice Over IP Encapulation', '105'=>'ATM DXI', '106'=>'ATM FUNI', '107'=>'ATM IMA', '108'=>'PPP Multilink Bundle', '109'=>'IBM IP over CDLC', '110'=>'IBM Common Link Access to Workstation', '111'=>'IBM Stack to Stack', '112'=>'IBM Virtual IP Address (VIPA)', '113'=>'IBM Multi-Protocol Channel Support', '114'=>'IBM IP over ATM', '115'=>'ISO 802.5j Fiber Token Ring', '116'=>'IBM Twinaxial Data Link Control (TDLC)', '117'=>'Gigabit Ethernet', '118'=>'Higher Data Link Control (HDLC)', '119'=>'Link Access Protocol F (LAPF)', '120'=>'CCITT V.37', '121'=>'CCITT X.25 Multi-Link Protocol', '122'=>'CCITT X.25 Hunt Group', '123'=>'Transp HDLC', '124'=>'Interleave Channel', '125'=>'Fast Channel', '126'=>'IP (for APPN HPR in IP Networks)', '127'=>'CATV MAC Layer', '128'=>'CATV Downstream Interface', '129'=>'CATV Upstream Interface', '130'=>'Avalon Parallel Processor', '131'=>'Encapsulation Interface', '132'=>'Coffee Pot', '133'=>'Circuit Emulation Service', '134'=>'ATM Sub Interface', '135'=>'Layer 2 Virtual LAN using 802.1Q', '136'=>'Layer 3 Virtual LAN using IP', '137'=>'Layer 3 Virtual LAN using IPX', '138'=>'IP Over Power Lines', '139'=>'Multi-Media Mail over IP', '140'=>'Dynamic synchronous Transfer Mode (DTM)', '141'=>'Data Communications Network', '142'=>'IP Forwarding Interface' ); my($vendor)=0; my($iponly)=0; my($workdir)=0; my($community,$router,%defaults); my($res); # Just need to make sure that all perl installations have the GetOpt module # - fwo@obsidian.co.za # $res = GetOptions(\%optctl,"vendor","iponly","workdir=s","options=s"); if($res == 0 ) { print "\nError in arguments. Please run cfgmaker with no arguments for help!\n\n"; exit 1; } if($optctl{"vendor"}) { $vendor = 1; } if($optctl{"iponly"}) { $iponly = 1; } if($optctl{"workdir"}) { $workdir = $optctl{"workdir"}; } if($optctl{"options"}) { foreach $res(split(',',$optctl{"options"})) { chomp($res); next if($res eq "growright"); next if($res eq "bits"); next if($res eq "perminute"); next if($res eq "perhour"); next if($res eq "noinfo"); next if($res eq "nopercent"); next if($res eq "transparent"); next if($res eq "integer"); next if($res eq "dorelpercent"); next if($res eq "gauge"); next if($res eq "absolute"); next if($res eq "unknaszero"); print "\nERROR:$res is not a valid option for --options, exiting!\n"; exit 1; } } $res = 0;#TODO: check for conflicting info in options - l->r and r->l print STDERR "iponly=$iponly\n" if $DEBUG; print STDERR "vendor=$vendor\n" if $DEBUG; print STDERR "workdir=$workdir\n" if $DEBUG; ($community,$router) = ($1,$2) if $ARGV[0] =~ /(.*)\@(.*)/; if(!($community) && !($router)) { print <<USAGE;USAGE: cfgmaker [--vendor] [other options] 'community'\@'router'use the --vendor option to try and wrestle some better information from willing livingston and cisco routers ... (may not work)[other options] can be one of the following:use the --iponly option to force the targets to the ip adress of the router being queried. Also note that the 'router' option must be the ip address and not the symbolic name.use the --workdir '/some/path' option to add the WorkDir option to the cfg file being generated.use the --options 'defaults' to set default options for each target. defaults is a comma seperated list and can contain the following : growright bits perminute perhour noinfo nopercent transparent integer dorelpercent gauge absolute unknaszero See the mrtg.cfg doccumentation for descriptions of the above options. NOTE: no checking for conflicting options are done at the moment.EXAMPLE: cfgmaker public\@ezwf7.ethz.ch >>mrtg.cfgUSAGE exit 1; } if($iponly) { # We only want to work with ip numbers and not names # Check to see whether the name is a valid ip address # If not bail - we do not want to deal with reverse dns
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -