Yum Plugin With NCPA

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
vornado
Posts: 79
Joined: Wed Jun 13, 2018 9:17 am

Yum Plugin With NCPA

Post 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
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Yum Plugin With NCPA

Post 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
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
vornado
Posts: 79
Joined: Wed Jun 13, 2018 9:17 am

Re: Yum Plugin With NCPA

Post 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.
You do not have the required permissions to view the files attached to this post.
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Yum Plugin With NCPA

Post 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
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
vornado
Posts: 79
Joined: Wed Jun 13, 2018 9:17 am

Re: Yum Plugin With NCPA

Post 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.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Yum Plugin With NCPA

Post 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!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked