Page 1 of 1

Custom Plugin, NRPE and SSH - No result

Posted: Mon Apr 20, 2020 5:54 am
by cyp
Greetings everyone,
I wrote a few custom Nagios plugins. They work more or less fine. Though I encounter a problem with one of them and so far, I have not succeeded to solve it. That's why I came here to ask some help from the community...

The purpose of the plugin is to retrieve the disk storage from a mounted folder. Quite easy in itself. The thing is I have to check this remotely through SSH. But what's really tricky is I'm using NRPE in addition to the remote check itself.

In other words :
My Nagios Core server ==NRPE check=> Remote server that host the custom plugin ==SSH=> Remote target we want to get the result from

From the remote server, if I manually run the plugin, I have the right result. But from the Nagios server : no data..
Seems like it gets lost somewhere on the way.
My custom plugin contains a while loop (I have a list of remote targets actually) which run the command through SSH for each target. I guess I am doing something wrong somewhere...

Here is the SSH command :
used_space=$(timeout 30s sshpass -p 'my_password' ssh -nq root@$ip "df -h |grep "'/media/removable0'" | awk -F ' ' '{print \$5}'")
(it should not be a timeout problem, I tried many things concerning this, both on the Nagios and remote server hosting plugins, and my other plugins works well. But they don't use SSH...)


If someone has any idea, it would be greatly appreciated.. I'm kinda stuck there..
Thanks in advance for your help ! :)


PS English isn't my native language, so I apologize for any mistakes I did. If something isn't clear enough I can give more information !

Re: Custom Plugin, NRPE and SSH - No result

Posted: Thu Apr 23, 2020 4:16 pm
by benjaminsmith
Hello @cyp,

That's pretty awesome that you've written a few Nagios custom plugins! Reading over your post, a couple of things come to mind?

1. What error message did you get from the Nagios server? Anything.. timeouts?

2. When you run the plugin from the remote host running NRPE, are you logged in as the nagios user? There could be a permissions issue here.

Good Luck! Let us know what you find out.

Benjamin
Nagios Support Team