Bayram
Bayram

Reputation: 53

Icinga2 check_mem plugin doesn't accept parameters

​Hello,

I've created a custom command in Icinga 2 using this plugin:

https://github.com/justintime/nagios-plugins/blob/master/check_mem/check_mem.pl

check_command

object CheckCommand "memory" {
  import "plugin-check-command"
  command = [ PluginDir + "/check_mem" ]

  arguments = {
    "-w" = {
     required = true 
     value = "$mem_warning$"
    }

    "-c" = {
     required = true
     value = "$mem_critical$"
    }
    "-u" = {
     required = true
     value = "$mem_used$"
    }

    "-C" = "$mem_cache$"
  }

  vars.mem_used = true
  vars.mem_cache = true
  vars.mem_warning = 85
  vars.mem_critical = 95

}

service

apply Service "Memory" {
  import "generic-service"
  check_command = "memory"
  assign where host.address
}

However the plugin cannot check the memory and gives the following output in Icinga Web 2 interface:

​Plugin Output

*** You must define WARN and CRITICAL levels! \ncheck_​mem.​pl v1.​0 - Nagios Plugin\n\nusage:​\n check_​mem.​pl -\ncheck_​mem.​pl comes with absolutely NO WARRANTY either implied or explicit\nThis program is licensed under the terms of the\nMIT License (check source code for details)

Could you please help, what is wrong with this check?

Upvotes: 3

Views: 4134

Answers (2)

enjoy343322434
enjoy343322434

Reputation: 129

This works with your service

object CheckCommand "memory" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_mem.pl" ]

    arguments = {
      "-w" = {
         value = "$mem_warning$" 
      }
     "-c" = {
        value ="$mem_critical$"
      }
     "-u" = {
        set_if = "$mem_used$"
     }
     "-C" = {
        set_if = "$mem_cache$"
     }  
   }

    vars.mem_warning = 85
    vars.mem_critical = 95
    vars.mem_used = true
    vars.mem_cache = true
}

Upvotes: 2

saravanakumar
saravanakumar

Reputation: 1777

Give like this, you command will get values from service at run time.

apply Service "Memory" {
  import "generic-service"
  check_command = "memory"
  vars.mem_used = true
  vars.mem_cache = true
  vars.mem_warning = 85
  vars.mem_critical = 95
  assign where host.address
}

This will replaced while execution refering this will help .If you are using NRPE, please update your question with that, answer may differ for that please refer arguments passing icinga to NRPE.

Upvotes: 1

Related Questions