I have made a few scripts and tested it up to an icinga2 agent. Unfortunately, it’s not always recognized from the director.
Additionally, you have to create the command yourself. The Icinga Director, as far as I know, does not automatically scan the plugins folder and saves it in the director.
Try to create the command manually and use Runtime Macros to parse variables as arguments.
In your case try to do the following:
Under Icinga2 Director, add a new command with the fields as follows:
Command type: Plugin Check Command
Command Name: check_file_content
Depending on your infrastructure, choose the appropriate zone. If you don’t have any satelites, just leave it blank and let Director deal with it.
Place the plugin script in the plugins folder on your agents that needs to run it. Make sure the registered hosts are in fact registered as an agent.
Do the following in the agents terminal:
sudo chmod +x check_file_content.pl
Under the arguments tab, add the arguments one by one with desired values. Most important 2 things here is
Argument name and
Value input should be with the syntax of
Under the Icinga Director, go to the
Define Data Fields menu and add the variables you have just made for the command. These fields you can either add to the command itself, or the service template where you will use said command. For better overview, add the fields in a category.
Most of this is really just by free hand, but surely it can be automated with an automation script in puppet or ansible. But given how often this will be done, it might not be beneficial for you.
One thing I’ve been struggling with whenever registering a new plugin, is the director can’t always find the file itself, for some reason, even after doing
icinga2 daemon -C on the agent and the master, so I usually just say “screw it” and restart the entire server, if i can permit it.
Hope this helps