HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Utility for returning memory usage as both a perce...
Operating System - HP-UX
1825803
Members
2704
Online
109687
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2004 06:58 AM
01-09-2004 06:58 AM
Anyone has a small utility (shell, perl or small C source) to return something like:
server# freemem
120 pages 99 percent
Thanks!
server# freemem
120 pages 99 percent
Thanks!
Hakuna Matata.
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2004 07:16 AM
01-09-2004 07:16 AM
Re: Utility for returning memory usage as both a percent and bytes
Found this on the forums - called memdetail:
/*
* @(#)$Header: memdetail.c,v 1.1 2001/05/03 15:35:00 nsr1521 Exp $
*
* determine detailed current memory utilized and print.
*
* No warranty is expressed or implied.
* Your mileage may vary.
*
* Contact: srobertson@bcbs-ga.com
*
*/
static char ident[] = "@(#)$Revision: 1.1 $";
#define KB 1024
#include
#include
#include
main() {
struct pst_static sbuf;
struct pst_dynamic dbuf;
struct pst_vminfo vbuf;
double page_size, sys_mem;
double phys_mem, used_phys_mem, avail_mem;
double total_virtual_mem, active_virtual_mem, avail_virtual_mem;
double total_real_mem, active_real_mem, avail_real_mem;
double total_swap_dev, used_swap_dev, avail_swap_dev;
double total_swap_mem, used_swap_mem, avail_swap_mem;
/* get static information about the system */
if (pstat_getstatic(&sbuf, sizeof(sbuf), (size_t)1, 0) != -1)
{
phys_mem = sbuf.physical_memory;
page_size = sbuf.page_size;
}
else
perror("pstat_getstatic()");
/* get dynamic information about the system */
if (pstat_getdynamic(&dbuf, sizeof(dbuf), (size_t)1, 0) != -1)
{
avail_mem = dbuf.psd_free;
total_virtual_mem = dbuf.psd_vm;
active_virtual_mem = dbuf.psd_avm;
total_real_mem = dbuf.psd_rm;
active_real_mem = dbuf.psd_arm;
}
else
perror("pstat_getdynamic()");
/* get VM information about the system */
if (pstat_getvminfo(&vbuf, sizeof(vbuf), (size_t)1, 0) != -1)
{
sys_mem = vbuf.psv_sysmem;
total_swap_dev = vbuf.psv_swapspc_max;
avail_swap_dev = vbuf.psv_swapspc_cnt;
total_swap_mem = vbuf.psv_swapmem_max;
avail_swap_mem = vbuf.psv_swapmem_cnt;
}
else
perror("pstat_getvminfo()");
/* calculate used physical memory */
used_phys_mem = phys_mem - avail_mem;
/* calculate avail virtual memory */
avail_virtual_mem = total_virtual_mem - active_virtual_mem;
/* calculate avail real memory */
avail_real_mem = total_real_mem - active_real_mem;
/* calculate used swap on device */
used_swap_dev = total_swap_dev - avail_swap_dev;
/* calculate used swap on memory */
used_swap_mem = total_swap_mem - avail_swap_mem;
(void)printf("%-15s\t%6s\t%6s\t%6s\t%6s\n",
"Memory Stat","total","used","avail","%used");
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"physical",
(phys_mem * page_size) / (KB * KB),
(used_phys_mem * page_size) / (KB * KB),
(avail_mem * page_size) / (KB * KB),
used_phys_mem * 100 / phys_mem);
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"active virtual",
(total_virtual_mem * page_size) / (KB * KB),
(active_virtual_mem * page_size) / (KB * KB),
(avail_virtual_mem * page_size) / (KB * KB),
active_virtual_mem * 100 / total_virtual_mem);
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"active real",
(total_real_mem * page_size) / (KB * KB),
(active_real_mem * page_size) / (KB * KB),
(avail_real_mem * page_size) / (KB * KB),
active_real_mem * 100 / total_real_mem);
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"memory swap",
(total_swap_mem * page_size) / (KB * KB),
(used_swap_mem * page_size) / (KB * KB),
(avail_swap_mem * page_size) / (KB * KB),
used_swap_mem * 100 / total_swap_mem);
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"device swap",
(total_swap_dev * page_size) / (KB * KB),
(used_swap_dev * page_size) / (KB * KB),
(avail_swap_dev * page_size) / (KB * KB),
used_swap_dev * 100 / total_swap_dev);
return;
}
Looks like:
# memdetail
Memory Stat total used avail %used
physical 10080.0 10019.6 60.4 99%
active virtual 13073.8 5964.9 7109.0 46%
active real 7156.5 2706.1 4450.4 38%
memory swap 7697.2 1914.8 5782.4 25%
device swap 26528.0 12792.2 13735.8 48%
Rgds...Geoff
/*
* @(#)$Header: memdetail.c,v 1.1 2001/05/03 15:35:00 nsr1521 Exp $
*
* determine detailed current memory utilized and print.
*
* No warranty is expressed or implied.
* Your mileage may vary.
*
* Contact: srobertson@bcbs-ga.com
*
*/
static char ident[] = "@(#)$Revision: 1.1 $";
#define KB 1024
#include
#include
#include
main() {
struct pst_static sbuf;
struct pst_dynamic dbuf;
struct pst_vminfo vbuf;
double page_size, sys_mem;
double phys_mem, used_phys_mem, avail_mem;
double total_virtual_mem, active_virtual_mem, avail_virtual_mem;
double total_real_mem, active_real_mem, avail_real_mem;
double total_swap_dev, used_swap_dev, avail_swap_dev;
double total_swap_mem, used_swap_mem, avail_swap_mem;
/* get static information about the system */
if (pstat_getstatic(&sbuf, sizeof(sbuf), (size_t)1, 0) != -1)
{
phys_mem = sbuf.physical_memory;
page_size = sbuf.page_size;
}
else
perror("pstat_getstatic()");
/* get dynamic information about the system */
if (pstat_getdynamic(&dbuf, sizeof(dbuf), (size_t)1, 0) != -1)
{
avail_mem = dbuf.psd_free;
total_virtual_mem = dbuf.psd_vm;
active_virtual_mem = dbuf.psd_avm;
total_real_mem = dbuf.psd_rm;
active_real_mem = dbuf.psd_arm;
}
else
perror("pstat_getdynamic()");
/* get VM information about the system */
if (pstat_getvminfo(&vbuf, sizeof(vbuf), (size_t)1, 0) != -1)
{
sys_mem = vbuf.psv_sysmem;
total_swap_dev = vbuf.psv_swapspc_max;
avail_swap_dev = vbuf.psv_swapspc_cnt;
total_swap_mem = vbuf.psv_swapmem_max;
avail_swap_mem = vbuf.psv_swapmem_cnt;
}
else
perror("pstat_getvminfo()");
/* calculate used physical memory */
used_phys_mem = phys_mem - avail_mem;
/* calculate avail virtual memory */
avail_virtual_mem = total_virtual_mem - active_virtual_mem;
/* calculate avail real memory */
avail_real_mem = total_real_mem - active_real_mem;
/* calculate used swap on device */
used_swap_dev = total_swap_dev - avail_swap_dev;
/* calculate used swap on memory */
used_swap_mem = total_swap_mem - avail_swap_mem;
(void)printf("%-15s\t%6s\t%6s\t%6s\t%6s\n",
"Memory Stat","total","used","avail","%used");
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"physical",
(phys_mem * page_size) / (KB * KB),
(used_phys_mem * page_size) / (KB * KB),
(avail_mem * page_size) / (KB * KB),
used_phys_mem * 100 / phys_mem);
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"active virtual",
(total_virtual_mem * page_size) / (KB * KB),
(active_virtual_mem * page_size) / (KB * KB),
(avail_virtual_mem * page_size) / (KB * KB),
active_virtual_mem * 100 / total_virtual_mem);
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"active real",
(total_real_mem * page_size) / (KB * KB),
(active_real_mem * page_size) / (KB * KB),
(avail_real_mem * page_size) / (KB * KB),
active_real_mem * 100 / total_real_mem);
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"memory swap",
(total_swap_mem * page_size) / (KB * KB),
(used_swap_mem * page_size) / (KB * KB),
(avail_swap_mem * page_size) / (KB * KB),
used_swap_mem * 100 / total_swap_mem);
(void)printf("%-15s\t%6.1f\t%6.1f\t%6.1f\t%5.0f%%\n",
"device swap",
(total_swap_dev * page_size) / (KB * KB),
(used_swap_dev * page_size) / (KB * KB),
(avail_swap_dev * page_size) / (KB * KB),
used_swap_dev * 100 / total_swap_dev);
return;
}
Looks like:
# memdetail
Memory Stat total used avail %used
physical 10080.0 10019.6 60.4 99%
active virtual 13073.8 5964.9 7109.0 46%
active real 7156.5 2706.1 4450.4 38%
memory swap 7697.2 1914.8 5782.4 25%
device swap 26528.0 12792.2 13735.8 48%
Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2004 07:17 AM
01-09-2004 07:17 AM
Solution
Well that post looks ugly - here it is as an attachment...
Rgds...Geoff
Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP