Plugin Issue with check_kvm

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Berto
Posts: 162
Joined: Tue Jul 01, 2014 6:12 pm

Plugin Issue with check_kvm

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Plugin Issue with check_kvm

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Berto
Posts: 162
Joined: Tue Jul 01, 2014 6:12 pm

Re: Plugin Issue with check_kvm

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Plugin Issue with check_kvm

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Berto
Posts: 162
Joined: Tue Jul 01, 2014 6:12 pm

Re: Plugin Issue with check_kvm

Post 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
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Plugin Issue with check_kvm

Post 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 
Previous Nagios employee
Berto
Posts: 162
Joined: Tue Jul 01, 2014 6:12 pm

Re: Plugin Issue with check_kvm

Post 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
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Plugin Issue with check_kvm

Post by avandemore »

What is the output of # grep nagios /etc/group?
Previous Nagios employee
Locked