[SOLVED] 0 Items / 0 Rows ????

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
eminion
Posts: 13
Joined: Fri Jan 25, 2008 4:23 am
Location: Germany

[SOLVED] 0 Items / 0 Rows ????

Post by eminion »

Hi there

Im having a few problems, hope some of you can help me out .... would be great.

The image below shows my problem allready. I took an perl and xml file i found in this forum i belive .... so im not taking credit for it ..... but i made some changes in the xml and perl ..... the result ist thet i get 0 Items and 0 Rows

Image

Well the compiler says its ok, well but i dont think so...

thats the log of the file i changed:

Code: Select all

 Running data query [22].
+ Found type = '4 '[script query].
+ Found data query XML file at '/var/www/html/resource/script_queries/qos13.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 index'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query index'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query Ifname'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query ifDescription'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query QoSname'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query Direction'
+ Found data query XML file at '/var/www/html/resource/script_queries/qos13.xml'
+ Found data query XML file at '/var/www/html/resource/script_queries/qos13.xml'
+ Found data query XML file at '/var/www/html/resource/script_queries/qos13.xml'


here ist the code of the changed files (first the perl thend the xml) .... futher below youll find the original files .... would be great if anybody can help me out (thanks):

PERL (changed)

Code: Select all

#!/usr/bin/perl


use warnings;
use strict;

my @arraypol;
my @arrayconf;
my $line;
my $dline;
my $tmpdir;
my $node;
my $community;
my $intf;
my $cmd;
my $cmd1;
my $snmpv;
my $get_ix;
my $sindex1;
my $sindex2;
my @intindex;
my @dirindex;
my %arrayconf2_rev;
my %arrayconf_rev;
my %arrayconf;
my %arrayconf2;


if(@ARGV < 4 || ($ARGV = 4 && $ARGV[3] eq not 'Index')) 
{ 
  
   die("not enough or wrong arguments\n"); }

$node=$ARGV[0];
$community=$ARGV[1];
$snmpv=$ARGV[2];
$cmd=$ARGV[3];
$cmd1=$ARGV[4];
$get_ix=$ARGV[5];


	if ($node) {
	if ($community) {		
	chomp $node;
	chomp $community;
	#list of the all configured QoS classses
	@arrayconf =`/usr/bin/snmpwalk -Os -c $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.7.1.1.1`;

	#An arbitrary (system-assigned) config (instance independent) index for each Object. Each objects having
	#the same configuration share the same config index.
	@arraypol =`/usr/bin/snmpwalk -Os -c $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.5.1.1.2`;

	#All intefaces where QoS is enabled
	@intindex =`/usr/bin/snmpwalk -Os -c $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.1.1.1.4`;

	#Direction on interfaces were QoS is enabled
	@dirindex =`/usr/bin/snmpwalk -Os -c $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.1.1.1.3`;

	 my %class = ();
	 my %class_rev = ();
	 my %intf = ();
    	 my %intf_rev = ();
	 my %dir = ();
    	 my %dir_rev = ();

	#build indexarray - index of the QoS map name binded to the QoS name

	foreach $line(@arrayconf) {
	chomp($line);
	if ($line =~ /\.(\d+)\s+=\s+STRING:\s"(.*?)"$/) {
	$class{$1} = $2;
	$class_rev{$2} = $1;
	}
	}

	#select in a new array only interfaces that have QoS classess attached to it

	foreach $line(@intindex) {
	chomp($line);
	if ($line =~ /\.(\d+)\s+=\s+INTEGER:\s(\d+)/) {
	$intf{$1} = $2;
	$intf_rev{$2} = $1;
	}
	}

	foreach $line(@dirindex) {
	chomp($line);
	if ($line =~ /\.(\d+)\s+=\s+INTEGER:\s(\d+)/) {
	$dir{$1} = $2;
	$dir_rev{$2} = $1;
	}
	}

	#processing all querry reequests for each configure class on the interface
	#Finction to generate indexes

	foreach my $pol(@arraypol) {
	chomp($pol);
	if ($pol =~ /Gauge32:\s+(\d+)/ && $class{$1}) {
	my $idx2 = $class{$1};
	if ($pol =~ /\.(\d+)\.\d+\s+=/ && $intf{$1}) {
	my $idx1 = $intf{$1};
	my $idx3 = $dir{$1};

	#get indexes only
	if ($cmd eq 'Index') {
	print("$idx1.$idx2.$idx3\n");
	}
	
	#indexed indexes
	if($cmd eq 'query' && $cmd1 eq 'index') {
	print("$idx1.$idx2.$idx3!$idx1.$idx2.$idx3\n");
        }
      
	#get direction of police
	if($cmd eq 'query' && $cmd1 eq 'Direction') {
	    if($idx3 eq '1') {
	    print("$idx1.$idx2.$idx3!Inbound\n");
	    }
	    if($idx3 eq '2') {
	    print("$idx1.$idx2.$idx3!Outbound\n");
	    }
        }
      
        #get interface names.
        if($cmd eq 'query' &&  $cmd1 eq 'Ifname') {
        my($intindex) = `/usr/bin/snmpget -Os -c $community -v $snmpv"c" $node 1.3.6.1.2.1.31.1.1.1.1.$idx1`;
        chomp($intindex);
        my($iname) = ($intindex =~ /STRING:\s+(.+)/);
        print("$idx1.$idx2.$idx3!$iname\n");
 	}	

	#get interface description
	if ($cmd eq 'query' && $cmd1 eq 'ifDescription') {
	my($intindex) = `snmpget -Os -c $community -v $snmpv"c" $node 1.3.6.1.2.1.31.1.1.1.18.$idx1`;
	chomp($intindex);
	my($idescr) = ($intindex =~ /STRING:\s+(.+)/);
	print("$idx1.$idx2.$idx3!$idescr\n");
	}

	#get QoS class names
	if ($cmd eq 'query' && $cmd1 eq 'QoSname') {
	print("$idx1.$idx2.$idx3!$idx2\n");
	}
	}
	else {
	print STDERR "No match found: $pol\n";
	}
	}
	}

	#getting dropsper class
#        if ($cmd eq 'get' && $cmd1 eq 'QoSdropperclass') {
#        cindex($get_ix);
#        my($classdrop) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.14.$sindex1.$sindex2`;
#        $classdrop =~ s/ /./g;
#        chomp($classdrop);
#        my(@ifpol1) = split(/\./,$classdrop);
#        print $ifpol1[18] . "\n";
#        }


	#getting class traffic cbQosCMPostPolicyBitRate
        if ($cmd eq 'get' && $cmd1 eq 'QoSbitrate') {
        cindex($get_ix);
        my($classtraff) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.11.$sindex1.$sindex2`;
        $classtraff =~ s/ /./g;
        chomp($classtraff);
        my(@cbitr) = split(/\./,$classtraff);
        print $cbitr[13] . "\n";
        }


	#getting pre class traffic cbQosCMPrePolicyBitRate
        if ($cmd eq 'get' && $cmd1 eq 'QoSprecbitrate') {
        cindex($get_ix);
        my($preclasstraff) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.7.$sindex1.$sindex2`;
        $preclasstraff =~ s/ /./g;
        chomp($preclasstraff);
        my(@precbitr) = split(/\./,$preclasstraff);
        print $precbitr[13] . "\n";
        }


	#getting drop class traffic cbQosCMDropBitRate
        if ($cmd eq 'get' && $cmd1 eq 'QoSdropbitrate') {
        cindex($get_ix);
        my($droptraff) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.18.$sindex1.$sindex2`;
        $droptraff =~ s/ /./g;
        chomp($droptraff);
        my(@dropbitr) = split(/\./,$droptraff);
        print $dropbitr[13] . "\n";
        }


	#getting drop class bytes cbQosCMDropByte64
        if ($cmd eq 'get' && $cmd1 eq 'QoSdropbyte') {
        cindex($get_ix);
        my($dropbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.17.$sindex1.$sindex2`;
        $dropbyte =~ s/ /./g;
        chomp($dropbyte);
        my(@dropbyte) = split(/\./,$dropbyte);
        print $dropbyte[13] . "\n";
        }

        #getting cbQosCMNoBufDropPkt64
        if ($cmd eq 'get' && $cmd1 eq 'QosNoBufDropPkt') {
        cindex($get_ix);
        my($nobufpkt) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.21.$sindex1.$sindex2`;
        $nobufpkt =~ s/ /./g;
        chomp($nobufpkt);
        my(@nobufpkt) = split(/\./,$nobufpkt);
        print $nobufpkt[13] . "\n";
        }

        #getting cbQosTSStatsDropByte64 
        if ($cmd eq 'get' && $cmd1 eq 'QosTSDropByte') {
        cindex($get_ix);
        my($tsdropbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.19.1.1.9.$sindex1.$sindex2`;
        $tsdropbyte =~ s/ /./g;
        chomp($tsdropbyte);
        my(@tsdropbyte) = split(/\./,$tsdropbyte);
        print $tsdropbyte[13] . "\n";
        }

	#getting pre class bytes cbQosCMPrePolicyByte64
        if ($cmd eq 'get' && $cmd1 eq 'QoSprecbyte') {
        cindex($get_ix);
        my($precbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.6.$sindex1.$sindex2`;
        $precbyte =~ s/ /./g;
        chomp($precbyte);
        my(@precbyte) = split(/\./,$precbyte);
        print $precbyte[13] . "\n";
        }


	#getting class bytes cbQosCMPostPolicyByte64
        if ($cmd eq 'get' && $cmd1 eq 'QoSbyte') {
        cindex($get_ix);
        my($classbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.10.$sindex1.$sindex2`;
        $classbyte =~ s/ /./g;
        chomp($classbyte);
        my(@classbyte) = split(/\./,$classbyte);
        print $classbyte[13] . "\n";
        }

        #getting cbQosTSStatsDelayedByte64
        if ($cmd eq 'get' && $cmd1 eq 'QosTSDelayedByte') {
        cindex($get_ix);
        my($tsdelaybyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.19.1.1.3.$sindex1.$sindex2`;
        $tsdelaybyte =~ s/ /./g;
        chomp($tsdelaybyte);
        my(@tsdelaybyte) = split(/\./,$tsdelaybyte);
        print $tsdelaybyte[13] . "\n";
        }

        #getting cbQosTSStatsCurrentQSize 
        if ($cmd eq 'get' && $cmd1 eq 'QosTSCurrentQSize') {
        cindex($get_ix);
        my($tscurqsize) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.19.1.1.14.$sindex1.$sindex2`;
        $tscurqsize =~ s/ /./g;
        chomp($tscurqsize);
        my(@tscurqsize) = split(/\./,$tscurqsize);
        print $tscurqsize[13] . "\n";
        }

        #getting cbQosPoliceConformedByte64 
        if ($cmd eq 'get' && $cmd1 eq 'QosPoliceConformedByte') {
        cindex($get_ix);
        my($confbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.17.1.1.6.$sindex1.$sindex2`;
        $confbyte =~ s/ /./g;
        chomp($Confbyte);
        my(@confbyte) = split(/\./,$confbyte);
        print $confbyte[13] . "\n";
        }

        #getting cbQosPoliceConformedBitRate
        if ($cmd eq 'get' && $cmd1 eq 'QosPoliceConformedBitRate') {
        cindex($get_ix);
        my($confbitr) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.17.1.1.7.$sindex1.$sindex2`;
        $confbitr =~ s/ /./g;
        chomp($confbitr);
        my(@confbitr) = split(/\./,$confbitr);
        print $confbitr[13] . "\n";
        }

        #getting cbQosPoliceExceededByte64
        if ($cmd eq 'get' && $cmd1 eq 'QosPoliceExceededByte') {
        cindex($get_ix);
        my($exceedbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.17.1.1.13.$sindex1.$sindex2`;
        $exceedbyte =~ s/ /./g;
        chomp($exceedbyte);
        my(@exceedbyte) = split(/\./,$exceedbyte);
        print $exceedbyte[13] . "\n";
        }

        #getting cbQosPoliceExceededBitRate
        if ($cmd eq 'get' && $cmd1 eq 'QosPoliceExceededBitRate') {
        cindex($get_ix);
        my($exceedbitr) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.17.1.1.14.$sindex1.$sindex2`;
        $exceedbitr =~ s/ /./g;
        chomp($exceedbitr);
        my(@exceedbitr) = split(/\./,$exceedbitr);
        print $exceedbitr[13] . "\n";
        }

        #getting cbQosPoliceViolatedByte64
        if ($cmd eq 'get' && $cmd1 eq 'QosPoliceViolatedByte') {
        cindex($get_ix);
        my($viloatedbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.17.1.1.20.$sindex1.$sindex2`;
        $viloatedbyte =~ s/ /./g;
        chomp($viloatedbyte);
        my(@viloatedbyte) = split(/\./,$viloatedbyte);
        print $viloatedbyte[13] . "\n";
        }

 	#getting cbQosPoliceViolatedBitRate
        if ($cmd eq 'get' && $cmd1 eq 'QosPoliceViolatedBitRate') {
        cindex($get_ix);
        my($viloatedbitr) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.17.1.1.21.$sindex1.$sindex2`;
        $viloatedbitr =~ s/ /./g;
        chomp($viloatedbitr);
        my(@viloatedbitr) = split(/\./,$viloatedbitr);
        print $viloatedbitr[13] . "\n";
        }

	#getting cbQosQueueingCurrentQDepth
        if ($cmd eq 'get' && $cmd1 eq 'QosQueueingCurrentQDepth') {
        cindex($get_ix);
        my($currqdepth) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.18.1.1.1.$sindex1.$sindex2`;
        $currqdepth =~ s/ /./g;
        chomp($currqdepth);
        my(@currqdepth) = split(/\./,$currqdepth);
        print $currqdepth[13] . "\n";
        }

	#getting cbQosQueueingMaxQDepth
        if ($cmd eq 'get' && $cmd1 eq 'QosQueueingMaxQDepth') {
        cindex($get_ix);
        my($maxqdepth) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.18.1.1.2.$sindex1.$sindex2`;
        $maxqdepth =~ s/ /./g;
        chomp($maxqdepth);
        my(@maxqdepth) = split(/\./,$maxqdepth);
        print $maxqdepth[13] . "\n";
        }

	#getting cbQosQueueingDiscardByte64
        if ($cmd eq 'get' && $cmd1 eq 'QosQueueingDiscardByte') {
        cindex($get_ix);
        my($quediscbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.18.1.1.5.$sindex1.$sindex2`;
        $quediscbyte =~ s/ /./g;
        chomp($quediscbyte);
        my(@quediscbyte) = split(/\./,$quediscbyte);
        print $quediscbyte[13] . "\n";
        }

	#getting cbQosQueueingDiscardPkt64
        if ($cmd eq 'get' && $cmd1 eq 'QosQueueingDiscardPkt') {
        cindex($get_ix);
        my($quediscpkt) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.18.1.1.8.$sindex1.$sindex2`;
        $quediscpkt =~ s/ /./g;
        chomp($quediscpkt);
        my(@quediscpkt) = split(/\./,$quediscpkt);
        print $quediscpkt[13] . "\n";
        }

	#function to convert index in to real x.y values that will be required to poll data from the router
	sub cindex {
	my($index) = @_;
	my @index  = split(/\./, $index);
        my $int = $index[0];
	my $class = $index[1];
	my $direction = $index[2];
	my $tmpdir=0;
	$sindex1=0;
	$sindex2=0;

	foreach my $line(@arraypol) {
	chomp($line);
	if ($line =~ /\.(\d+)\.(\d+)\s=\s+Gauge32:\s(\d+)/
	&& $intf{$1} && $class{$3})
	{
	    my $stmpindex1=$1;
	    my $stmpindex2=$2;
	    my $tmpintf=$intf{$1};
	    my $tmpclass=$class{$3};

	    if ($tmpintf eq $int)
	    {
	    foreach my $dline(@dirindex) {
	    chomp($dline);
	    if ($dline =~ /\.(\d+)\s+=\s+INTEGER:\s(\d+)/) {
		my $tmpintf=$1;
		my $tmpdir=$2;
		if ($stmpindex1 eq $tmpintf && $class eq $tmpclass && $direction eq $tmpdir) {
		$sindex1 = $stmpindex1;
		$sindex2 = $stmpindex2;

	    }
	    }
	    }
	    }
	}
	}
	
}
}
}

XML (changed)

Code: Select all

<query>
        <name>Get Cisco CB QoS stats</name>
        <script_path>/usr/bin/perl |path_cacti|/scripts/qospol13.pl</script_path>
        <arg_prepend>|host_hostname| |host_snmp_community| |host_snmp_version|</arg_prepend>
        <arg_index>index</arg_index>
        <arg_query>query</arg_query>
        <arg_get>get</arg_get>
        <output_delimeter>!</output_delimeter>

       <fields>
                <customindex>
                        <name>index</name>
                        <direction>input</direction>
                        <query_name>index</query_name>
                </customindex>
                <ifName>
                        <name>Inetrfaces (IF-MIB)</name>
                        <direction>input</direction>
                        <query_name>Ifname</query_name>
                </ifName>
                <ifDescription>
                        <name>Description</name>
                        <direction>input</direction>
                        <query_name>ifDescription</query_name>
                </ifDescription>
                <QoSname>
                        <name>QoS Map name</name>
                        <direction>input</direction>
                        <query_name>QoSname</query_name>
                </QoSname>
                <QoSdirection>
                        <name>QoS direction</name>
                        <direction>input</direction>
                        <query_name>Direction</query_name>
                </QoSdirection>
                <QoSbitrate>
                        <name>Class bit rate</name>
                        <direction>output</direction>
                        <query_name>QoSbitrate</query_name>
                </QoSbitrate>
                <QoSprecbitrate>
                        <name>PreClass bit rate</name>
                        <direction>output</direction>
                        <query_name>QoSprecbitrate</query_name>
                </QoSprecbitrate>
                <QoSdropbitrate>
                        <name>Drop bit rate</name>
                        <direction>output</direction>
                        <query_name>QoSdropbitrate</query_name>
                </QoSdropbitrate>
                <QoSbyte>
                        <name>Class bytes</name>
                        <direction>output</direction>
                        <query_name>QoSbyte</query_name>
                </QoSbyte>
                <QoSprecbyte>
                        <name>Pre-Class bytes</name>
                        <direction>output</direction>
                        <query_name>QoSprecbyte</query_name>
                </QoSprecbyte>
                <QoSdropbyte>
                        <name>Class drop bytes</name>
                        <direction>output</direction>
                        <query_name>QoSdropbyte</query_name>
                </QoSdropbyte>
		 		 <QosNoBufDropPkt>
                        <name>NoBuf drop bytes</name>
                        <direction>output</direction>
                        <query_name>QosNoBufDropPkt</query_name>
                </QosNoBufDropPkt>
		 		 <QosTSDropByte>
                        <name>TS drop bytes</name>
                        <direction>output</direction>
                        <query_name>QosTSDropByte</query_name>
                </QosTSDropByte>
		 		 <QosTSDelayedByte>
                        <name>TS delayed bytes</name>
                        <direction>output</direction>
                        <query_name>QosTSDelayedByte</query_name>
                </QosTSDelayedByte>
		 		 <QosTSCurrentQSize>
                        <name>TS current que size</name>
                        <direction>output</direction>
                        <query_name>QosTSCurrentQSize</query_name>
                </QosTSCurrentQSize>
		 		 <QosPoliceConformedByte>
                        <name>Police conformed bytes</name>
                        <direction>output</direction>
                        <query_name>QosPoliceConformedByte</query_name>
                </QosPoliceConformedByte>
		 		 <QosPoliceConformedBitRate>
                        <name>Police conformed bit rate</name>
                        <direction>output</direction>
                        <query_name>QosPoliceConformedBitRate</query_name>
                </QosPoliceConformedBitRate>
		 		 <QosPoliceExceededByte>
                        <name>Police exceeded bytes</name>
                        <direction>output</direction>
                        <query_name>QosPoliceExceededByte</query_name>
                </QosPoliceExceededByte>
		 		 <QosPoliceExceededBitRate>
                        <name>Police exceeded bit rate</name>
                        <direction>output</direction>
                        <query_name>QosPoliceExceededBitRate</query_name>
                </QosPoliceExceededBitRate>
		 		 <QosPoliceViolatedByte>
                        <name>Police violated bytes</name>
                        <direction>output</direction>
                        <query_name>QosPoliceViolatedByte</query_name>
                </QosPoliceViolatedByte>
		 		 <QosPoliceViolatedBitRate>
                        <name>Police violated bit rate</name>
                        <direction>output</direction>
                        <query_name>QosPoliceViolatedBitRate</query_name>
                </QosPoliceViolatedBitRate>
		 		 <QosQueueingCurrentQDepth>
                        <name>Queueing current que depth</name>
                        <direction>output</direction>
                        <query_name>QosQueueingCurrentQDepth</query_name>
                </QosQueueingCurrentQDepth>
		 		 <QosQueueingMaxQDepth>
                        <name>Queueing max que depth</name>
                        <direction>output</direction>
                        <query_name>QosQueueingMaxQDepth</query_name>
                </QosQueueingMaxQDepth>
		 		 <QosQueueingDiscardByte>
                        <name>Queueing discard bytes</name>
                        <direction>output</direction>
                        <query_name>QosQueueingDiscardByte</query_name>
                </QosQueueingDiscardByte>
		 		 <QosQueueingDiscardPkt>
                        <name>Queueing discard pakets</name>
                        <direction>output</direction>
                        <query_name>QosQueueingDiscardPkt</query_name>
                </QosQueueingDiscardPkt>


       </fields>
</query>
PERL (original)

Code: Select all

#!/usr/bin/perl


use warnings;
use strict;

my @arraypol;
my @arrayconf;
my $line;
my $dline;
my $tmpdir;
my $node;
my $community;
my $intf;
my $cmd;
my $cmd1;
my $snmpv;
my $get_ix;
my $sindex1;
my $sindex2;
my @intindex;
my @dirindex;
my %arrayconf2_rev;
my %arrayconf_rev;
my %arrayconf;
my %arrayconf2;


if(@ARGV < 4 || ($ARGV = 4 && $ARGV[3] eq not 'Index')) 
{ 
  
   die("not enough or wrong arguments\n"); }

$node=$ARGV[0];
$community=$ARGV[1];
$snmpv=$ARGV[2];
$cmd=$ARGV[3];
$cmd1=$ARGV[4];
$get_ix=$ARGV[5];


	if ($node) {
	if ($community) {		
	chomp $node;
	chomp $community;
	#list of the all configured QoS classses
	@arrayconf =`/usr/bin/snmpwalk -Os -c $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.7.1.1.1`;

	#An arbitrary (system-assigned) config (instance independent) index for each Object. Each objects having
	#the same configuration share the same config index.
	@arraypol =`/usr/bin/snmpwalk -Os -c $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.5.1.1.2`;

	#All intefaces where QoS is enabled
	@intindex =`/usr/bin/snmpwalk -Os -c $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.1.1.1.4`;

	#Direction on interfaces were QoS is enabled
	@dirindex =`/usr/bin/snmpwalk -Os -c $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.1.1.1.3`;

	 my %class = ();
	 my %class_rev = ();
	 my %intf = ();
    	 my %intf_rev = ();
	 my %dir = ();
    	 my %dir_rev = ();

	#build indexarray - index of the QoS map name binded to the QoS name

	foreach $line(@arrayconf) {
	chomp($line);
	if ($line =~ /\.(\d+)\s+=\s+STRING:\s"(.*?)"$/) {
	$class{$1} = $2;
	$class_rev{$2} = $1;
	}
	}

	#select in a new array only interfaces that have QoS classess attached to it

	foreach $line(@intindex) {
	chomp($line);
	if ($line =~ /\.(\d+)\s+=\s+INTEGER:\s(\d+)/) {
	$intf{$1} = $2;
	$intf_rev{$2} = $1;
	}
	}

	foreach $line(@dirindex) {
	chomp($line);
	if ($line =~ /\.(\d+)\s+=\s+INTEGER:\s(\d+)/) {
	$dir{$1} = $2;
	$dir_rev{$2} = $1;
	}
	}

	#processing all querry reequests for each configure class on the interface
	#Finction to generate indexes

	foreach my $pol(@arraypol) {
	chomp($pol);
	if ($pol =~ /Gauge32:\s+(\d+)/ && $class{$1}) {
	my $idx2 = $class{$1};
	if ($pol =~ /\.(\d+)\.\d+\s+=/ && $intf{$1}) {
	my $idx1 = $intf{$1};
	my $idx3 = $dir{$1};

	#get indexes only
	if ($cmd eq 'Index') {
	print("$idx1.$idx2.$idx3\n");
	}
	
	#indexed indexes
	if($cmd eq 'query' && $cmd1 eq 'index') {
	print("$idx1.$idx2.$idx3!$idx1.$idx2.$idx3\n");
        }
      
	#get direction of police
	if($cmd eq 'query' && $cmd1 eq 'Direction') {
	    if($idx3 eq '1') {
	    print("$idx1.$idx2.$idx3!Inbound\n");
	    }
	    if($idx3 eq '2') {
	    print("$idx1.$idx2.$idx3!Outbound\n");
	    }
        }
      
        #get interface names.
        if($cmd eq 'query' &&  $cmd1 eq 'Ifname') {
        my($intindex) = `/usr/bin/snmpget -Os -c $community -v $snmpv"c" $node 1.3.6.1.2.1.31.1.1.1.1.$idx1`;
        chomp($intindex);
        my($iname) = ($intindex =~ /STRING:\s+(.+)/);
        print("$idx1.$idx2.$idx3!$iname\n");
 	}	

	#get interface description
	if ($cmd eq 'query' && $cmd1 eq 'ifDescription') {
	my($intindex) = `snmpget -Os -c $community -v $snmpv"c" $node 1.3.6.1.2.1.31.1.1.1.18.$idx1`;
	chomp($intindex);
	my($idescr) = ($intindex =~ /STRING:\s+(.+)/);
	print("$idx1.$idx2.$idx3!$idescr\n");
	}

	#get QoS class names
	if ($cmd eq 'query' && $cmd1 eq 'QoSname') {
	print("$idx1.$idx2.$idx3!$idx2\n");
	}
	}
	else {
	print STDERR "No match found: $pol\n";
	}
	}
	}

	#getting dropsper class
#        if ($cmd eq 'get' && $cmd1 eq 'QoSdropperclass') {
#        cindex($get_ix);
#        my($classdrop) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.14.$sindex1.$sindex2`;
#        $classdrop =~ s/ /./g;
#        chomp($classdrop);
#        my(@ifpol1) = split(/\./,$classdrop);
#        print $ifpol1[18] . "\n";
#        }


	#getting class traffic cbQosCMPostPolicyBitRate
        if ($cmd eq 'get' && $cmd1 eq 'QoSbitrate') {
        cindex($get_ix);
        my($classtraff) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.11.$sindex1.$sindex2`;
        $classtraff =~ s/ /./g;
        chomp($classtraff);
        my(@cbitr) = split(/\./,$classtraff);
        print $cbitr[13] . "\n";
        }


	#getting pre class traffic cbQosCMPrePolicyBitRate
        if ($cmd eq 'get' && $cmd1 eq 'QoSprecbitrate') {
        cindex($get_ix);
        my($preclasstraff) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.7.$sindex1.$sindex2`;
        $preclasstraff =~ s/ /./g;
        chomp($preclasstraff);
        my(@precbitr) = split(/\./,$preclasstraff);
        print $precbitr[13] . "\n";
        }


	#getting drop class traffic cbQosCMDropBitRate
        if ($cmd eq 'get' && $cmd1 eq 'QoSdropbitrate') {
        cindex($get_ix);
        my($droptraff) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.18.$sindex1.$sindex2`;
        $droptraff =~ s/ /./g;
        chomp($droptraff);
        my(@dropbitr) = split(/\./,$droptraff);
        print $dropbitr[13] . "\n";
        }


	#getting drop class bytes cbQosCMDropByte64
        if ($cmd eq 'get' && $cmd1 eq 'QoSdropbyte') {
        cindex($get_ix);
        my($dropbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.17.$sindex1.$sindex2`;
        $dropbyte =~ s/ /./g;
        chomp($dropbyte);
        my(@dropbyte) = split(/\./,$dropbyte);
        print $dropbyte[13] . "\n";
        }


	#getting pre class bytes cbQosCMPrePolicyByte64
        if ($cmd eq 'get' && $cmd1 eq 'QoSprecbyte') {
        cindex($get_ix);
        my($precbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.6.$sindex1.$sindex2`;
        $precbyte =~ s/ /./g;
        chomp($precbyte);
        my(@precbyte) = split(/\./,$precbyte);
        print $precbyte[13] . "\n";
        }


	#getting class bytes cbQosCMPostPolicyByte64
        if ($cmd eq 'get' && $cmd1 eq 'QoSbyte') {
        cindex($get_ix);
        my($classbyte) = `/usr/bin/snmpget -Os -c  $community -v $snmpv"c" $node 1.3.6.1.4.1.9.9.166.1.15.1.1.10.$sindex1.$sindex2`;
        $classbyte =~ s/ /./g;
        chomp($classbyte);
        my(@classbyte) = split(/\./,$classbyte);
        print $classbyte[13] . "\n";
        }


	#function to convert index in to real x.y values that will be required to poll data from the router
	sub cindex {
	my($index) = @_;
	my @index  = split(/\./, $index);
        my $int = $index[0];
	my $class = $index[1];
	my $direction = $index[2];
	my $tmpdir=0;
	$sindex1=0;
	$sindex2=0;

	foreach my $line(@arraypol) {
	chomp($line);
	if ($line =~ /\.(\d+)\.(\d+)\s=\s+Gauge32:\s(\d+)/
	&& $intf{$1} && $class{$3})
	{
	    my $stmpindex1=$1;
	    my $stmpindex2=$2;
	    my $tmpintf=$intf{$1};
	    my $tmpclass=$class{$3};

	    if ($tmpintf eq $int)
	    {
	    foreach my $dline(@dirindex) {
	    chomp($dline);
	    if ($dline =~ /\.(\d+)\s+=\s+INTEGER:\s(\d+)/) {
		my $tmpintf=$1;
		my $tmpdir=$2;
		if ($stmpindex1 eq $tmpintf && $class eq $tmpclass && $direction eq $tmpdir) {
		$sindex1 = $stmpindex1;
		$sindex2 = $stmpindex2;

	    }
	    }
	    }
	    }
	}
	}
	
}
}
}

XML (original)

Code: Select all

<query>
        <name>Get Cisco CB QoS stats</name>
        <script_path>/usr/bin/perl |path_cacti|/scripts/qospol.pl</script_path>
        <arg_prepend>|host_hostname| |host_snmp_community| |host_snmp_version|</arg_prepend>
        <arg_index>index</arg_index>
        <arg_query>query</arg_query>
        <arg_get>get</arg_get>
        <output_delimeter>!</output_delimeter>

       <fields>
                <customindex>
                        <name>index</name>
                        <direction>input</direction>
                        <query_name>index</query_name>
                </customindex>
                <ifName>
                        <name>Inetrfaces (IF-MIB)</name>
                        <direction>input</direction>
                        <query_name>Ifname</query_name>
                </ifName>
                <ifDescription>
                        <name>Description</name>
                        <direction>input</direction>
                        <query_name>ifDescription</query_name>
                </ifDescription>
                <QoSname>
                        <name>QoS Map name</name>
                        <direction>input</direction>
                        <query_name>QoSname</query_name>
                </QoSname>
                <QoSdirection>
                        <name>QoS direction</name>
                        <direction>input</direction>
                        <query_name>Direction</query_name>
                </QoSdirection>
                <QoSbitrate>
                        <name>Class bit rate</name>
                        <direction>output</direction>
                        <query_name>QoSbitrate</query_name>
                </QoSbitrate>
                <QoSprecbitrate>
                        <name>PreClass bit rate</name>
                        <direction>output</direction>
                        <query_name>QoSprecbitrate</query_name>
                </QoSprecbitrate>
                <QoSdropbitrate>
                        <name>Drop bit rate</name>
                        <direction>output</direction>
                        <query_name>QoSdropbitrate</query_name>
                </QoSdropbitrate>
                <QoSbyte>
                        <name>Class bytes</name>
                        <direction>output</direction>
                        <query_name>QoSbyte</query_name>
                </QoSbyte>
                <QoSprecbyte>
                        <name>Pre-Class bytes</name>
                        <direction>output</direction>
                        <query_name>QoSprecbyte</query_name>
                </QoSprecbyte>
                <QoSdropbyte>
                        <name>Class drop bytes</name>
                        <direction>output</direction>
                        <query_name>QoSdropbyte</query_name>
                </QoSdropbyte>

       </fields>
</query>
once again thanks
Last edited by eminion on Tue Jan 29, 2008 5:46 am, edited 1 time in total.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

When running from command line, what does
+ Executing script for list of indexes '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 index'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query index'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query Ifname'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query ifDescription'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query QoSname'
+ Executing script query '/usr/bin/perl /var/www/html/scripts/qospol13.pl 10.14.37.248 public 2 query Direction'
give you?
Reinhard
eminion
Posts: 13
Joined: Fri Jan 25, 2008 4:23 am
Location: Germany

Post by eminion »

thx for your reply

well im getting the indexes using snmpwalk aswell as the classnames if you mean that. The original xml and perl files are working fine aswell as the compiler log seems to be a bit longer, it shows me the interface names, qs names and so on, but if i use my it shows only the log i posted. Any idea what i did wrong?

Thanks for your help
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

This did not answer my question. I've listed some commands above that I would like you to execute and post output of each command
Reinhard
eminion
Posts: 13
Joined: Fri Jan 25, 2008 4:23 am
Location: Germany

Post by eminion »

Hi there

I dont belive it ... i had a small spelling mistake in line 272

"Global symbol "$Confbyte" requires explicit package name at /var/www/html/scripts/qospol13.pl line 272.
Execution of /var/www/html/scripts/qospol13.pl aborted due to compilation errors."

seems to be working now .... mistery solved ^^ (40 items / 8 rows)

ill post in about 2 hours (maybe later) again if its woking or not :) thx
eminion
Posts: 13
Joined: Fri Jan 25, 2008 4:23 am
Location: Germany

Post by eminion »

well im back and it seems to be working now.

once again ........ thanks gandalf
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests