How to accurately determine memory (RAM) information


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to accurately determine memory (RAM) information
# 1  
Old 11-27-2008
How to accurately determine memory (RAM) information

I'm writing a shell script to display as much useful information on physical and virtual memory availability and usage as possible. I need a CLI tool to print these numbers for me.

The utilities that I know to give out some statistics are the following:

free
top
vmstat
sysctl

In Linux there's also /proc/meminfo

I'm however using OpenBSD which doesn't by default utilize /proc, and I want the script to apply in as many different environments as possible, relying on the most common basic utilities. The command "free" isn't installed on OpenBSD out-of-the-box, so I've excluded that. sysctl seems the best bet at the moment, aside from the fact that I have to do some wildcarding/conditionals for my script to apply to both Linux and BSD kernels (for example in Linux the first level key for some parameters is "kernel" whereas in OpenBSD it's "kern").

sysctl also displays the amount of physical memory wrong:

hw.physmem=469037056
hw.usermem=467742720

I have 512MB of RAM on that machine. What's up with that? I've also seen it reported by some users that sysctl incorrectly displays the machine to have 2147483648 bytes of physical memory, even when the actual amount by far exceeds this. I'm not sure if this was a Mac-related or a universal issue.

Where does /proc/meminfo fetch its content from? What about free, top, vmstat? Surely there's some cross-referencing somewhere?

Lower the level, the better, as long as it's reachable by scripting.
# 2  
Old 12-05-2008
vmstat is fairly universal. The info you want is on the third line, in the fourth field. Of course, it shows memory that's 'free', as in, not currently in use. The OS usually has a big cache and uses lots for buffers which can be freed. So maybe two numbers: "free" and "potentially free" or something.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Maximum Memory RAM for windows 7 32 bit

Hi, i have just installed 4 gb RAM ddr3 on OS Windows 7 32 bit. In "manage peripherals" i see this section: Memory installed (ram) : 4,00 gb (2,30gb usable) Why only 2,30 gb usable ? In Windows 7 32bit the maximum size is not 3,00gb ? see file attached, please (4 Replies)
Discussion started by: nash83
4 Replies

2. Red Hat

Query on RAM Memory

Hi Experts, I have a linux system , which triggers a alarm if RAM memory goes above 70%... When i see top command i cant find any process utilizing much of memory .. Can anyone tell me what could be the reason for high memory utilization.. Bellow is the free command o/p: free ... (14 Replies)
Discussion started by: shaliniyadav
14 Replies

3. Ubuntu

Find defective ram memory

How do I find if I have defective ram in my computer. I don't have a cd-rom, so I can't use a bootable cd. (1 Reply)
Discussion started by: locoroco
1 Replies

4. Solaris

Ram memory fails.

Hi All, Ram memory always fails,i did not find the reason...........any one can help i this.:wall: (2 Replies)
Discussion started by: Rajesh_Apple
2 Replies

5. Solaris

RAM memory display

Hi How to display RAM memory info under Sol10 ? I need info like : - how many slots is available in MoBo - how RAM is plugged into those slots - total number of RAM memory size and size divided in each slot ths for help. (2 Replies)
Discussion started by: presul
2 Replies

6. Solaris

Solaris sun4v - how do you determine physical RAM?

I have a Sun T5120, and I want to programmatically determine how much RAM it has. # uname -a SunOS myhost 5.10 Generic_141444-09 sun4v sparc SUNW,SPARC-Enterprise-T5120 The box has 64Gb; I tried prtdiag and prtconf, but they give me bogus info prtconf gives me: # prtconf |grep -i... (12 Replies)
Discussion started by: thomn8r
12 Replies

7. Shell Programming and Scripting

RAM usage Information

Hi i just wanted to know what is the code to display amount of RAM and also the percentage used? I know i can possibly use the vmstat code but what part indicates the RAM? Any help would be much appreciated. Thanks (1 Reply)
Discussion started by: warlock129
1 Replies

8. Solaris

RAM Physical Memory usage by each Process.

Hi All, I am trying to find the physical memory usage by each process/users. Can you please let me know how to get the memory usage?. Thanks, bsraj. (12 Replies)
Discussion started by: bsrajirs
12 Replies

9. UNIX for Dummies Questions & Answers

Amount of RAM (Memory)

How do i check/get the total amount of RAM, on a machine running UNIX? (4 Replies)
Discussion started by: samudimu
4 Replies
Login or Register to Ask a Question