My plugin not work ?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
liberodark
Posts: 25
Joined: Tue Mar 19, 2019 8:56 am

My plugin not work ?

Post by liberodark »

Hi,

Have make new plugin for cpu nrpe but is not work is very strange.

https://github.com/liberodark/nrpe-inst ... heck_cpu.c

Centos 7
SELinux disable

Work in local :

Code: Select all

./check_cpu -w 70 -c 90
OK: CPU Used = 0.00% | Core 0 = 0.00%; Core 1 = 0.00%
parameter on nrpe.cfg :

Code: Select all

command[cpu]=/usr/local/nagios/libexec/check_cpu -w 70 -c 90
Not work :

Code: Select all

./check_nrpe -H 127.0.0.1 -c cpu
NRPE: Unable to read output
No more information in debug :
May 29 15:04:49 server nrpe[31896]: WARNING: my_system() seteuid(0): Operation not permitted

NRPE: Unable to read output

You have any idea for what my plugin work ?
PS : Is my first plugin !


Best Regards
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: My plugin not work ?

Post by scottwilkerson »

It looks like your plugin need root access, you would have to add sudoers access for the nagios user and then change the command in the nrpe.cfg to

Code: Select all

command[cpu]=sudo /usr/local/nagios/libexec/check_cpu -w 70 -c 90
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
liberodark
Posts: 25
Joined: Tue Mar 19, 2019 8:56 am

Re: My plugin not work ?

Post by liberodark »

For what need sudo ?
This plugin run without sudo.
Have possibility to no add sudo ? would better for me.

Best Regard
Thanks for your reply
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: My plugin not work ?

Post by scottwilkerson »

This leads me to have elevated permissions
liberodark wrote:May 29 15:04:49 server nrpe[31896]: WARNING: my_system() seteuid(0): Operation not permitted
Can you run the following

Code: Select all

su nagios
./check_cpu -w 70 -c 90
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
liberodark
Posts: 25
Joined: Tue Mar 19, 2019 8:56 am

Re: My plugin not work ?

Post by liberodark »

Yes is not work in su nagios

Code: Select all

su nagios
bash-4.2$ /usr/local/nagios/libexec/check_cpu -w 70 -c 90
bash: /usr/local/nagios/libexec/check_cpu: Permission non accordée
have try to

Code: Select all

chown nagios:nagios /usr/local/nagios/libexec/check_cpu
Now work on su nagios
Last edited by liberodark on Fri May 31, 2019 4:29 am, edited 1 time in total.
liberodark
Posts: 25
Joined: Tue Mar 19, 2019 8:56 am

Re: My plugin not work ?

Post by liberodark »

Ok have try :

with visudo

Code: Select all

nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_cpu
that work

Best Regards

So sorry to disturb you no forget to change the chown all plugins is on nagios and this plugin have add manually is very stupid issue sorry.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: My plugin not work ?

Post by scottwilkerson »

liberodark wrote:Ok have try :

with visudo

Code: Select all

nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_cpu
that work

Best Regards

So sorry to disturb you no forget to change the chown all plugins is on nagios and this plugin have add manually is very stupid issue sorry.
Glad it is resolved!

Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked