How create checkcommand for check_mem.pl?

hello forum,

we would like to monitor the RAM on our Linux machines. For this you can copy the plugin check_mem.pl into the plugin directory. So far that’s fine and the output on the CLI works:

/usr/lib/nagios/plugins# ./check_mem.pl -w 10 -c 5 -f

OK - 79.2% (6423364 kB) free-percentage.|TOTAL=8113196KB;;;; USED=1689832KB;7301877;7707537;; FREE=6423364KB;;;; CACHES=1292292KB;;;;

But how do we get an output in the director? The following forum article doesn’t really get us there: Memory check "check_mem" not working - #26 by unic
Is there a guide on how to correctly create such commands in the director in order to get an output? I can’t really find leather and I’m going in circles.

Thanks for your support.

You don’t need to create a check command for it as there is a corresponding command defined in ITL already.

Ok, and how can i create a check? I’m not find a sulition for this. :frowning_face:

check_mem.pl v1.0 - Nagios Plugin usage: check_mem.pl - -w -c options: -a Check AVAILABLE memory -f Check FREE memory -u Check USED memory -C Count OS caches as FREE memory -w PERCENTAGE Percent free/used/available when to warn -w SIZE K/M/G Absolute size free/used/available when to warn -c PERCENTAGE Percent free/used/available when critical -c SIZE K/M/G Absolute size free/used/available when critical -v Show verbose output example: check_mem.pl -C -f -w 20 -c .5 Returns 1 if less than 20% free memory. Returns 2 if less than 0.5% free memory. Takes caches into account. check_mem.pl -u -w 80 -c 95 Returns 1 if more than 80% memory in use. Returns 2 if more than 95% memory in use. check_mem.pl -C -f -w 2G -c 500M Returns 1 if less than 2G free memory. Returns 2 if less than 500M free memory. Takes caches into account. Copyright (C) 2000 Dan Larsson

You need to define a service check as described here.

Helo Roland,

i have create a service template. It is not work.


Hello Faust,

did you Apply the Service-Template to your Hosts via a Service-Apply Rule or a Service-Set?

as first step you can also create a “Single-Service” for your Host to test your Service-Template.

The Template has to be “used” onto your Hosts :slight_smile: it wont run on itself!

Greetings

Hello Doberitus,

Many thanks for the help. I set it up like this.

  1. Service template created
  2. added the fields mem_critical, mem_free and mem_warning to the service check
  3. created the check_mem.pl on the host and given all rights with chmod a+x
  4. Check command assigned to the service set
  5. Roll out

My question is, how do the fields have to be filled correctly. Or what is still missing to get this output: “*** You must select to monitor USED, FREE or AVAILABLE memory! check_mem.pl v1.0 - Nagios Plugin usage: check_mem.pl - -w -c options: -a Check AVAILABLE memory -f Check FREE memory -u Check USED memory -C Count OS caches as FREE memory -w PERCENTAGE Percent free/used/available when to warn -w SIZE K/M/G Absolute size free/used/available when to warn -c PERCENTAGE Percent free/used/available when critical -c SIZE K/M/G Absolute size free/used/available when critical -v Show verbose output example: check_mem.pl -C -f -w 20 -c .5 Returns 1 if less than 20% free memory. Returns 2 if less than 0.5% free memory. Takes caches into account. check_mem.pl -u -w 80 -c 95 Returns 1 if more than 80% memory in use. Returns 2 if more than 95% memory in use. check_mem.pl -C -f -w 2G -c 500M Returns 1 if less than 2G free memory. Returns 2 if less than 500M free memory. Takes caches into account. Copyright (C) 2000 Dan Larsson”

It is clear that something is still missing. Only what, how and where is totally unclear. Unfortunately there are no instructions or a useful template to create this important Chek in Icinga2 via the director. I can’t imagine I’m the only one frustrated by this. And the other question I ask myself, why isn’t such an important check properly integrated in the Icinga from the ground up and only possible in a roundabout way? It also works with Windows machines. I don’t understand.

Best Regards Faust

the vars for free/used have to be a boolean type, as those parameters are only switches for the script
e.g. mem_used
image

After that you are able to choose from a dropdown.

Note: you named your variable mem_fee (missing and r), in case you haven’t noticed or corrected it yet.

Hello log1c,

Thanks for the support. But we didn’t manage it. We will no longer use Icinga2 and have switched to a different monitoring tool.

Greetings