Convert KB in GB

(Andre) #1

Hi community,

I build a Service-Templat for my Linux-Host’s to check the memory (check_SNMP_MEM_free). It works, but I get the value in KB . How can I convert in the Director to MB oder GB ?




(Aflatto) #2

Director can not convert the return values, also Director is not the place where you view the results, that is the Icinga Web.
To convert the values, you will need to do that in the plugin output.

(Andre) #3

You mean on the commandline in the directory /usr/lib/nagios/plugins ?

Sorry I am confused about the Director, but I am learning :wink:

(Aflatto) #4


The plugin is the actual execution file, and it is the one parsing the output data.
The director is a tool to configure Icinga, but it does not alter any output from check execution.

So to answer your initial question, to modify the output data, you will need to change the plugin to match the desired output you want to see.

1 Like
(Andre) #5

on commandline it works:
:/usr/lib/nagios/plugins# ./ -f -w 18 -c 8
OK - 31.6% (1277824 kB) free.|TOTAL=4040064KB;;;; USED=2762240KB;3312852;3716858;; FREE=1277824KB;;;; CACHES=2116436KB;;;;

But on IcingaWeb I see that:

That is what I configured:


Maybe I am completly on the woodway :roll_eyes:


The commands mem and snmp-memory are two different commands (and scripts).
mem is, and the command should be imported into the Icinga Director from the ITL.
snmp-memory is, and should also have been imported on the kickstart of the Director.

The ARG1 in your snmp-memory command does not make sense, as the command will not know how to use it, as it is not connected to any argument.

If you want to run this command you will have to use/configure the mem command in the Icinga Director.
Go to the command, switch to the “Field” tab and add the mem_warning and mem_critical fields.
As you want to check for the remaining free memory with -f you will have to do three additional steps:

  1. go to the “Define data fields” menu in the icinga Directorimage
  2. add a field called mem_free of data type Boolean
  3. go back to the mem command and add the mem_free field.

Next define a service template with the mem command and create apply rules.

1 Like
(Andre) #7


thank you for that help :slight_smile: It’s works, but there is still a problem.

How can I add the -H Option ? Otherwise all have the same value :astonished:
I was confused that the total mem of that host was shown as 3.85 GB, but it has
only 2 GB. So the value was from the Icinga2-Host itself :see_no_evil:

That can I see when I click on Actions --> Inspect:

’/usr/lib/nagios/plugins/’ ‘-c’ ‘8’ ‘-f’ ‘-w’ '18’

There is no variable for the hostadress ?

object CheckCommand “mem” {
import “plugin-check-command”
command = [ PluginDir + “/” ]
timeout = 1m
arguments += {
“-C” = {
description = “Count OS caches as FREE memory”
set_if = “$mem_cache$”
“-c” = {
description = “Percent free/used when critical”
value = “$mem_critical$”
“-f” = {
description = “Check FREE memory”
set_if = “$mem_free$”
“-u” = {
description = “Check USED memory”
set_if = “$mem_used$”
“-w” = {
description = “Percent free/used when to warn”
value = “$mem_warning$”
vars.mem_cache = false
vars.mem_free = false
vars.mem_used = false


You can’t ;), as this plugin is just for the host it is running on.
If you want to monitor a remote hosts memory you will have to use either

  • a plugin via SNMP (like
  • configuring check_by_ssh and run the plugin on the remote system locally
  • install the Icinga 2 Agent on the remote system so that it monitors itself and reports the results to the master.
1 Like
(Andre) #9

Oh that is the reason :upside_down_face:

Thank you so much for that great help :slight_smile:

So I try it with the Agent or SNMP