Add custom command - check_dnf

Hi guys,

Sorry for bothering you with my first post in this forum. I’m not able to add a simple command to the director and ask you for some help or a hint. I want to add check_dnf from I put check_dnf.rb into /usr/lib64/nagios/plugins/ on an agent, made a chmod 755 and run the check on the command line:

[root@pxxxx plugins]# sudo -H -u nagios /usr/lib64/nagios/plugins/check_dnf.rb 
OK - No updates to do on this host.

So far so good. Now I’m going to the director and unfortunately check_dnf is not available as an “External Command” so I add a “Plug In Check Command”:

with this result:

object CheckCommand "dnf" {
    import "plugin-check-command"
    command = [ "/usr/lib64/nagios/plugins/check_dnf.rb" ]
    timeout = 3m

After deploying it I create a “Service Template”:

with this result:

template Service "dnf-check" {
    check_command = "dnf"
    enable_notifications = true
    enable_active_checks = true
    enable_passive_checks = true
    command_endpoint = host_name

and after deploying this template I add the service to a host and this is the result after checking:


Does this check try to run dnf instead of check_dnf.rb?


## Check execution
The Command shows:[...]dnf [Process check result]("https://icinga2/icingaweb2/monitoring/service/process-check-result?host=pxxxx&service=dnf-check")

All the other checks (they are all from “External Commands”) are running smoothly (users-check, disk-check, load check and so on).

What do I missing? Thanks in advance for any help or hint!

Hi @hthuemin , thanks for including the configs. Just to verify that it is loading what you expect - can you click on the service and click Inspect and provide the output from Executed Command?

Hi Lee Clemens and thank you so much for your quick response. I can’t believe that I’m too stupid to find Inspect in the Service Detail View. This is on my left hand side:

And this on my right hand side:


There is no Inspect?! From the documentation (Troubleshooting - Icinga 2) I know it should be here:

Alternatively when using the Director, navigate into the Service Detail View in Icinga Web and pick Inspect to query the details.

Got it sorry, its in the Overview:

Thanks in advance!
Please let me know if I should delete the previous posting…

Holy sh… It was selinux. Sorry and thank you.
I just made a setenforce 0 and not it works :slight_smile:

After creating the selinux policy I will post them here. Now I’ve learned a lot again, thank you.

I’ve just found the selinux policy:

Perfect and I’m happy now! Time to go home :slight_smile:

1 Like