Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: MRTG graphs
PostPosted: Wed Dec 07, 2005 5:44 pm 
Offline
Junior Member

Joined: Wed May 04, 2005 9:08 pm
Posts: 24
Website: http://xcski.com/blogs/pt/
Location: Rochester NY
Now that you're producing graphs of network traffic, is there any way you could also produce them for io tokens, memory and CPU? Or do I have to do that myself?

(And if the latter, I've never set up MRTG. Is there a good tutorial somewhere?)


Top
   
 Post subject:
PostPosted: Wed Dec 07, 2005 7:24 pm 
Offline
Senior Member
User avatar

Joined: Fri Aug 15, 2003 2:15 pm
Posts: 111
Website: http://fubegra.net/
I don't have a CPU graph, but I do have graphs for network traffic, I/O token rate, I/O tokens available, and 5- and 15-minute system load average.

Caveat: I've noticed that reboots produce screwy results with my network traffic graph, which don't jibe with the graphs on the LPM.

This example will drop traffic.html, tokens.html, io_rate.html, and load_avg.html files in the WorkDir.

A cron job should run mrtg every five minutes. It will need to run at least three times before you start getting meaningful results.

/etc/mrtg.cfg:
Code:
# This file is for use with mrtg-2.5.4c

# Global configuration
WorkDir: /var/www/some/where
WriteExpires: Yes

Target[traffic]: `/usr/local/bin/traffic.pl`
Title[traffic]: Traffic Analysis for Linode VPS
PageTop[traffic]: <H1>Bandwidth Usage</H1>
Options[traffic]: logscale
MaxBytes[traffic]: 12500000

Title[tokens]: I/O Tokens for Linode VPS
Target[tokens]: `/usr/local/bin/tokens.pl`
PageTop[tokens]: <H1>I/O Tokens</H1>
Options[tokens]: gauge
MaxBytes[tokens]: 400000
YLegend[tokens]: Tokens
ShortLegend[tokens]: Tokens
LegendI[tokens]: &nbsp;Tokens:
LegendO[tokens]: &nbsp;
Legend1[tokens]: I/O Tokens Available
Legend2[tokens]: &nbsp;

Title[io_rate]: I/O Rate for Linode VPS
Target[io_rate]: `/usr/local/bin/tokenrate.pl`
PageTop[io_rate]: <H1>I/O Token Usage Rate</H1>
Options[io_rate]: logscale
MaxBytes[io_rate]: 400000
YLegend[io_rate]: Tokens/sec
ShortLegend[io_rate]: Tokens/sec
LegendI[io_rate]: &nbsp;Tokens/sec:
LegendO[io_rate]: &nbsp;
Legend1[io_rate]: I/O Token Usage Rate
Legend2[io_rate]: &nbsp;

Target[load_avg]: `/usr/local/bin/uptime.pl`
Title[load_avg]: Load Averages and Uptime
Options[load_avg]: gauge,logscale
PageTop[load_avg]: <H1>System Load Averages</H1>
YLegend[load_avg]: Load Average


The uptime.pl script:
Code:
#!/usr/bin/perl

# Retrieve 5-minute and 15-minute load averages for system
# for use by MRTG

$text = `uptime`;

($uptime,$avg5min,$avg15min) = ($text =~ m/^.*up (.*),  \d+ user.*,  load average: \S+, (\S+), (\S+)$/o);

$host = `hostname`;
# use printf here to round the averages
printf("%.1f\n%.1f\n%s\n$host\n", $avg5min, $avg15min, $uptime);


The tokens.pl script:
Code:
#!/usr/bin/perl

$line = `/usr/bin/uptime`;
($uptime) = ($line =~ m/^.*up (.*),\s+\d+\s+users*,\s+load average:.*$/o);

$host = `/bin/hostname`;

open IOSTATUS, "/proc/io_status";
$line = <IOSTATUS>;
close IOSTATUS;

($tokens) = ($line =~ m/^.* io_tokens=(\d+) .*$/o);

print "$tokens\n0\n$uptime\n$host\n";


The tokenrate.pl script:
Code:
#!/usr/bin/perl

$line = `/usr/bin/uptime`;
($uptime) = ($line =~ m/^.*up (.*),\s+\d+\s+users*,\s+load average:.*$/o);

$host = `/bin/hostname`;

open IOSTATUS, "/proc/io_status";
$line = <IOSTATUS>;
close IOSTATUS;

($count) = ($line =~ m/^io_count=(\d+) .*$/o);

print "$count\n0\n$uptime\n$host\n";


The traffic.pl script:
Code:
#!/usr/bin/perl

$line = `/usr/bin/uptime`;
($uptime) = ($line =~ m/^.*up (.*),\s+\d+\s+users*,\s+load average:.*$/o);

open IFCONFIG, "/sbin/ifconfig eth0|";
while(<IFCONFIG>) {
        ($in, $out) = (m/^.*RX bytes:(\d+).*TX bytes:(\d+).*$/o);
        last if($in);
}
close IFCONFIG;


$host = `/bin/hostname`;

print "$in\n$out\n$uptime\n$host\n";


HTH...

_________________
Bus error (passengers dumped)


Top
   
 Post subject:
PostPosted: Fri Dec 09, 2005 5:28 pm 
Offline
Junior Member

Joined: Wed Jan 26, 2005 7:20 pm
Posts: 34
I'm too busy right now (read lazy) to go check. If you haven't put this up on the wiki as a how-to, can I request you do that?


Top
   
 Post subject:
PostPosted: Thu Dec 15, 2005 2:21 pm 
Offline
Junior Member

Joined: Wed May 04, 2005 9:08 pm
Posts: 24
Website: http://xcski.com/blogs/pt/
Location: Rochester NY
Actually, I just found something better - http://munin.projects.linpro.no/. Not only does it produce better graphs than mrtg, but I can run just the client node on my linode, and do the actually building of graphs and rrdtool stuff on my home machine. Even better, the client node was available as a package in Debian Sarge, so I didn't even have to do a lot of setup on my Linode. I did make a custom plugin to monitor io_tokens, though.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: mwchase and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group