The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Quantifying Counts, Costs, and Trends Accurately via Machine Learning iBot UNIX and Linux RSS News 0 04-07-2008 06:00 AM
kernel, memory and patches information Teh Tiack Ein HP-UX 0 08-18-2005 09:48 AM
How to determine cpu&memory percentage usage per user hp-ux-user HP-UX 4 03-10-2005 07:53 AM
how can I get the system information such as cup,memory,ports etc? fresh SCO 2 09-30-2003 03:55 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-27-2008
fiori_musicali fiori_musicali is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 8
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 (permalink)  
Old 12-05-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,889
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.
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0