hpux-meminfo.c patch
list Jason Fredricksen
This patch for hpux-meminfo.c may help due to 11iv3 page sizes 4096 ,8192
,16384 ,65536. from: man 5 base_pagesize
running xymon 4.2.3 l
diff then the modified source:
15d14
< #include <unistd.h>
24,25d22
< unsigned long pgsizecnf;
< int d=0;
31,48c28,29
< pgsizecnf = sysconf(_SC_PAGE_SIZE);
< switch(pgsizecnf) {
< case 4096:
< d = 256;
< break;
< case 8192:
< d = 128;
< break;
< case 16384:
< d = 64;
< break;
< case 65536:
< d = 16;
< break;
< default:
< exit (1);
< }
< printf("Total:%ld\n", sbuf.physical_memory/d);
---
printf("Total:%ld\n", sbuf.physical_memory/256);50a32
/*----------------------------------------------------------------------------*/
/* Hobbit memory information tool for HP-UX.
*/
/* This tool retrieves information about the total and free RAM.
*/
/*
*/
/* Copyright (C) 2005-2006 Henrik Storner <user-ce4a2c883f75@xymon.invalid>
*/
/*
*/
/* This program is released under the GNU General Public License (GPL),
*/
/* version 2. See the file "COPYING" for details.
*/
/*
*/
/*----------------------------------------------------------------------------*/
static char rcsid[] = "$Id: hpux-meminfo.c,v 1.4 2006-05-03 21:12:33 henrik
Exp $";
#include <sys/pstat.h>
#include <unistd.h>
#include <stdio.h>
main(int argc, char *argv[])
{
struct pst_static sbuf;
struct pst_dynamic dbuf;
unsigned long pgsizekb;
unsigned long kpages;
unsigned long pgsizecnf;
int d=0;
pstat_getstatic(&sbuf, sizeof(sbuf), 1, 0);
pstat_getdynamic(&dbuf, sizeof(dbuf), 1, 0);
pgsizekb = sbuf.page_size / 1024;
kpages = dbuf.psd_free / 1024;
pgsizecnf = sysconf(_SC_PAGE_SIZE);
switch(pgsizecnf) {
case 4096:
d = 256;
break;
case 8192:
d = 128;
break;
case 16384:
d = 64;
break;
case 65536:
d = 16;
break;
default:
exit (1);
}
printf("Total:%ld\n", sbuf.physical_memory/d);
printf("Free:%lu\n", pgsizekb*kpages);
}
Jason A.J. Fredricksen
list Henrik Størner
Hi Jason, On Tue, 22 Feb 2011 08:15:14 -0600, Jason Fredricksen
▸
<user-124cbfd9fa0b@xymon.invalid> 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
(the original message is
http://lists.xymon.com/archive/2010-December/030100.html
from Earl Flack)
Can you confirm if this shell script works OK for you ?
I would much rather use standard shell-tools than a custom
C program that I have difficulty supporting.
Also, anyone with access to older HP/UX versions ? I would
be most interested to hear if Earl's shell version to get
the memory info works on other HP/UX versions as well.
Regards,
Henrik
list Buchan Milne
▸
----- user-ce4a2c883f75@xymon.invalid wrote:
Hi Jason, On Tue, 22 Feb 2011 08:15:14 -0600, Jason Fredricksen <user-124cbfd9fa0b@xymon.invalid> wrote:This patch for hpux-meminfo.c may help due to 11iv3 page sizes4096 ,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
list Doug Williams
# uname -r
B.11.23
# /usr/sbin/swapinfo | awk '/^memory/ {tot=$2/1024;free=$4/1024} END
{printf "Total: %d\nFree: %d\n",tot,free}'
Total: 49122
Free: 42732
# uname -r
B.11.31
# /usr/sbin/swapinfo | awk '/^memory/ {tot=$2/1024;free=$4/1024} END
{printf "Total: %d\nFree: %d\n",tot,free}'
Total: 23354
Free: 9986
-----Original Message-----
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf
Of Buchan Milne
Sent: Thursday, March 03, 2011 9:51 AM
To: user-ce4a2c883f75@xymon.invalid
Cc: xymon at xymon.com
Subject: Re: [Xymon] hpux-meminfo.c patch
▸
----- user-ce4a2c883f75@xymon.invalid wrote:
Hi Jason, On Tue, 22 Feb 2011 08:15:14 -0600, Jason Fredricksen <user-124cbfd9fa0b@xymon.invalid> wrote:This patch for hpux-meminfo.c may help due to 11iv3 page sizes4096 ,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
list Doug Williams
# ./mytest.sh Total:49122 Free:42732 # cat mytest.sh #!/usr/bin/sh
▸
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
# uname -r
B.11.23
# swapinfo -ta
Kb Kb Kb PCT START/ Kb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1048576 0 1038336 0% 0 - 1
/dev/vg00/lvol2
dev 83853312 0 83852288 0% 0 - 0
/dev/vgev08_swap_r0_1/lvswap
reserve - 3775900 -3775900
memory 50301020 6543124 43757896 13%
total 135202908 10319024 124872620 8% - 0 -
# swapinfo -tam
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1024 0 1014 0% 0 - 1
/dev/vg00/lvol2
dev 81888 0 81887 0% 0 - 0
/dev/vgev08_swap_r0_1/lvswap
reserve - 3686 -3686
memory 49122 6390 42732 13%
total 132034 10076 121947 8% - 0 -
-----Original Message-----
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf
Of user-ce4a2c883f75@xymon.invalid
Sent: Thursday, March 03, 2011 9:00 AM
To: Jason Fredricksen
▸
Cc: xymon at xymon.com
Subject: Re: [Xymon] hpux-meminfo.c patch
Hi Jason,
On Tue, 22 Feb 2011 08:15:14 -0600, Jason Fredricksen
<user-124cbfd9fa0b@xymon.invalid> 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
(the original message is
http://lists.xymon.com/archive/2010-December/030100.html
from Earl Flack)
Can you confirm if this shell script works OK for you ?
I would much rather use standard shell-tools than a custom
C program that I have difficulty supporting.
Also, anyone with access to older HP/UX versions ? I would
be most interested to hear if Earl's shell version to get
the memory info works on other HP/UX versions as well.
Regards,
Henrik
list Buchan Milne
Do the numbers look correct (~ 50GB memory, 42GB free, and 24GB memory, 10GB free)?
The following shorter form should also work:
/usr/sbin/swapinfo | awk '/^memory/ {printf "Total: %d\nFree: %d\n",$2/1024,$4/1024}'
Regards,
Buchan
▸
----- "Doug Williams (Consultant-RIC)" <user-2bde7ec54a85@xymon.invalid> wrote:
# uname -r B.11.23 # /usr/sbin/swapinfo | awk '/^memory/ {tot=$2/1024;free=$4/1024} END {printf "Total: %d\nFree: %d\n",tot,free}' Total: 49122 Free: 42732 # uname -r B.11.31 # /usr/sbin/swapinfo | awk '/^memory/ {tot=$2/1024;free=$4/1024} END {printf "Total: %d\nFree: %d\n",tot,free}' Total: 23354 Free: 9986 -----Original Message----- From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Buchan Milne Sent: Thursday, March 03, 2011 9:51 AM To: user-ce4a2c883f75@xymon.invalid Cc: xymon at xymon.com Subject: Re: [Xymon] hpux-meminfo.c patch ----- user-ce4a2c883f75@xymon.invalid wrote:Hi Jason, On Tue, 22 Feb 2011 08:15:14 -0600, Jason Fredricksen <user-124cbfd9fa0b@xymon.invalid> wrote:This patch for hpux-meminfo.c may help due to 11iv3 page sizes4096 ,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:$FREEREPORTI 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
list Doug Williams
yes, sorry:
▸
# /usr/sbin/swapinfo | awk '/^memory/ {tot=$2/1024;free=$4/1024} END {printf "Total: %d\nFree: %d\n",tot,free}'
Total: 49122
Free: 42732
# swapinfo -tam
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1024 0 1014 0% 0 - 1 /dev/vg00/lvol2
dev 81888 0 81887 0% 0 - 0 /dev/vgev08_swap_r0_1/lvswap
reserve - 3714 -3714
memory 49122 6390 42732 13%
total 132034 10104 121919 8% - 0 -
# uname -r
B.11.23
▸
-----Original Message-----
From: Buchan Milne [mailto:user-9b139aff4dec@xymon.invalid]
Sent: Thursday, March 03, 2011 10:14 AM
To: Williams, Doug (Consultant-RIC)
Cc: xymon at xymon.com; user-ce4a2c883f75@xymon.invalid
Subject: Re: [Xymon] hpux-meminfo.c patch
Do the numbers look correct (~ 50GB memory, 42GB free, and 24GB memory, 10GB free)?
The following shorter form should also work:
/usr/sbin/swapinfo | awk '/^memory/ {printf "Total: %d\nFree: %d\n",$2/1024,$4/1024}'
Regards,
Buchan
----- "Doug Williams (Consultant-RIC)" <user-2bde7ec54a85@xymon.invalid> wrote:
# uname -r B.11.23 # /usr/sbin/swapinfo | awk '/^memory/ {tot=$2/1024;free=$4/1024} END {printf "Total: %d\nFree: %d\n",tot,free}' Total: 49122 Free: 42732 # uname -r B.11.31 # /usr/sbin/swapinfo | awk '/^memory/ {tot=$2/1024;free=$4/1024} END {printf "Total: %d\nFree: %d\n",tot,free}' Total: 23354 Free: 9986 -----Original Message----- From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Buchan Milne Sent: Thursday, March 03, 2011 9:51 AM To: user-ce4a2c883f75@xymon.invalid Cc: xymon at xymon.com Subject: Re: [Xymon] hpux-meminfo.c patch ----- user-ce4a2c883f75@xymon.invalid wrote:Hi Jason, On Tue, 22 Feb 2011 08:15:14 -0600, Jason Fredricksen <user-124cbfd9fa0b@xymon.invalid> wrote:This patch for hpux-meminfo.c may help due to 11iv3 page sizes4096 ,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:$FREEREPORTI 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
list Earl Flack
So the bad news is that swapinfo (on HP-UX 11iv3 ia64 at least) does not take into account shared memory space memory utilization. We orginally tested the script on some idle servers with no databases running at the time and it looked good there. After starting up a bunch of oracle databases the output did not look right. Further investigation showed that swapinfo was reporting an incomplete picture of memory, we compared with kmeminfo and glance. Back to the drawing board for scripts. ~~Earl -----Original Message----- From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Williams, Doug (Consultant-RIC) Sent: Thursday, March 03, 2011 7:09 AM To: user-ce4a2c883f75@xymon.invalid; Jason Fredricksen
▸
Cc: xymon at xymon.com
Subject: Re: [Xymon] hpux-meminfo.c patch
# ./mytest.sh
Total:49122
Free:42732
# cat mytest.sh
#!/usr/bin/sh
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
# uname -r
B.11.23
# swapinfo -ta
Kb Kb Kb PCT START/ Kb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1048576 0 1038336 0% 0 - 1
/dev/vg00/lvol2
dev 83853312 0 83852288 0% 0 - 0
/dev/vgev08_swap_r0_1/lvswap
reserve - 3775900 -3775900
memory 50301020 6543124 43757896 13%
total 135202908 10319024 124872620 8% - 0 -
# swapinfo -tam
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1024 0 1014 0% 0 - 1
/dev/vg00/lvol2
dev 81888 0 81887 0% 0 - 0
/dev/vgev08_swap_r0_1/lvswap
reserve - 3686 -3686
memory 49122 6390 42732 13%
total 132034 10076 121947 8% - 0 -
-----Original Message-----
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf
Of user-ce4a2c883f75@xymon.invalid
Sent: Thursday, March 03, 2011 9:00 AM
To: Jason Fredricksen
Cc: xymon at xymon.com
Subject: Re: [Xymon] hpux-meminfo.c patch
Hi Jason,
On Tue, 22 Feb 2011 08:15:14 -0600, Jason Fredricksen
<user-124cbfd9fa0b@xymon.invalid> 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
(the original message is
http://lists.xymon.com/archive/2010-December/030100.html
from Earl Flack)
Can you confirm if this shell script works OK for you ?
I would much rather use standard shell-tools than a custom C program
that I have difficulty supporting.
Also, anyone with access to older HP/UX versions ? I would be most
interested to hear if Earl's shell version to get the memory info works
on other HP/UX versions as well.
Regards,
Henrik
***********************************************************
NOTICE:
This e-mail, including attachments, contains information
that may be confidential, protected by the attorney/client
or other privileges, or exempt from disclosure under
applicable law. Further, this e-mail may contain
information that is proprietary and/or constitutes a trade
secret. This e-mail, including attachments, constitutes
non-public information intended to be conveyed only to the
designated recipient of this communication, please be
advised that any disclosure, dissemination, distribution,
copying, or other use of this communication or any attached
document is strictly prohibited. If you have received this
communication in error, please notify the sender
immediately by reply e-mail and promptly destroy all
electronic and printed copies of this communication and
attached documents.
***********************************************************
list Lynn Osburn
Here are some ideas that might be fruitful. # dmesg | grep Physical (works on all HP-UX from 11.00 onwards) # print_manifest | grep -i memory (I'd use this as a last resort, as the manifest is created at factory and mightn't include field upgrades) # machinfo | egrep "^Memory" If you are on a cell based server, you can use the /usr/sbin/parstatus command to get detailed information about your overall memory configuration by cell board, partition, etc.
▸
-----Original Message-----
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Flack, Earl
Sent: Saturday, March 05, 2011 6:54 PM
To: Williams, Doug (Consultant-RIC); user-ce4a2c883f75@xymon.invalid; Jason Fredricksen
Cc: xymon at xymon.com
Subject: Re: [Xymon] hpux-meminfo.c patch
So the bad news is that swapinfo (on HP-UX 11iv3 ia64 at least) does not
take into account shared memory space memory utilization.
We orginally tested the script on some idle servers with no databases
running at the time and it looked good there. After starting up a bunch
of oracle databases the output did not look right. Further investigation
showed that swapinfo was reporting an incomplete picture of memory, we
compared with kmeminfo and glance. Back to the drawing board for
scripts.
~~Earl
list Earl Flack
Those work for physical memory in many cases but we are looking for a command to determine how much memory is being consumed.
▸
-----Original Message-----
From: Lynn Osburn [mailto:user-fd907411ed25@xymon.invalid]
Sent: Sunday, March 06, 2011 8:36 AM
To: Flack, Earl; Williams, Doug (Consultant-RIC); user-ce4a2c883f75@xymon.invalid; Jason
Fredricksen
Cc: xymon at xymon.com
Subject: RE: [Xymon] hpux-meminfo.c patch
Here are some ideas that might be fruitful.
# dmesg | grep Physical (works on all HP-UX from 11.00 onwards)
# print_manifest | grep -i memory (I'd use this as a last resort, as
the manifest is created at factory and mightn't include field upgrades)
# machinfo | egrep "^Memory"
If you are on a cell based server, you can use the /usr/sbin/parstatus
command to get detailed information about your overall memory
configuration by cell board, partition, etc.
-----Original Message-----
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf
Of Flack, Earl
Sent: Saturday, March 05, 2011 6:54 PM
To: Williams, Doug (Consultant-RIC); user-ce4a2c883f75@xymon.invalid; Jason Fredricksen
Cc: xymon at xymon.com
Subject: Re: [Xymon] hpux-meminfo.c patch
So the bad news is that swapinfo (on HP-UX 11iv3 ia64 at least) does not
take into account shared memory space memory utilization.
We orginally tested the script on some idle servers with no databases
running at the time and it looked good there. After starting up a bunch
of oracle databases the output did not look right. Further investigation
showed that swapinfo was reporting an incomplete picture of memory, we
compared with kmeminfo and glance. Back to the drawing board for
scripts.
~~Earl
***********************************************************
NOTICE:
This e-mail, including attachments, contains information
that may be confidential, protected by the attorney/client
or other privileges, or exempt from disclosure under
applicable law. Further, this e-mail may contain
information that is proprietary and/or constitutes a trade
secret. This e-mail, including attachments, constitutes
non-public information intended to be conveyed only to the
designated recipient of this communication, please be
advised that any disclosure, dissemination, distribution,
copying, or other use of this communication or any attached
document is strictly prohibited. If you have received this
communication in error, please notify the sender
immediately by reply e-mail and promptly destroy all
electronic and printed copies of this communication and
attached documents.
***********************************************************
list innate.ideas
The previous shell script I uploaded works for older HP-UX 11.11 versions.