Custom Plugin, NRPE and SSH - No result

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
cyp
Posts: 1
Joined: Mon Apr 20, 2020 4:32 am

Custom Plugin, NRPE and SSH - No result

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

Re: Custom Plugin, NRPE and SSH - No result

Post 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
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