My plugin not work ?

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

My plugin not work ?

Postby liberodark » Wed May 29, 2019 8:10 am

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
liberodark
 
Posts: 25
Joined: Tue Mar 19, 2019 8:56 am

Re: My plugin not work ?

Postby scottwilkerson » Wed May 29, 2019 4:38 pm

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: My plugin not work ?

Postby liberodark » Thu May 30, 2019 7:50 am

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
liberodark
 
Posts: 25
Joined: Tue Mar 19, 2019 8:56 am

Re: My plugin not work ?

Postby scottwilkerson » Thu May 30, 2019 9:11 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: My plugin not work ?

Postby liberodark » Fri May 31, 2019 2:42 am

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 ?

Postby liberodark » Fri May 31, 2019 3:05 am

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.
liberodark
 
Posts: 25
Joined: Tue Mar 19, 2019 8:56 am

Re: My plugin not work ?

Postby scottwilkerson » Fri May 31, 2019 6:42 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 1 guest