[Nagiosplug-devel] check_swap on solaris with metadisk

Thomas Sluyter tsluyter at kilala.nl
Tue Jun 13 11:18:54 CEST 2006


On 13 Jun, 2006, at 10:27, Ben O'Hara wrote:

> db5# swap -l
> swapfile             dev  swaplo blocks   free
> /dev/md/dsk/d20     85,20     16 2097392      0
>
> db5# swap -s
> total: 3431360k bytes allocated + 34488k reserved = 3465848k used,  
> 820608k available

 From the man-page of "swap":
> The blocks column from swap -l reports:
> The swaplen  value  for  the  area  in  512-byte blocks.

Also from that man-page:
> The allocated column from swap -s reports:
> The  total  amount  of  swap  space in   bytes currently allocated  
> for use as backing store.

So there's a discrepancy right there.

How could your swap partition be 2.097.392 * 512 (about 1G) in size,  
when you have a total of over 3.4G in use? Swap -l does indeed report  
that there are zero blocks free... Odd.

Could it be that you defined a non-default block size when creating  
the swap space? Something like ~2048 per block? Could be that "swap - 
l" doesn't actually report the size in 512 blocks, but in the -real-  
size blocks. If check_swap was relying on swap -l , then the  
calculation would be off as well... Seems like this might be a bit of  
a bug in Solaris' "swap -l" command?

Anywho, looking at my own systems the combination of "df -k" and  
"swap -s" seems to be the more reliable way of telling the real swap  
usage.

So instead of the output of "metastat" I'm more curious about the  
output of "df -k". This should show the size for your swap device in  
kB (look for /var/run)...

Now, if "df -k" supports your claim that swap space is 4G in size I'd  
wager that check_swap was using the "swap -l" approach, while it  
could be making better use of the "swap -s" way.

There's more buginess in check_swap anyway... See below:
> JST $ ./check_swap -w 85% -c 95%
> Warning percentage should be more than critical percentage
> Usage:
> check_swap [-a] -w <used_percentage>% -c <used_percentage>%
> check_swap [-a] -w <bytes_free> -c <bytes_free>
> check_swap (-h | --help) for detailed help
> check_swap (-V | --version) for version information
>
> JST $ ./check_swap -w 15% -c 5%
> SWAP OK: 98% free (1360 MB out of 1391 MB) |swap=1360MB;208;69;0;1391
Meaning that the author got "used_percentage" mixed up with  
"free_percentage"

Cheers!


Thomas




More information about the Devel mailing list