Page 1 of 1

Yum Plugin With NCPA

Posted: Wed May 26, 2021 10:46 am
by vornado
Good morning.

Using the Linux Server Wizard, I created a series of monitors for a new RHEL server using the NCPA agent. However, the new NCPA wizard does not create a yum monitor to see to O/S is up to date. I created a bash script as a plugin in the /usr/local/ncpa/plugins directory. NRPE uses a perl script which I referred to when creating my bash script. Apparently, my script runs and gives the proper exit code and status, but in Nagios there's an error message indicating a permissions issue:

Code: Select all

2021-05-26 11:23:51,649 [ERROR] yum:193087:MainThread @logutil.py:194 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr
2021-05-26 11:23:51,651 [ERROR] yum:193087:MainThread @identity.py:156 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 13] Permission denied: '/etc/pki/consumer/key.pem'

[b]YUM WARNING: O/S requires an update.[/b]
Also, here is my bash script:

Code: Select all

#!/bin/bash
if [ "$1" != "" ]; then
 echo -e "Usage: please issue command with no parameters!\n"
 exit 2
fi

yum check-update >/dev/null

if [ "$?" -eq "0" ]; then
 echo -e "YUM OK: O/S is up to date.\n"
 exit 0
else
 echo -e "YUM WARNING: O/S requires an update.\n$?"
 exit 1
fi
Kindly advise how to properly resolve the issue.

Thank you and best regards,

Steve

Re: Yum Plugin With NCPA

Posted: Wed May 26, 2021 12:48 pm
by dchurch
Does it work if you call "sudo yum"? I.e.

Code: Select all

sudo yum check-update >/dev/null
What is the content of your /etc/sudoers file? If you configure it so the 'nagios' user has sudo access to run yum commands, it should work.

Insert this line at the end of /etc/sudoers only if it doesn't work right off the bat. This will grant sudo access to a specific command to "nagios" (assuming your ncpa.cfg specifies uid = nagios).

Code: Select all

nagios ALL = NOPASSWD:/usr/bin/yum check-update

Re: Yum Plugin With NCPA

Posted: Wed May 26, 2021 2:01 pm
by vornado
dchurch wrote:Does it work if you call "sudo yum"? I.e.

Code: Select all

sudo yum check-update >/dev/null
What is the content of your /etc/sudoers file? If you configure it so the 'nagios' user has sudo access to run yum commands, it should work.

Insert this line at the end of /etc/sudoers only if it doesn't work right off the bat. This will grant sudo access to a specific command to "nagios" (assuming your ncpa.cfg specifies uid = nagios).

Code: Select all

nagios ALL = NOPASSWD:/usr/bin/yum check-update

Thanks for your reply.

"sudo yum check-update >/dev/null" does work. I added the line you recommended and confirmed uid = nagios in ncpa.cfg but I still see the same error message. I get the correct status -- now that I updated with yum, I get OK but I see the error (in Nagios).
2021-05-26_15-30-58.png
The file mentioned in the error message, rhsm.log, is related to Red Hat Subscription Manager. I will reach out to Red Hat to see if they can help.

Re: Yum Plugin With NCPA

Posted: Wed May 26, 2021 4:40 pm
by dchurch
What's the output from the following commands?

Code: Select all

su - nagios
sudo yum check-update
getenforce
ls -la /etc/pki/consumer

Re: Yum Plugin With NCPA

Posted: Fri May 28, 2021 9:13 am
by vornado
dchurch wrote:What's the output from the following commands?

Code: Select all

su - nagios
sudo yum check-update
getenforce
ls -la /etc/pki/consumer
Per your earlier post, I added "sudo" in the script and it worked. Thanks for your help.

Re: Yum Plugin With NCPA

Posted: Fri May 28, 2021 9:27 am
by benjaminsmith
Per your earlier post, I added "sudo" in the script and it worked. Thanks for your help.
Excellent. Thanks for the update, we'll mark this as resolved.

Have a great weekend!