[mrtg] Help with memory stats
Kelly
kelly at rgcontadores.com.br
Fri May 30 13:32:35 MEST 2003
Hello,
I´m using the script below, to get de memory stats, but my graphs are always
the same, a line.
Could anyone help?
This is my .cfg file
### Global Config Options
# for Debian
WorkDir: /var/www/mrtg
# or for NT
# WorkDir: c:\mrtgdata
### Global Defaults
# to get bits instead of bytes and graphs growing to the right
Options[_]: growright, bits
RunAsDaemon: yes
######################################################################
# System: debian
# Description: Linux debian 2.2.20-idepci #1 Sat Apr 20 12:45:19 EST 2002
i686
# Contact: Root <root at localhost> (configure /etc/snmp/snmp.local.conf)
# Location: Unknown (configure /etc/snmp/snmp.local.conf)
######################################################################
Target[mem]:'/var/www/mrtg/memory.pl'
Options[mem]: growright,noinfo,gauge
Unscaled[mem]: ymwd
MaxBytes[mem]: 268435456
YLegend[mem]:Percentual
ShortLegend[mem]:%
Legend1[mem]:Uso de memoria do sistema
LegendI[mem]:Mem. Livre
LegendO[mem]:blah
Legend2[mem]:Mem Util
Title[mem]:Uso de Memoria
PageTop[mem]:<h1>Uso de Memoria</h1>
<table>
<tr><td>Sistema:</td><td>Sistema</td></tr>
<tr><td>Responsavel:</td><td>admin</td></tr>
<tr><td>Descricao:</td><td>Uso de Memoria</td></tr>
</table>
############### End Memory
and this is the script:
#!/usr/bin/perl
# This small utility is used to collect the available memory and
# used memory. For free memory, it sums the free, cached and buffers.
# You must enable the "gauge" feature to have a proper graph
# as those numbers do not grow
#
# Colin Tinker
# g1gsw at titanic.demon.co.uk
# setup local vars
my($machine);
# Enter default macine name here
$machine = "g1gsw.ampr.org";
# This allows command args to override defaults listed above
if (scalar(@ARGV) > 1 )
{
print("USAGE: memory.pl {machine}\n");
exit(-1);
}
if ($ARGV[0] ne '' && $ARGV[0] ne '#')
{
$machine = $ARGV[0];
}
# Calculate free memory
$getfree = `cat /proc/meminfo | grep Mem:`;
$getfree =~ /^Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/;
# Each (\D+) = $1 or $2 or $3 etc
$outfree = $3;
$outbuffers = $5;
$outcached = $6;
# Total free memory
$gettotal = $outfree+$outcached+$outbuffers;
print $gettotal."\n";
# Get used memory free
$getused = `cat /proc/meminfo | grep Swap:`;
$outused = $1-$gettotal;
print $outused."\n";
# Get uptime
$getuptime = `/usr/bin/uptime`;
# Parse though getuptime and get data
$getuptime =~ /^\s+(\d{1,2}:\d{2}..)\s+up\s+(\d+)\s+(\w+),/;
#Print getuptime data for mrtg
print $2." ".$3."\n";
# Print machine name for mrtg
print $machine."\n";
--------------------------
Kelly Cristine Göedert
RG Contadores Associados
(48)3025-6424 - ramal 219
www.rgcontadores.com.br
---------------------------
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://www.ee.ethz.ch/~slist/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the mrtg
mailing list