Page 1 of 1

Plugin Issue with check_kvm

Posted: Sun Oct 16, 2016 11:05 am
by Berto
Hello,

I've noticed that the plugin check_kvm that I'm using is all of sudden displaying "Unknown guests" for the results. If I run /usr/local/nagios/libexec/check_nrpe -H localhost -c check_kvm as root or as the nagios user, I get the same results back from the command line. I'm pretty much the only person in my team that configures Nagios Xi, so not sure what has happen for this to stop working. My /etc/sudoers for nagios user looks like this:

# NEEDED TO ALLOW NAGIOS TO CHECK SERVICE STATUS
Defaults:nagios !requiretty
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_init_service
nagios ALL=(ALL) NOPASSWD: /usr/local/nagios/libexec/check_kvm

# ASTERISK-SPECIFIC CHECKS
# NOTE: You can uncomment the following line if you are monitoring Asterisk locally
#nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_asterisk_sip_peers.sh, /usr/local/nagios/libexec/nagisk.pl, /usr/sbin/asterisk

/etc/passwd shows:
nagios:x:59658:59658::/home/nagios:/bin/bash

/etc/group shows:
nagios:x:59658:nagios
nagcmd:x:501:nagios

/etc/nsswitch.conf shows for sudoers:
sudoers: files ldap

The plugin did mention to avoid using sudoers I can add the nagios users to the libvirt group, but trying that didn't help.

--Berto

Re: Plugin Issue with check_kvm

Posted: Sun Oct 16, 2016 8:14 pm
by Box293
What is is the command definition for check_kvm in your nrpe configuration file and what happens when you execute the plugin as the nagios user?

Re: Plugin Issue with check_kvm

Posted: Tue Oct 25, 2016 7:56 pm
by Berto
Sorry for a late reply but here is the command definition in the nrpe.cfg:

command[check_kvm]=/usr/local/nagios/libexec/check_kvm

As the nagios user using the plugin

bash-4.1$ /usr/local/nagios/libexec/check_nrpe -H localhost -t 30 -c check_kvm
Unknown guests

Re: Plugin Issue with check_kvm

Posted: Tue Oct 25, 2016 10:28 pm
by Box293
Execute the plugin as the nagios user:

Code: Select all

su nagios
/usr/local/nagios/libexec/check_kvm
When I try and run it, I get the output:

Code: Select all

./check_kvm: line 43: virsh: command not found
Unknown guests
Do you get this output? Do you have virsh installed?

What is the output of (when the nagios user):

Code: Select all

virsh list --all

Re: Plugin Issue with check_kvm

Posted: Thu Oct 27, 2016 10:02 am
by Berto
This is the output as nagios
sudo su - nagios

-bash-4.1$ /usr/local/nagios/libexec/check_kvm
error: Failed to reconnect to the hypervisor
error: no valid connection
error: authentication failed: Authorization requires authentication but no agent is available.

Unknown guests

If I run virsh list --all as nagios I see

-bash-4.1$ sudo virsh list --all
Id Name State
----------------------------------------------------
1 lncpu0350 running
2 lncpu2104 running

Re: Plugin Issue with check_kvm

Posted: Thu Oct 27, 2016 11:44 am
by avandemore
If I run virsh list --all as nagios I see

Code: Select all

-bash-4.1$ sudo virsh list --all
Actually that is not run as user nagios, it's run as root.

Your nagios user doesn't have the appropriate authentication.

To attempt as nagios user this the cleanest form(using sudo unnecessarily is convoluting the problem):

Code: Select all

# su - nagios
bash-4.1$ /usr/local/nagios/libexec/check_kvm 

Re: Plugin Issue with check_kvm

Posted: Sat Oct 29, 2016 11:17 am
by Berto
-bash-4.1$ /usr/local/nagios/libexec/check_kvm
error: Failed to reconnect to the hypervisor
error: no valid connection
error: authentication failed: Authorization requires authentication but no agent is available.

Unknown guests

Re: Plugin Issue with check_kvm

Posted: Mon Oct 31, 2016 12:33 pm
by avandemore
What is the output of # grep nagios /etc/group?