From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96079067215811.tru64-unix-managers.marc@archive.invalid> From: Dirk Bergl Date: Thu, 05 Aug 1999 07:41:15 +0000 To: tru64-unix-managers Subject: SUMMARY: mrtg - recording swap and mem. with vmstat X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96079067215811 Hi eveyone, Thanks to the following for responding....... "Frank Wortner" alan@nabeth.cxo.dec.com "Alvarez, Cynthia" "Balamuralikrishnan" "Thomas.Meyer" (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.