[Nagiosplug-devel] check_swap on solaris with metadisk

Ben O'Hara bohara at gmail.com
Tue Jun 13 11:34:41 CEST 2006


On 6/13/06, Thomas Sluyter <tsluyter at kilala.nl> wrote:
>
> 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.



Hi Thomas, thanks for the detailed reply.

df -k is showing

Filesystem            kbytes    used   avail capacity  Mounted on
swap                  810152      24  810128     1%    /var/run

Which seems to suggest swap is only 800MB with 1% used?

The source for check_swap has the following

#   ifdef sun
        if (!allswaps) {
                asprintf(&swap_command, "%s", "/usr/sbin/swap -s");
                asprintf(&swap_format, "%s", "%*s %*dk %*s %*s + %*dk %*s =
%dk
%*s %dk %*s");
                conv_factor = 2048;
        }
#   endif


Which to me suggests that its using swap -s for its calculations?



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"



Hmm, maybe worth not using check_swap then!

Cheers

Ben

Cheers!
>
>
> Thomas
>
>
> _______________________________________________________
> Nagios Plugin Development Mailing List
> Nagiosplug-devel at lists.sourceforge.net
> Unsubscribe at
> https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
> ::: Please include plugins version (-v) and OS when reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
>



-- 
"A Scientist will earn a living by taking a really difficult problem and
spends many years solving it, an engineer earns a living by finding really
difficult problems and side stepping them"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nagios-plugins.org/archive/devel/attachments/20060613/cd7a562a/attachment.html>


More information about the Devel mailing list