- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Want to Get % used and Total Memory in HP-UX
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
08-11-2011 11:08 PM
08-11-2011 11:08 PM
Hi Guys,
I am new to HP-UX and I am stuck in a problem here. I want to get total memory and % used Memory from HP-UX. After going through commands I can only get total Memory and free Memory from System, There are two commands One is providing total memory other is providing free Memory. I need to concate these ouput as well as want to generate % used memory using these output. Please note that I can't create scripts. I just need to use one line command and output should also be in one line.
to get Total Memory I am using:
machinfo | awk '/Memory/ {print $2};'
Its output looks like this>> 32665
to get Free Memory I am using:top -d 1 | grep Memory | awk 'gsub(/K/,"")'| awk '{print $8/1024}'
Its output looks like this>> 22847.8
When I use && operator between these two commands:
top -d 1 | grep Memory | awk 'gsub(/K/,"")'| awk '{print $8/1024}' && machinfo | awk '/Memory/ {print $2};'
I get output like this: Two Different Lines.
22847.7
32665
Now As I have these values. I need to
1. generate % used Memory like ((32665-22847.7)/32665)*100
2. show all these ouput in one line, Like this
3266530%
Looking forward for your response & suggestions.
Kaleem Ullah
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2011 02:34 AM
08-12-2011 02:34 AM
Solution>Please note that I can't create scripts. I just need to use one line command
Any particular reason why?
top -n 1 -d 1 -f top.$$; awk -v total=$(machinfo | awk '/Memory/ {print $2}') \
'/Memory/ {gsub(/K/,"") ; print total, (total - $8/1024) * 100/ total "%"}' top.$$ ; rm top.$$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2011 03:00 AM
08-12-2011 03:00 AM
Re: Want to Get % used and Total Memory in HP-UX
Thanks Dennis,
Actually right Now I am working with HP SiteScope Memory Monitor. Currently Memory Monitor for HP-UX is not showing Physical Memory. So I have to create a set of commands that can easily be run on each HP-UX machine & we don't need to deploy scripts on them.
Thanks Alot for your solution. Problem reolved
Kaleem Ullah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2011 03:45 AM
08-12-2011 03:45 AM
Re: Want to Get % used and Total Memory in HP-UX
>Thanks A lot for your solution. Problem resolved
If you are happy with your answers, please assign kudos.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2011 06:08 AM
08-12-2011 06:08 AM
Re: Want to Get % used and Total Memory in HP-UX
Kaleem Ullah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2011 10:00 AM
08-13-2011 10:00 AM
Re: Want to Get % used and Total Memory in HP-UX
When I am running the above command in HP-UX 11.23 version I am getting the following output.
$ top -n 1 -d 1 -f top.$$; awk -v total=$(machinfo | awk '/Memory/ {print $2}') \ > '/Memory/ {gsub(/K/,"") ; print total, (total - $8/1024) * 100/ total "%"}' top.$$ ; rm top.$$ = awk: Cannot divide by zero. The input line number is 13. The file is top.8530. The source line number is 1. $
Did I miss anything ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2011 10:18 AM
08-13-2011 10:18 AM
Re: Want to Get % used and Total Memory in HP-UX
@Arunabha Banerjee wrote:When I am running the above command in HP-UX 11.23 version I am getting the following output.
$ top -n 1 -d 1 -f top.$$; awk -v total=$(machinfo | awk '/Memory/ {print $2}') \ > '/Memory/ {gsub(/K/,"") ; print total, (total - $8/1024) * 100/ total "%"}' top.$$ ; rm top.$$ = awk: Cannot divide by zero. The input line number is 13. The file is top.8530. The source line number is 1. $Did I miss anything ?
If you are running 11.23 and your server isn't an Itanium one, then 'machinfo' isn't available to return anything. Hence, the 'total' variable will be interpreted as zero and dividing by zero is a fault.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2011 04:49 PM - edited 08-13-2011 04:51 PM
08-13-2011 04:49 PM - edited 08-13-2011 04:51 PM
Re: Want to Get % used and Total Memory in HP-UX
>When I am running the above command in HP-UX 11.23
Yes, I developed it on 11.23 and noticed the machinfo output difference. Change to:
awk '/Memory/ {print $3}') ...
I suppose you could also do: (I think it was a ":".)
awk '/Memory/ {if ($2 == ":") print $3; else print $2}') ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2011 07:29 AM
08-14-2011 07:29 AM
Re: Want to Get % used and Total Memory in HP-UX
Hi James
I am running the script on HP-UX 11.23 running on Itanium platform only.
$ uname -r; model B.11.23 ia64 hp server rx6600 $
Hi Dennis,
After modifying the script as you suggested I ran again. Please fine below output
$ top -n 1 -d 1 -f top.$$; awk -v total=$(machinfo | awk '/Memory/ {print $3}') \ > '/Memory/ {gsub(/K/,"") ; print total, (total - $8/1024) * 100/ total "%"}' top.$$ ; rm top.$$ 4066 95.1615% $
The total memory output is okey (4066) but %/used output is not correct (95.1615%).
Please find below top output.
System: server Sun Aug 14 22:23:55 2011 Load averages: 0.00, 0.00, 0.00 105 processes: 81 sleeping, 24 running Cpu states: CPU LOAD USER NICE SYS IDLE BLOCK SWAIT INTR SSYS 0 0.00 0.2% 0.0% 0.2% 99.6% 0.0% 0.0% 0.0% 0.0% 1 0.00 0.0% 0.0% 0.0% 100.0% 0.0% 0.0% 0.0% 0.0% 2 0.00 0.4% 0.0% 0.6% 99.0% 0.0% 0.0% 0.0% 0.0% 3 0.00 0.0% 0.0% 0.0% 100.0% 0.0% 0.0% 0.0% 0.0% --- ---- ----- ----- ----- ----- ----- ----- ----- ----- avg 0.00 0.2% 0.0% 0.2% 99.6% 0.0% 0.0% 0.0% 0.0% Memory: 373332K (290288K) real, 547536K (437264K) virtual, 200184K free Page# 1/105
swapinfo output:
$ /usr/sbin/swapinfo -atm Mb Mb Mb PCT START/ Mb TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME dev 8192 0 8192 0% 0 - 1 /dev/vg00/lvol2 reserve - 413 -413 memory 4067 1648 2419 41% total 12259 2061 10198 17% - 0 - $
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2011 02:32 PM
08-14-2011 02:32 PM
Re: Want to Get % used and Total Memory in HP-UX
>%/used output is not correct (95.1615%).
Which do you trust more, top or swapinfo?
(I never use the summary values on top because I don't trust them. Only the values for each process.)
Note: swapinfo doesn't measure memory, only pseudo swap.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2011 11:10 AM
08-15-2011 11:10 AM
Re: Want to Get % used and Total Memory in HP-UX
Hi Dennis,
Thanks for the explanation now everything is clear to me.