I am setting up MRTG to monitor TC Classes. I have created several scripts regarding this issue.
Now after running all these script, all scripts work fine with our any error. When i runScript for creating individual Directory with IP addresses as the Directory name
mkdir.shPerl Script used to get values from TC class from a file containing output ofCode: Select all
#!/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
tc -s class show dev eth0 > class.eth0
rate.plScript for creating individual scripts for the use of CFG's for individual IP'sCode: Select all
#!/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";
make.shScript for creating individual CFG's to used for MRTGCode: Select all
#!/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
make.cfgScript created to make index.html by the use of indexmake from CFG'sCode: Select all
#!/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
index.shCode: Select all
#!/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
Code: Select all
env LANG=C /usr/bin/mrtg /files/stat/cfgs/*.cfg
Please let me know how can i remove this error and make my MRTG work.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