[mrtg] Re: free &used memory are 0?

Takumi Yamane yamtak at b-session.com
Fri Oct 29 17:42:53 MEST 2004


On Fri, 29 Oct 2004 10:15:41 +0200, Marco Ledebur wrote 
in <4181FC2D.4020001 at desy.de>:
> 
> I use MRTG-2.10.15 to monitoring the CPU trouble, I/O trouble and 
> free & used memory of my linux machine.
...
> Here the perl script I use: memory.pl

I wonder if your script really works :O
Would you tell me what kind of 'linux' you are running?


Here is what you need:
#!/usr/bin/perl -w

use strict;

my $mem_total = 0;
my $mem_free = 0;

open(MEMINFO, '<', "/proc/meminfo");
while (<MEMINFO>) {
        $mem_total = $1 if (/^MemTotal:\s+(\d+)/o);
        $mem_free = $1 if (/^MemFree:\s+(\d+)/o);
}
close(MEMINFO);

printf("%d\n%d\nMemory usage\n",
        ($mem_total - $mem_free) << 10,
        $mem_free << 10);

# EOF

I believe it works on any Linux 2.x kernel.


Aside from that, IMHO, monitoring 'used & free' memory is almost 
meaningless on Linux.
I think you should monitor swap usage too.

Regards,
Takumi Yamane <yamtak at b-session.com>

--
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