[Nottingham] MRTG

Johan Boshoff jboshoff at rpc.co.za
Thu Aug 3 09:29:08 BST 2006


Hi Graeme,

Thanks for your advice, but I can't seem to find the script you are
talking about:

       Target[eth1]: `/usr/local/bin/local-dev.pl eth0`

Then, I also saw in the html directory that there are no html pages, only
pictures...  How do I start MRTG and will it update every 5 minutes after
that?

I have 4 IP addresses on my box.  1 Static and the other virtual.  So all
is on eth0.  Will I still have to use the line above as eth1 or must I use
both as eth0?

Please assist...

Regards,
Johan





> On Wed, 2006-08-02 at 19:33 +0200, Johan Boshoff wrote:
>> I want to monitor my traffic going in and out of my server and loaded
>> MRTG
>> but when I configure it, I don't know what to put in as the
>> community at router.  I tried the default and IP's and Host names, etc, but
>> it
>> just don;t want to work.
>
> Unless you have also installed, configured, and secured an SNMP daemon
> on your machine it is likely you'll have to use an external script to
> pass your local interface usage to MRTG.
>
> The defaults in the delivered config file are just examples, and IIRC
> are all commented out anyway so won't do a thing no matter how hard you
> try.
>
> You'll more than likely need an MRTG config file in /etc/mrtg/mrtg.conf
> like this one:
>
> # START OF CONFIG
> WorkDir: /var/www/html/traffic
> ThreshDir: /var/www/html/traffic/thresholds
> Options[_]: bits, growright
> XSize[_]:400
> YSize[_]:60
> YLegend[_]: bits/second
> ShortLegend[_]: b/s
> LegendI[_]:  In:
> LegendO[_]:  Out:
> Forks: 5
>
> #---------------------------------------------------------------
> Target[eth1]: `/usr/local/bin/local-dev.pl eth0`
> MaxBytes[eth1]: 12500000
> AbsMax[eth1]: 12500000
> Title[eth1]: gw.graemef.net eth0 (external)
> PageTop[eth1]: <H2>gw.graemef.net eth0 (external)</H2>
> # END OF CONFIG
>
> ...and a script to call in /usr/local/bin/local-dev.pl like so:
>
> #!/usr/bin/perl
> #
> # usage:
> # /usr/local/bin/local-dev.pl devname
> #
>
> $devname = @ARGV[0];
>
> exit (255) if ($devname !~ /^(eth|tun|vlan)[0-9]/);
>
> open INPUT, "/bin/cat /proc/net/dev|" or die "Oops. Could not
> open /proc/net/dev for reading: $!\n";
>
> while (<INPUT>) {
>   next unless (m/$devname/);
>   s/^\s*$devname:\s*//;
>   my ($rbyte,$rpack,$rerr,$rdrop,$rfifo,$rframe,$rcomp,$rmult,$tbyte,
> $tpack,$terr,$tdrop,$tfifo,$tframe,$tcomp,$tmult) = split(/\s+/);
>   print "$rbyte\n$tbyte\n$uptime\n$devname\n";
> }
>
> exit(0);
> # EOF
>
> That's worked for me for years. It's probably not very elegant and other
> list members might smite me for doing things terribly inefficiently
> (hell, I could replace the whole caboodle with one line of awk these
> days) but it does work.
>
> Again, reading those docs will help you out. MRTG is probably one of the
> best documented OSS applications available IMO. And I provide Tobi with
> a mirror site for it :)
>
> Graeme
>
>
> _______________________________________________
> Nottingham mailing list
> Nottingham at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/nottingham
>




More information about the Nottingham mailing list