[Xymon] hpux-meminfo.c patch

Buchan Milne bgmilne at staff.telkomsa.net
Thu Mar 3 15:50:39 CET 2011


----- henrik at hswn.dk wrote:

> Hi Jason,
> 
> On Tue, 22 Feb 2011 08:15:14 -0600, Jason Fredricksen
> <jasonajfredricksen at gmail.com> wrote:
> > This patch for hpux-meminfo.c may help due to  11iv3 page sizes
> 4096
> ,8192
> > ,16384 ,65536. 
> 
> I was sent another solution back in December which replaces the
> hpux-meminfo 
> utility with a bit of shell scripting:
> 
> FREE=`/usr/sbin/swapinfo |grep ^memory |awk {'print $4'}`
> FREEREPORT=`echo $FREE / 1024 |/usr/bin/bc`
> TOTAL=`/usr/sbin/swapinfo |grep ^memory |awk {'print $2'}`
> TOTALREPORT=`echo $TOTAL / 1024 |/usr/bin/bc`
> echo Total:$TOTALREPORT
> echo Free:$FREEREPORT

I am not sure of the features of awk on HP-UX, but on Linux, you can do all the processing with a single invocation of awk and swapinfo:

/usr/sbin/swapinfo | awk '/^memory/ {tot=$2/1024;free=$4/1024} END {printf "Total: %d\nFree: %d\n",tot,free}'

It would be useful to know if this version works on HP-UX.

Regards,
Buchan



More information about the Xymon mailing list