Total Memory/Swap Memory

I need to put a program together to determine the total, available memory and total and available swap on unix machines. I have been searching for weeks and I seem to run into dead ends. Every unix platform I look at has a different way to determine memory info.

Any sugggestions or new directions would be greatly appreciated.

THANKS!!!!!

I might be wrong but I don't think so. (Brand new user, 1st post is a generic problem question)

No one here will write your script for you, but we may offer advices if this is an "honest" question and/or not a homework question.

When you post you must tell us a little about your UNIX Version.

What is the OS version. shells used etc...

Many systems have commands like swapinfo, meminfo. You can also look in /var/adm/messages on some boxes. Some systems have a "dmesg" command that will show you some stuff.

You can grep info out of the kernel config with the "strings" command.

Get a few good books like UNIX in a Nutshell by O'Reilly.
Here is a link to another newbie response that I posted.

If this is not homework, I apologize for my sharp comment. Read the FAQs on the homepage to understand the rules of this forum

Here's the deal: I have already put together a script that runs on a linux environment 32-bit machine, but it does not work on an IRIX or SUN or Tru64, so I was wondering if there was something universal for all unix machines. I am quite familar with "vmstat", "swap -l", "swapon -s", but I need an executable and not command line code. As to what OS and shells used, I need to be able to cover them all. This function needs to cover a wide range of machines.

I also already have the "Unix in a Nutshell," by O'Reilly. I use it faithfully.

I will check /var/adm/messages..."dmesg." Haven't tried that yet, its worth a shot.

If you are looking for generic commands of this type, there are none. All of the major brands of UNIX are "proprietary" that means that they have altered UNIX just enough to make "their own". And this is the case with swap and memory.

Tru64 has a command "meminfo". HP does not. HP has a command "swapinfo" and I am sure that Tru64 doesn't. You will need to look in the "bin directories"

/bin
/sbin
/usr/bin
/usr/sbin
/usr/local/bin

Please see my response in this post.

As a result, a few commands are unique to each flavor of UNIX.

Most flavors of unix are quite similar, all major brands have the generic backup tools like tar, cpio & dd.

You will also find that there are some filesystem differences as well as device configuration and naming conventions.

Thanks for the help. That is what I needed to hear. I am going to look into the bin directories and see what I find. I just might have to resort to higher help for this one.