⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfgmaker

📁 主要用于监控网络流量并动态产生可视化结果
💻
📖 第 1 页 / 共 2 页
字号:
      #    issues - fwo@obsidian.co.za 2000/01/17      chomp($router);      if(!($router =~ /^[0-9]{1,3}.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/)){	  print "\nERROR: when specifying --iponly, please use a valid\n";	  print "ip address for the router. Do not use a symbolic name.\n\n";	  exit 1;      }  }  if($workdir) {  	print "WorkDir: $workdir\n\n";  } else {  	print "# Add a WorkDir: /some/path line to this file\n\n";  }  $session = SNMP_Session->open ($router, $community, 161)	|| die "Error opening SNMP session to $router";    my($sysDescr,$sysContact,$sysName,$sysLocation,$ifNumber,$sysObjectID) =    snmpget("$community\@$router",	    'sysDescr','sysContact','sysName',	'sysLocation', 'ifNumber', 'sysObjectID');   my $sysDescr_orig=$sysDescr;   $sysDescr_orig =~ s/[\r\n ]+/ /g;   $sysDescr =~ s/[\r\n]+/<BR>/g;  # Change returns to <BR>   my($cisco_router_sysid) = '1\.3\.6\.1\.4\.1\.9';   my($livingston_router_sysid) = '1\.3\.6\.1\.4\.1\.307';   my($ciscobox) = ($sysObjectID =~ /^$cisco_router_sysid/);   my($portmaster) = ($sysObjectID =~ /^$livingston_router_sysid/);    print <<ECHO;####################################################################### Description: $sysDescr_orig#     Contact: $sysContact# System Name: $sysName#    Location: $sysLocation#.....................................................................ECHO  $session->map_table ([[1,3,6,1,2,1,4,20,1,1],	# ipAdEntAddr			[1,3,6,1,2,1,4,20,1,2]], # ipAdEntIf		       sub ($@) {			   my ($index, $ipadentaddr, $ipadentif) = @_;			   grep (defined $_ && ($_=pretty_print $_),				 ($ipadentif, $ipadentaddr));			   $ipaddr{$ipadentif} = $ipadentaddr;			   $iphost{$ipadentif} = 			       gethostbyaddr(pack('C4',split(/\./,$ipaddr{$ipadentif})), AF_INET);			   if (!defined $iphost{$ipadentif} || ($iphost{$ipadentif} eq '')){			       $iphost{$ipadentif} = 'No hostname defined for IP address';			   }		       });  print STDERR "Got Addresses\n" if $DEBUG;  print STDERR "Got IfTable\n" if $DEBUG;  my(%sifdesc,%siftype,%sifspeed,%sifadminstatus,%sifoperstatus,%sciscodescr);  ### May need the cisco IOS version number so we know which oid to use  ###   to get the cisco description.  ###  ### - mjd 2/5/98 (Mike Diehn) (mdiehn@mindspring.net)  ###  my ($cisco_ver, $cisco_descr_oid, @ciscodescr);  if ( $ciscobox ) {    ($cisco_ver) = ($sysDescr =~ m/Version\s+([\d\.]+)\(\d/o);    $cisco_descr_oid = ($cisco_ver ge "11.2") ? "ifAlias" : "CiscolocIfDescr";  }$session->map_table ([[1,3,6,1,2,1,2,2,1,1], # ifIndex		      [1,3,6,1,2,1,2,2,1,2], # ifDescr		      [1,3,6,1,2,1,2,2,1,3], # ifType		      [1,3,6,1,2,1,2,2,1,5], # ifSpeed		      [1,3,6,1,2,1,2,2,1,7], # ifAdminStatus		      [1,3,6,1,2,1,2,2,1,8]], # ifOperStatussub ($@) {    my ($rowindex,$index,$ifdescr,$iftype,$ifspeed,$ifadminstatus,$ifoperstatus) = @_;    grep (defined $_ && ($_=pretty_print $_),	  ($index,$ifdescr,$iftype,$ifspeed,$ifadminstatus,$ifoperstatus));    $sifdesc{$index} = $ifdescr;    $siftype{$index} = $iftype;    $sifspeed{$index} = $ifspeed;    $sifadminstatus{$index} = $ifadminstatus;    $sifoperstatus{$index} = $ifoperstatus;    if ($portmaster && $vendor) {            # We can only approximate speeds      #       # so we think that ppp can do 76800 bit/s, and slip 38400.      # (actualy, slip is a bit faster, but usualy users with newer modems      # use ppp). Alternatively, you can set async speed to 115200 or      # 230400 (the maximum speed supported by portmaster).      #       # But if the interface is ptpW (sync), max speed is 128000      # change it to your needs. On various Portmasters there are      # various numbers of sync interfaces, so modify it.      #       #  The most commonly used PM-2ER has only one sync.      #       #  Paul Makeev (mac@redline.ru)      #       if ($siftype{$index} eq '23') {              if ($sifdesc{$index} eq 'ptpW1') {                      $sifspeed{$index} = 128000;              } else {                      $sifspeed{$index} = 76800;              }      } elsif ($siftype{$index} eq '28') {              $sifspeed{$index} = 38400;      } elsif ($siftype{$index} eq '6') {              $sifspeed{$index} = 10000000;      }    }    ### Move this section south so we know what type of    ###  circuit we're looking at before we retrieve    ###  the cisco interface alias.    ###    ### This whole cicso thing should be re-written, but since    ###   this script doesn't need to run quickly...    ###    ###  - mjd 2/5/98    ###    # Get the user configurable interface description entered in the config     # if it's a cisco-box    #    if ($ciscobox && $vendor) {	my ($enoid, @descr);	$enoid = $cisco_descr_oid . "." . $index;	if ( $cisco_ver ge "11.2" or $siftype{$index} != '32' ) {	  ### This is either not a frame-relay sub-interface or	  ###  this router is running IOS 11.2+ and interface	  ###  type won't matter. In either of these cases, it's	  ###  ok to try getting the ifAlias or ciscoLocIfDesc.	  ###	  @descr = snmpget("$community\@$router", $enoid);	} else {	  ### This is a frame-relay sub-interface *and* the router	  ###  is running an IOS older than 11.2. Therefore, we can	  ###  get neither ifAlias nor ciscoLocIfDesc. Do something	  ###  useful.	  ###	  @descr = ("Cisco PVCs descriptions require IOS 11.2+.");	} # end if else	### Put whatever I got into the array we'll use later to append the result	###   of this operation onto the results from the ifDescr fetch.	###	push @ciscodescr, shift @descr;    } # end if ($cisco_box && $vendor)    # especially since cisco does not return a if    # descr for each interface it has ...    ## JB 2/8/97 - sometimes IOS inserts E1 controllers in the standard-MIB    ## interface table, but not in the local interface table. This puts the    ## local interface description table out-of-sync. the following     ## modification skips over E1 cards as interfaces.    #    ### I suspect that the mod I made above, to use the ifAlias    ###   oid if possible, may cause problems here. If it seems    ###   that your descriptions are out of sync, try commenting    ###   out the "if ( condition )" and it's closing right brace    ###   so that the "shift @ciscodescr" get executed for *all*    ###   iterations of this loop.    ###    ### - mjd 2/5/95    ###    if ($ciscobox && $siftype{$index} != 18) {          $sciscodescr{$index} = "<BR>" . (shift @ciscodescr) if @ciscodescr;    }});  my $index;  foreach $index ( sort { $a <=> $b } keys %sifdesc) {    my $c;    my $speed = int($sifspeed{$index} / 8); # bits to byte    my $speed_str=&fmi($speed);    my $name="$iphost{$index}";    $name = "$router.$index" if not $name or $name =~ /\s/ or $iponly;  my $err_msg;      $err_msg .= "######## - administratively not UP\n" if ($sifadminstatus{$index} != 1);# this check added by Josh - don't query E1-stack controllers  $err_msg .= "######## - DS1 type\n" 	  if ($siftype{$index} == 18);# i might be mistaken on this one - fwo@obsidian.co.za  $err_msg .= "######## - E1 type\n" 	  if ($siftype{$index} == 19);  $err_msg .= "######## - it is a softwareLoopback interface\n" 	  if ($siftype{$index} == 24);  $err_msg .= "######## - has an unrealistic speed setting\n" 	  if (($speed == 0 ) || ($speed > 400 * 10**6));    $err_msg .= "######## - administratively not UP\n" 	  if ($sifoperstatus{$index} == 3) ;  if($err_msg ne "") {    print <<ECHO;################ This Interface not configured :$err_msg######## It is commented out for this reason.########ECHO    $c="# ";  }else {    $c = '';  }      print <<ECHO;${c}${c}Target[$name]: $index:$community\@$router${c}MaxBytes[$name]: $speed${c}Title[$name]: $sysName ($iphost{$index}): $sifdesc{$index}ECHOif($optctl{"options"}) {    print "${c}Options[$name]: $optctl{'options'}\n";}   print <<ECHO;${c}PageTop[$name]: <H1>Traffic Analysis for $sifdesc{$index}${c} $sciscodescr{$index}</H1>${c} <TABLE>${c}   <TR><TD>System:</TD><TD>$sysName in $sysLocation</TD></TR>${c}   <TR><TD>Maintainer:</TD><TD>$sysContact</TD></TR>${c}   <TR><TD>Interface:</TD><TD>$sifdesc{$index} ($index)</TD></TR>${c}   <TR><TD>IP:</TD><TD>$iphost{$index} ($ipaddr{$index})</TD></TR>${c}   <TR><TD>Max Speed:</TD>${c}       <TD>$speed_str ($ifType_d{$siftype{$index}})</TD></TR>${c}  </TABLE>${c}#---------------------------------------------------------------ECHO  }}  main;exit(0);sub fmi {  my($number) = $_[0];  my(@short);  @short = ("Bytes/s","kBytes/s","MBytes/s","GBytes/s");  my $digits=length("".$number);  my $divm=0;  while ($digits-$divm*3 > 4) { $divm++; }  my $divnum = $number/10**($divm*3);  return sprintf("%1.1f %s",$divnum,$short[$divm]);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -