Get script result from remote Linux server
Get script result from remote Linux server
Hello,
I wrote a shell script on a remote Linux server and would like to monitor this result in NAGIOS.
The script return the amount of users connected to a specific application.
The script runs without error when exedcuted on the remote server.
What is the best way to get that information in NAGIOS (check_by_ssh, check_nrpe or something else ...)
For the chosen option, could you give me the main lines to configure on both NAGIOS server and Remote server.
Thanks.
I wrote a shell script on a remote Linux server and would like to monitor this result in NAGIOS.
The script return the amount of users connected to a specific application.
The script runs without error when exedcuted on the remote server.
What is the best way to get that information in NAGIOS (check_by_ssh, check_nrpe or something else ...)
For the chosen option, could you give me the main lines to configure on both NAGIOS server and Remote server.
Thanks.
-
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Get script result from remote Linux server
Hello, @yellowdog. I'd go with the nrpe agent. On the remote server please execute the commands from this tutorial:
https://assets.nagios.com/downloads/nag ... _Agent.pdf
After you install the nrpe place your custom plugin in the /usr/local/nagios/libexec/ folder on the remote server and give it the permissions:
On the remote server open the /usr/local/nagios/etc/nrpe.cfg file and change:
To:
Where 192.168.4.172 is the Nagios core ip address.
Run:
Then from the Nagios server run the following command and share the output with us:
Where 191.114.3.142 is the IP address of the remote nrpe server.
https://assets.nagios.com/downloads/nag ... _Agent.pdf
After you install the nrpe place your custom plugin in the /usr/local/nagios/libexec/ folder on the remote server and give it the permissions:
Code: Select all
chmod 777 your_plugin.sh
Code: Select all
allowed_hosts=127.0.0.1
Code: Select all
allowed_hosts=127.0.0.1 192.168.4.172
Run:
Code: Select all
service nrpe restart
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H 191.114.3.142
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Get script result from remote Linux server
The result of the command shows that NAGIOS is able to communicate with the remote server, but now, how do I proceed to run the script on the remote server ?
[root@GLNXNGIOS plugins]# ./check_nrpe -H VLNXDIAP2
NRPE v3.2.0
-
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Get script result from remote Linux server
@yellowdog, On the remote server open the /usr/local/nagios/etc/nrpe.cfg file and add the following command in the commands section:
*you can change the check_script name to anything you like
*replace the script_name.sh in the path with the actual script name
Run:
Then from the Nagios server run the following command and share the output with us:
Code: Select all
command[check_script]=/usr/local/nagios/libexec/script_name.sh
*replace the script_name.sh in the path with the actual script name
Run:
Code: Select all
service nrpe restart
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H 191.114.3.142 -c check_script
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Get script result from remote Linux server
Everything is fine now, thanks a lot.
Re: Get script result from remote Linux server
Great to hear it! Did you have further (related) questions or are we good to lock this up?
Former Nagios employee
Re: Get script result from remote Linux server
A really nice way to do this is, instead of using NRPE, to use snmp.
See my url to find more info on this:
http://mona.deltics.info/snmp-execute-remote-script/
See my url to find more info on this:
http://mona.deltics.info/snmp-execute-remote-script/
Rob Hassing
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact: