Include external Commands

Hi,

I have an Icinga2 setup including Director. Now I would like to integrate a CheckCommand.conf from a plugin. However, I don’t have any subdirectories under /etc/icinga2/zones.d/ where I could store the file and subsequently integrate it via Kickstart.

However, the above setup works so far, so I don’t want to “experiment”. Anyone have any tips on how I can read the CheckCommand.conf file?

Greetings

what’s the content of the CheckCommand.conf? Is is like 100 commads or just one check?

currently you have the itl only?
https://icinga.com/docs/icinga-2/latest/doc/10-icinga-template-library/#icinga-template-library

You are advised to create your own CheckCommand definitions in /etc/icinga2

but I am not to familiar with plain config files…

I would add the command using director because you can edit it via gui afterwards.

  • add command (PluginCheckCommand?)
  • add arguments
  • create service template to command

if you post the CheckCommandConf I’m happy to help.

Folgend ein Ausschnitt aus der Konfigurationsdatei vom Plugin.

[ … ]
object CheckCommand “system_basics_filesystem” {
importieren “system_basics”
command = [PluginContribDir + “/check_system_basics”]
arguments = {
“–criticalAbsolutFreeSpace” = {
Wert = “$system_basics_filesystem_criticalAbsolutFreeSpace$”
description = “Absoluter kritischer Schwellenwert für freien Dateisystemplatz”.
repeat_key = false
}
“–warningAbsolutFreeSpace” = {
Wert = “$system_basics_filesystem_warningAbsolutFreeSpace$”
description = “Absoluter Warnschwellenwert für freien Dateisystemplatz.”
repeat_key = false
}
“–criticalAbsolutUsedSpace” = {
Wert = “$system_basics_filesystem_criticalAbsolutUsedSpace$”
description = “Absoluter kritischer Schwellenwert für belegten Dateisystemplatz”.
repeat_key = false
}
“–warningAbsolutUsedSpace” = {
Wert = “$system_basics_filesystem_warningAbsolutUsedSpace$”
description = “Absoluter Warnschwellenwert für belegten Dateisystemplatz.”
repeat_key = false
}
“–criticalPercentFreeSpace” = {
Wert = “$system_basics_filesystem_criticalPercentFreeSpace$”
description = “Kritischer Schwellenwert für freien Dateisystemplatz in Prozent. (Voreinstellung: 2:100)”
repeat_key = false
}
“–warningPercentFreeSpace” = {
Wert = “$system_basics_filesystem_warningPercentFreeSpace$”
description = “Prozentualer Warnschwellenwert für freien Dateisystemplatz. (Voreinstellung: 5:100)”
repeat_key = false
}
“–criticalPercentUsedSpace” = {
Wert = "$system_b

please format your post, if you need help for that read the formating guidlines

the config is also invalid because of a strange translation:

Sorry, it’s a translation error. Here is the new attempt.

[...]
object CheckCommand "system_basics_filesystem" {
	import "system_basics"
	command = [PluginContribDir + "/check_system_basics"]
	arguments = {
		"--criticalAbsolutFreeSpace" = {
			value = "$system_basics_filesystem_criticalAbsolutFreeSpace$"
			description = "Absolute critical threshold for free filesystem space."
			repeat_key = false
		}
		"--warningAbsolutFreeSpace" = {
			value = "$system_basics_filesystem_warningAbsolutFreeSpace$"
			description = "Absolute warning threshold for free filesystem space."
			repeat_key = false
		}
		"--criticalAbsolutUsedSpace" = {
			value = "$system_basics_filesystem_criticalAbsolutUsedSpace$"
			description = "Absolute critical threshold for used filesystem space."
			repeat_key = false
		}
		"--warningAbsolutUsedSpace" = {
			value = "$system_basics_filesystem_warningAbsolutUsedSpace$"
			description = "Absolute warning threshold for used filesystem space."
			repeat_key = false
		}
		"--criticalPercentFreeSpace" = {
			value = "$system_basics_filesystem_criticalPercentFreeSpace$"
			description = "Percentage critical threshold for free filesystem space. (Default: 2:100)"
			repeat_key = false
		}
		"--warningPercentFreeSpace" = {
			value = "$system_basics_filesystem_warningPercentFreeSpace$"
			description = "Percentage warning threshold for free filesystem space. (Default: 5:100)"
			repeat_key = false
		}
		"--criticalPercentUsedSpace" = {
			value = "$system_basics_filesystem_criticalPercentUsedSpace$"
			description = "Percentage critical threshold for used filesystem space."
			repeat_key = false
		}
		"--warningPercentUsedSpace" = {
			value = "$system_basics_filesystem_warningPercentUsedSpace$"
			description = "Percentage warning threshold for used filesystem space."
			repeat_key = false
		}
		"--warningAbsolutFreeInodes" = {
			value = "$system_basics_filesystem_warningAbsolutFreeInodes$"
			description = "Absolute critical threshold for number of free inodes"
			repeat_key = false
		}
[...]

it is about the followinf check:
https://github.com/NETWAYS/check_system_basics

this imports system_basics which is also relevant for the command, but here is your basket:
Director-Basket_1_test_959_acbd944.json.txt (28.9 KB)


You can use this to work yourself through the other commands and learn how to add them:

Create a command:


Add an agrument:

add the field to the command:

For booleans you need to predefine the field as boolean:




1 Like

Attached the full file.
check_system_basics.conf (24.3 KB)

and what should i do with the file?
I already posted basket and an explaination of how you add commands.

I have imported the basket, but I don’t see the data list or the command.

can you post screenshots of how you imported the basket.
keep in mind you have to press restore twice there are two buttons.

Okay, that was my mistake. I had overlooked the restoration. That has now worked.

Could you adjust/convert my uploaded conf file again? The remaining values were still missing in your basket (only filesystem was included).

@moreamazingnick can you translate the full config file to a basket?

I can but there is still something missing in this thread…

@moreamazingnick what are you missing? i’ve uploaded the file yesterday :slight_smile:
https://community.icinga.com/uploads/short-url/yLS8QTqWxLUab2EWGjaoFKcQ2Ir.conf

@InformatikKFM that’s is kinda weird because I took a lot of effort to explain to you how a command is created in icinga director → FAQ - Icinga Community and this thread lacks on two words from your side… => https://www.google.com/search?q=two+magic+words&oq=two+magic+words

3 Likes

For the sake of completeness:

That is because those directories have to be created by hand.
Steps to creating a valid folder and then importing something from there would be:

  • Check what zones you currently have (can be done via Director->Icinga Infrastructure->Zones)
  • create a folder that is named exactly like one of the zones shown there
  • (global zones are preferred for commands as they would be synced to every node, other zones are specific to the endpoints that belong to that zone)
  • put your config into that folder
  • run icinga2 daemon -C to check if everything is correct
  • run the Director kickstart from the webinterface to import the config into the Director

note: Configuration items from config files can be used but not edited inside the Director.

Apart from that I’m with @moreamazingnick that one should learn how to create a command from scratch, just so one knows what goes into it and what to look for. Importing from config files (or baskets) is quick & easy but will do less for learning how to work with the imported items.

My 2 cents :slight_smile:

All the best and don’t hesitate asking in the community if you can’t find a solution in one of the previously posted topics!