# swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 256,2 16 8388592 8388592
The last colums shows blocks and free, where blocks is the current size and free shows how many blocks are free. The manpage for swap holds the following information:
# man swap
...
blocks
The swaplen value for the area in 512-byte blocks.
free
The number of 512-byte blocks in this area that are
not currently allocated.
free
The number of 512-byte blocks in this area that are
not currently allocated.
...
Now you can multiply both values to get the current SWAP size in Bytes:
# echo 8388592*512 | bc -l
4294959104
Deviding 4294959104 by 1024 three time will give you the SWAP size in GB:
# echo 8388592*512/1024/1024/1024 | bc -l
3.99999237060546875000
Use the following command to get the used and free space of your Swap in GB:
# swap -l | grep -v "swapfile" | awk 'BEGIN {FS=" "} {print $1" - Size: "$4*512/1024/1024/1024"GB - Free: "$5*512/1024/1024/1024"GB"}'
/dev/md/dsk/d5 - Size: 16.0029GB - Free: 16.0029GB
The ouptut was taken from another machine but does the same.
You can check the above value if you are using ZFS:
# zfs get all rpool/swap | grep volsize
rpool/swap volsize 4G -
No comments:
Post a Comment