bits of host information from Solaris, Linux, and FreeBSD. The OS
details are:
HOSTS: snorkle (sunhost), tux (linhost), beastie (bsdhost) PROMPT: host [0] Solaris INFO: Solaris 10, x86 Linux INFO: CentOS 5.4, x86 FreeBSD INFO: FreeBSD 8.1, x86
Of note, most of the following is applicable to previous OS releases,
though I've tried to note alternatives when necessary for older OS
versions. Moving on to details, for memory we must consider both swap
space and physical memory. To obtain both in Solaris:
snorkle [0] /usr/sbin/swap -l swapfile dev swaplo blocks free /dev/dsk/c1t0d0s1 32,1 8 2313352 2313352
Assuming the default 512 byte block size, to get the size in GB
(1.10 GB), use 'bc':
snorkle [0] echo "scale=2 ; (2313352 / 2) / 1048576" | /usr/bin/bc 1.10 sunhost [0] /usr/platform/`/usr/bin/uname -i`/sbin/prtdiag -v | /usr/bin/grep ^Memory Memory size: 2048 Megabytes
For some Solaris hosts, 'prtdiag' doesn't give up much or any
information, such as on my test instance which is a VM (virtual
machine) in VirtualBox. This may be the case in other VM software
as well as on some Solaris x86 hosts. When 'prtdiag' doesn't provide
anything useful, go with 'prtconf':
snorkle [0] /usr/sbin/prtconf | /usr/bin/grep ^Memory Memory size: 1024 Megabytes
In Linux:
tux [0] /bin/egrep 'MemTotal:|SwapTotal:' /proc/meminfo MemTotal: 1035140 kB SwapTotal: 1052248 kBIf you want to see what devices are providing the swap space (size is listed in KB, so divide by 1048576 to get GB):tux [0] /sbin/swapon -s Filename Type Size Used Priority /dev/sda3 partition 1052248 0 -1 tux [0] /bin/cat /proc/swaps Filename Type Size Used Priority /dev/sda3 partition 1052248 0 -1In FreeBSD:beastie [0] /usr/sbin/swapinfo Device 1K-blocks Used Avail Capacity /dev/mirror/gm0s1b 1048576 0 1048576 0%'swapinfo' reports in KB, thus for MB, divide by 1024, for GB, divide by 1048576:beastie [0] echo "scale=2; 1048576 / 1024" | /usr/bin/bc 1024.00 beastie [0] /sbin/sysctl hw.realmem hw.realmem: 1073676288'hw.realmem' is the memory available to FreeBSD reported in bytes, as opposed to 'hw.physmem' which is the total reporting physical memory. To get MB, divide by 1048576, GB, divide by 1073741824:beastie [0] echo "scale=2; 1073676288 / 1048576" | /usr/bin/bc 1023.93Still to come in the series, CPUs.