[Nottingham] MRTG

tim at inspiration7.co.uk tim at inspiration7.co.uk
Thu Aug 3 09:16:01 BST 2006


To be fair here I don't normally recommend using SNMP as it notoriously
insecure but .... if you are collecting data only from localhost (and you
have a decent firewall running with port 161 closed) it is far more
effective as it was designed to do exactly that job. I use "cacti" rather
than MRTG, more fun to fiddle with.

Tim

> 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