[mrtg] Externat Get Error

Mudasir Mirza cool_mudasir at hotmail.com
Sat Apr 26 23:18:46 CEST 2008


Hi!!
 
 I am setting up MRTG to monitor TC Classes. I have created several scripts regarding this issue. 



Quote:

Script for creating individual Directory with IP addresses as the Directory name mkdir.sh 



Code:

#!/bin/bash #set -x FILE="/users/ids.ips" cat $FILE | while read ids do ips=`echo $ids | awk '{print $1}'` mkdir /var/www/mrtg/$ips mkdir /var/www/mrtg/$ips/images cp /var/www/mrtg/mrtg*.png /var/www/mrtg/$ips/images/ done Perl Script used to get values from TC class from a file containing output of tc -s class show dev eth0 > class.eth0 rate.pl (Downloaded From Internet)



Code:

#!/usr/bin/perl # License: Are you joking? This is trivial... # USAGE: # $ARGV[0] - infile # $ARGV[1] - inclassmark # use strict; use English; my $foundclass = 0; my $classID; my $inbytes; open INFILE, $ARGV[0]; while (<INFILE>) {    if ((!$foundclass) && (/^class\s+cbq\s+(\d+:\d*)\s+/)) {       $classID = $1;       if ($classID eq $ARGV[1]) {     $foundclass = 42;       }    }    if ($foundclass && (/^\s+Sent\s+(\d+)\s+bytes/)) {       $inbytes = $1;       last;    } } close INFILE; print "$inbytes\n"; 
Script for creating individual scripts for the use of CFG's for individual IP's 
make.sh 



Code:

#!/bin/bash NETWORK="eth0" file="/users/ids.ips" dir="/files/stat/scripts" stat="/files/stat/stat.$NETWORK" rate="/files/stat/rate.pl" awk="/usr/bin/awk" rm -fr $dir mkdir $dir rm -fr $dir/*.sh cat $file | while read ids do ID=`echo $ids | $awk '{print $2}'` IP=`echo $ids | $awk '{print $1}'` touch $dir/$IP.sh echo -e "#!/bin/bash\n\n" >$dir/$IP.sh echo -e "/usr/bin/perl $rate $stat 10:$ID" >> $dir/$IP.sh done Script for creating individual CFG's to used for MRTG make.cfg 



Code:

#!/bin/bash #set -x idfile="/users/ids.ips" cfgdir="/files/stat/cfgs" shdir="/files/stat/scripts" workdir="/var/www/mrtg" awk="/usr/bin/awk" rm -fr $cfgdir mkdir $cfgdir chmod 777 -R $shdir/ cat $idfile | while read ids do ID=`echo $ids | $awk '{print $2}'` IP=`echo $ids | $awk '{print $1}'` touch $cfgdir/$IP.cfg echo "EnableIPv6: no" > $cfgdir/$IP.cfg echo "Workdir: /var/www/mrtg/$IP" >> $cfgdir/$IP.cfg echo "Options[_]: growright, unknaszero" >> $cfgdir/$IP.cfg echo "Target[tc.class]: \`$shdir/$IP.sh\`" >> $cfgdir/$IP.cfg echo "MaxBytes[tc.class]: 1000000000" >> $cfgdir/$IP.cfg echo "Title[tc.class]: TC Class $ID, IP Address $IP, Graphs" >> $cfgdir/$IP.cfg echo "Options[tc.class]: growright, nopercent" >> $cfgdir/$IP.cfg echo "PageTop[tc.class]: <H1>TC Class $ID, IP Address $IP, Graphs</H1>" >> $cfgdir/$IP.cfg echo "YLegend[tc.class]: Bytes/second" >> $cfgdir/$IP.cfg echo "ShortLegend[tc.class]: Bytes/s" >> $cfgdir/$IP.cfg done Script created to make index.html by the use of indexmake from CFG's index.sh 



Code:

#!/bin/bash #set -x file="/users/ids.ips" cfgdir="/files/stat/cfgs" workdir="/var/www/mrtg" cat $file | while read ids do IP=`echo $ids | awk '{print $1}'` indexmaker $cfgdir/$IP.cfg > $workdir/$IP/index.html done Now after running all these script, all scripts work fine with our any error. When i run 



Code:

env LANG=C /usr/bin/mrtg /files/stat/cfgs/*.cfg i get following erroe 



Quote:

WARNING: Problem with External get '/files/stat/scripts/172.16.10.10.sh': Expected a Number for 'out' but nothing' ERROR: Target[tc.class][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data 
Please let me know how can i remove this error and make my MRTG work.
 
Kind RegardsMudasir MirzaCrystal Net Communications (+92)-321-2395320
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/mrtg/attachments/20080426/a755f4d7/attachment.html 


More information about the mrtg mailing list