[ale] Memory "free" vs what is truly available

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed May 16 14:30:20 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed 2007-05-16 14:14:33 -0400, cfowler wrote:

> I'm trying to write a perl program that will monitor the output of
> the free command and notify me when there is an issue with memory usage

you might instead be interested in something like munin [0], which is
capable of doing what you ask, monitoring other resources as well, and
of generating pretty graphs to boot [1].

The archiecture is simple and clean, though it's not quite perfect.  A
small process runs as root on the host being monitored.  It is capable
of checking whatever you've configured it to check (dropping privs
where possible, i think).  It accepts TCP requests for information,
which can be limited by IP address.

a simple, non-privileged cron job polls every server (initially, only
localhost), collects data, logs it, and generates graphs and static
web pages from the info.

You can use your webserver of choice to export the information
publicly/restrict access to it/etc.

On debian, at least, initial setup is very simple:

 apt-get install munin munin-node

munin is the gatherer.  munin-node is the daemon.  munin-node needs to
be on every monitored machine.  munin only needs to be on one of them.

You can read more about how to configure Munin to contact you when
things change, probably starting on the Munin wiki [1].

> I should be aware of
>
> Output:
>              total       used       free     shared    buffers
> cached
> Mem:       1026776    1018744       8032          0      89988
> 450292
> -/+ buffers/cache:     478464     548312
> Swap:      1044208          0    1044208
>
> When should I be concerned.  Right now it appears as if almost all
> memory is used.  There is 89m in buffers and 450m in cached Would that
> memory become available if needed.  
>
> I do not what to compare the columns total and used and notify then they
> are almost equal.  That would not show a real problem.

If you want to write it yourself, you might get better
machine-parseable data by reading the contents of /proc/meminfo, or
the output of "vmstat X" where X is the number of seconds you want
between polls.

hth,

   --dkg

[0] http://munin.projects.linpro.no/
[1] http://www.askbjoernhansen.com/2007/04/30/munin.html
[2] http://munin.projects.linpro.no/wiki/HowToContact
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>

iD8DBQFGS02uiXTlFKVLY2URAoNVAKCkaRNs4xKJ7+1QpuVtwrNFtNNAUwCfcocV
Tlm1fG3xqnj1r7bUG7BmNlA=
=siS3
-----END PGP SIGNATURE-----



More information about the Ale mailing list