SUMMARY: mrtg - recording swap and mem. with vmstat

From: Dirk Bergl <dbergl_at_dbtech.com.au>
Date: Thu, 05 Aug 1999 15:41:15 +0800

Hi eveyone,


Thanks to the following for responding.......

"Frank Wortner" <frank_at_bondnet.com>
alan_at_nabeth.cxo.dec.com
"Alvarez, Cynthia" <Alvare2C_at_kochind.com>
"Balamuralikrishnan" <bsriniva_at_oakland.edu>
"Thomas.Meyer" <meyert_at_dla-marbach.de>

(Sorry if I left anyone out)



The original question was....

What is the best/easiest way to collect free memory and swap for use with
mrtg.

>From the several different answers I recieved, there's a number of ways.
 It comes down to individual choice...


A)
try "vmstat -s | sed -ne 4p" for free memory,
and the same for swap space: "swapon -s | sed -ne 16p"

------------------------------------------------------------------------
--------------------------------------------
B)

If you don't mind dealing in percentages rather than total MB...

        /usr/sbin/swapon -s | awk '/Available/ { print $6 }' | sed -e 's/%)//'

If you want total physical memory use, then vmstat -P :

        vmstat -P | awk '/Physical/ { print $7 }' | sed -e 's/M//'

If you want a percentage, just recover the total physical memory from the
boot message in /var/adm/messages and do the arithmetic:

        awk 'BEGIN { MEM = 0 }
                /physical memory/ { MEM = $9 }
                END { print MEM }'

------------------------------------------------------------------------
--------------------------------------------
C)
Use TOP, a utility program, and grep the headings for the required data.


------------------------------------------------------------------------
--------------------------------------------
D)

Use Performance Manager Metrics Server as a source for MRTG
data.
pmgrd runs on port 1167 if set up and delivers a rich variety of data,
including memory and swap statistics.


------


Also, as I discovered, and as Alan pointed out, if you use vmstat with
MRTG, beware that sometimes vmstat's fields overrun, joining fields
togeather. To overcome this I used NF in the awk script, and then grabbed
the last 3 fields I was interested in via "(NR-1) (NR-2) (NR-3).

After initially using vmstat, I converted to using top for the stats,
although I'm still checking top to make sure it's stats are accurate.
pmgrd also looks like it might be worth investigating (Thanks for that
info. Thomas)



Thanks again for everyone's help.
Cheers,
Dirk.
Received on Thu Aug 05 1999 - 07:51:57 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:39 NZDT