[mrtg] cfgmaker error
micro at gsc.weblinq.com
micro at gsc.weblinq.com
Tue Apr 17 16:26:31 MEST 2001
Hi there Anybody from t helist!
What should be the right code for this cfgmaker that i have, pls help me
any#./cfgmaker
syntax error in file ./cfgmaker at line 16, next 2 tokens "@main:"
syntax error in file ./cfgmaker at line 19, next 2 tokens "use strict"
/^(?:(ms)?(dos|win(32|nt)?))/: ?+* follows nothing in regexp at ./cfgmaker
line 23.
this is my code
thanks~
#! /usr/bin/perl
# -*- mode: Perl -*-
##################################################################
# MRTG 2.9.11pre1 -- Config file creator
##################################################################
# Created by Tobias Oetiker <oetiker at ee.ethz.ch>
# this produces an mrtg config file for one router or more routers
# by pulling info off the router via snmp
##################################################################
# Distributed under the GNU copyleft
# Copyright 2000 by Tobias Oetiker
##################################################################
# DEBUG TARGETS
# base - basic program flow
@main::DEBUG=qw(base);
require 5.005;
use strict;
BEGIN {
# Automatic OS detection ... do NOT touch
if ( $^O =~ /^(?:(ms)?(dos|win(32|nt)?))/i ) {
$main::OS = 'NT';
$main::SL = '\\';
$main::PS = ';';
} elsif ( $^O =~ /^VMS$/i ) {
$main::OS = 'VMS';
$main::SL = '.';
$main::PS = ':';
} else {
$main::OS = 'UNIX';
$main::SL = '/';
$main::PS = ':';
}
}
use FindBin;
use lib "${FindBin::Bin}";
use lib "${FindBin::Bin}${main::SL}..${main::SL}lib${main::SL}mrtg2";
use MRTG_lib "2.090009";
use SNMP_util "0.77";
use SNMP_Session "0.83";
use Getopt::Long;
use Pod::Usage;
use Socket;
sub main {
my %opt;
my %routers;
my %confcache;
init();
$opt{fullcmd} = "$0 ".(join " ", map {$_ =~ /[ \[\]\*\{\}\;\>\<\&]/ ?
"'$_'"
: $_ } @ARGV);
$opt{community}="public";
options(\%opt,\%routers);
foreach my $router (keys %routers) {
# pod2usage(-verbose=>1,-message=>"ERROR: Could not Parse $router\n")
# unless $router =~ /.*\@.*/;
debug('base',"Get Device Info on $router");
$routers{$router}{deviceinfo} = DeviceInfo($router);
debug('base',"Populating confcache");
populateconfcache(\%confcache,$router,1,{});
debug('base',"Get Interface Info");
InterfaceInfo(\%confcache,\%routers,$router,\%opt)
}
GenConf(\%opt,\%routers,\%confcache);
}
main;
exit 0;
sub InterfaceInfo($$$$) {
my $confcache = shift;
my $routers = shift;
my $router = shift;
my $opt = shift;
my @Variables = qw (ifIndex ifType ifSpeed
ifAdminStatus ifOperStatus);
if ($routers->{$router}{deviceinfo}{Vendor} eq 'cisco' &&
$routers->{$router}{deviceinfo}{sysDescr} =~
m/Version\s+(\d\d\.\d+)/) {
push @Variables, ($1 > 11.0) ? "ifAlias" : "CiscolocIfDescr";
}
my $descr =
$routers->{$router}{deviceinfo}{sysDescr};
if ($routers->{$router}{deviceinfo}{Vendor} eq 'cisco'
&&
$descr =~ m/Catalyst\sOperating\sSystem/ )
{
push
@Variables, "CiscoCatalystPortName";
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://www.ee.ethz.ch/~slist/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the mrtg
mailing list