I have a problem with using commands on a linux client. It’s very simple, I have a service set for linux called basic linux checks or something, it has all the basic stuff like disk space, cpu load, memory, etc. Everything works except I memory.
For disk and cpu load I use the external commands called “load” and “disk”. These work just fine. But when using “mem” from the external commands I get the error: missing check_mem.pl. So I downloaded that file and it runs, but it says it needs arguments. Ok, no problem, I create a new command Called “Memory Check Command - Linux” and add the parameters. It looks like this:
Then I add this to my service, like it did on all my windows hosts and it says that command “Memory Check Command - Linux does not exist”.
Am I doing something wrong here? This approach worked on windows clients where I had to add arguments to the check commands.
Couple of things are off here, you’re using the command object like a service object should ideally be used. Check this for the values already specified by the included command object:
check_mem.pl is one of a number of not-included checks that they already have command templates for. So instead, consider this example for a service object once check_mem.pl is available:
apply Service "memory" {
import "generic-service"
check_command = "mem"
command_endpoint = host.name
// consider this if your host template includes the command_endpoint value
// from the default template:
// command_endpoint = host.vars.client_endpoint
vars.mem_used = true
vars.mem_cache = true
vars.mem_warning = 85 // percent
vars.mem_critical = 90
assign where host.vars.os = "Linux"
}
I’m not sure I understand what you’re getting at… The check_mem.pl is working, but it needs arguments passed (-c and -w) to work. How does one pass those arguments if not by creating a command object?
the command object receives them from the service object. this way they can be tuned per service object created, or per host type, etc. Command objects typically inherit from a Service object’s variables first and a Host object’s variables secondarily.
You can actually view the pre defined command objects in /usr/share/icinga2/include/. For mem is it such:
On Director? I’ll let someone else chime in. I do everything by hand. If there’s a thing for putting the aforementioned variables in, you’ll want to use that as the arguments are inherited.
Navigate into Commands > External and search for mem. Then in the fields tab, select the command arguments you want to use in your services. This is a required step.
Once done, navigate into the services, create apply rules or sets, put mem as check_command and select the previously created data fields from command arguments.
That clears up a lot of things. Now I only need to pass ‘-u’ to make it monitor USED memory, however I can only add the ‘mem_critical’ and ‘mem_warning’ fields and don’t see a way to add a custom one. Any ideas?
Hmmm it could be the case that the Director doesn’t understand the commands imported from Icinga 2’s ITL with set_if and no value, I am not sure about this.
Still, if you don’t get them via the command fields, you can always define data fields “free form” for being used in your service definitions. Therefore, navigate to the main dashboard and pick the data fields section.
Now, in your service, add this field and select true.
Once Icinga executes the check then, it will evaluate mem_used and if set to true, automatically add the required command line parameter -u. You can verify this via the Inspect option in the service’s detail view in Icinga Web 2.
You’re welcome Especially since I am still learning with the Director, I am glad I could have helped you in there.
Please pick a reply which fits best as solution, and mark it like this. This helps others to immediately see that this topic has a solution too More: Mark a topic as solved