Using Nagios Can I able to execute script from Nagios ?
Can I push script to endpoint using Nagios ?
If yes how do I do that. Any document or method is available in Nagios.
Script Execution Via Nagios
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Script Execution Via Nagios
Could you explain a bit more what you are looking to do, and on what type of devices? Yes nagios absolutely can run scripts, just place them in the /usr/local/nagios/libexec directory and apply the correct permissions. Setup a service and command definition and let it go! As for pushing things, that definitely needs a bit more clarification as stated above.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
-
lafargeuser
- Posts: 341
- Joined: Thu Sep 27, 2012 12:23 am
Re: Script Execution Via Nagios
Actually, My Prominent purpose is to deploy scripts remotely on monitoring nodes using Nagios & execute it from Nagios.
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Script Execution Via Nagios
Yes, this is what agent such as NRPE are for. I would install this on the remote system and use it to execute the plugins.
http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf
http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf
Re: Script Execution Via Nagios
Just to clarify, there is not a way I know of in Nagios to push scripts to hosts that do not already have some sort of client-side software running on them to allow this. This is not a limitation of Nagios, but rather a security feature of most operating systems. It would be scary if just anyone could run scripts on your computer!
Former Nagios employee
-
lafargeuser
- Posts: 341
- Joined: Thu Sep 27, 2012 12:23 am
Re: Script Execution Via Nagios
If I placed a shell scirpt on end point & want to call it from Nagios. How Do I do that using Nagios.
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Script Execution Via Nagios
You would install NRPE on the remote host, define a command within the nrpe.cfg file to call that plugin. Then call the command remotely from Nagios passing any arguments you require.
-
lafargeuser
- Posts: 341
- Joined: Thu Sep 27, 2012 12:23 am
Re: Script Execution Via Nagios
How Do I do that for Windows hosts ?
Can Nagios able to execute powershell script on windows machine.
Can Nagios able to execute powershell script on windows machine.
-
lafargeuser
- Posts: 341
- Joined: Thu Sep 27, 2012 12:23 am
Re: Script Execution Via Nagios
#!/bin/bash
service=httpd
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running!!!"
else
/etc/init.d/$service start
fi
I have placed this script /usr/local/nagios/libexec/ On nagios server & wants to call it from Nagios.
If I stopped httpd service on one of my Unix Box & run this script from Nagios server that service should gets start as per script.
what is the procedure is it I have to placed this script on monitored node which is being monitored by Nagios & How do I call that script from Nagios.
Can you pls. elaborate this
just place them in the /usr/local/nagios/libexec directory and apply the correct permissions. Setup a service and command definition and let it go! As for pushing things, that definitely needs a bit more clarification as stated above.
service=httpd
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running!!!"
else
/etc/init.d/$service start
fi
I have placed this script /usr/local/nagios/libexec/ On nagios server & wants to call it from Nagios.
If I stopped httpd service on one of my Unix Box & run this script from Nagios server that service should gets start as per script.
what is the procedure is it I have to placed this script on monitored node which is being monitored by Nagios & How do I call that script from Nagios.
Can you pls. elaborate this
just place them in the /usr/local/nagios/libexec directory and apply the correct permissions. Setup a service and command definition and let it go! As for pushing things, that definitely needs a bit more clarification as stated above.
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Script Execution Via Nagios
You are hopping around quite a bit, are you still interested in windows monitoring.......? To set that script up to restart a service on a remote host follow this guide:
http://assets.nagios.com/downloads/nagi ... h_NRPE.pdf
http://assets.nagios.com/downloads/nagi ... h_NRPE.pdf