[Nagiosplug-devel] [ nagiosplug-Patches-1847879 ] check_ram plugin (based on check_swap)

Andreas Ericsson ae at op5.se
Tue Dec 11 09:13:44 CET 2007


Thomas Guyot-Sionnest wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 10/12/07 09:35 AM, Andreas Ericsson wrote:
>> SourceForge.net wrote:
>>> Patches item #1847879, was opened at 2007-12-10 14:59 Message
>>> generated for change (Tracker Item Submitted) made by Item Submitter 
>>> You can respond by visiting: 
>>> https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1847879&group_id=29880
>>>
>>>
>>> Please note that this message will contain a full copy of the comment
>>> thread, including the initial issue submission, for this request, not
>>> just the latest update. Category: Enhancement Group: None Status:
>>> Open Resolution: None Priority: 5 Private: No Submitted By: Christian
>>> Heim (g_phreak) Assigned to: Nobody/Anonymous (nobody) Summary:
>>> check_ram plugin (based on check_swap)
>>>
>>> Initial Comment: Find attached a C-based version of the check_ram
>>> plugin. The code is based upon the check_swap plugin minus the
>>> BSD/AIX (and others) code.
>>>
>> Why not just use sysconf(_SC_PHYS_PAGES) - sysconf(_SC_AV_PHYS_PAGES) ?
>>
>> Fiddling with /proc/meminfo isn't very portable.
> 
> Lol. I didn't read the plug-in yet but I would have assumed from start
> that it was portable. I'm sure we want a memory check plugin, so I'll
> rework it it there's a way to make it portable. This won't be for the
> upcoming release though...
> 

_SC_PHYS_PAGES and _SC_AV_PHYS_PAGES are in POSIX.1-2001. They need to
be multiplied with _SC_PAGESIZE (defined in the same standard) to get
actual byte values (which may well be huge), but many systems support
it even though they don't follow the rest of the standard.

I'd suggest finding the correct value to divide the resource-values
with to get human-readable numbers and just storing everything in
unsigned long's.

Something like the attached, perhaps? It doesn't really give very
accurate numbers though, since nearly all unices cache until physical
RAM is pretty much full. It doesn't parse arguments or anything
either, but should give a decent idea of how one could go about
implementing it fairly portable. It's commented to the point of being
insulting, since I have no idea who might get his/her hands on it
and I really don't feel like answering questions about that particular
subject ;-)

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
-------------- next part --------------
A non-text attachment was scrubbed...
Name: check_ram.c
Type: text/x-csrc
Size: 1091 bytes
Desc: not available
URL: <http://nagios-plugins.org/archive/devel/attachments/20071211/fa236c30/attachment.c>


More information about the Devel mailing list