-1

May I know how to calculate total memory utilization and percent of a Solaris 11.3 machine?

Am I wrong in below calculation? or any other way?

memfree=$(vmstat 1 2 | awk '{print $5}' | tail -1) memtotal=$(vmstat 1 2 | awk '{print $4}' | tail -1) memused=$((memtotal-memfree)) mempercent=$((memused * 100 / memtotal)) 

OS version is: SunOS 5.11 11.3 sun4v sparc


For reference, the vmstat(8) output of vmstat 1 2 on a freshly installed Solaris 11.4 VM looks like this:

root@solaris:~# vmstat 1 2 kthr memory page disk faults cpu r b w swap free re mf pi po fr de sr cd -- -- -- in sy cs us sy id 0 0 0 4672456 2127260 342 1628 0 0 0 0 0 48 0 0 0 566 10129 2466 11 13 76 0 0 0 4753212 830276 5 141 0 0 0 0 0 0 0 0 0 527 1205 469 2 5 93 
5
  • 1
    Does that calculation not give you the output you expect? Does it produce error messages? The more information you provide in your question the better chance we'll be able to help you. Commented Dec 5, 2020 at 0:05
  • For us that don't regularly use Solaris: What is the output of vmstat 1 2? Add that as reference info to your question please (not in comments). Commented Dec 18, 2020 at 7:13
  • 1
    @Kusalananda OP doesn't like to post that, do know why, even asked to replace real data with dummy data but keep the formatting but still no response to that too. Commented Dec 18, 2020 at 11:17
  • @αғsнιη OK, I'll set up a Solaris VM and test later... Commented Dec 18, 2020 at 11:21
  • As far as I can see, you can not say that the amount of swap space is the same as the total amount of memory in the machine. Commented Dec 18, 2020 at 12:10

1 Answer 1

0

Solaris provides a mdb dcmd for this:

root@solaris:~# mdb -k Loading modules: [ unix genunix specfs dtrace mac cpu.generic uppc zvpsm scsi_vhci zfs zvblk ip hook neti arp usba kssl sockfs lofs random idm cpc crypto fcip fctl fcp ufs logindmux ptm nfs ipc ] > ::memstat Page Summary Pages Bytes %Tot ---------------------------- ---------------- ---------------- ---- Kernel 368046 1.4G 9% ZFS 2236330 8.5G 53% Anon 955993 3.6G 23% Exec and libs 95340 372.4M 2% Page cache 32844 128.2M 1% Free (cachelist) 61894 241.7M 1% Free (freelist) 443246 1.6G 11% Total 4193693 15.9G 

This can be used in a command like echo ::memstat|mdb -k if you just want the output without using the mdb prompt.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.