Custom Plugin, NRPE and SSH - No result
Posted: Mon Apr 20, 2020 5:54 am
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 !
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 !