Script Execution Via Nagios

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
lafargeuser
Posts: 341
Joined: Thu Sep 27, 2012 12:23 am

Script Execution Via Nagios

Post by lafargeuser »

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.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Script Execution Via Nagios

Post by sreinhardt »

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

Post by lafargeuser »

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

Post by slansing »

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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Script Execution Via Nagios

Post by tmcdonald »

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

Post by lafargeuser »

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

Post by slansing »

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

Post by lafargeuser »

How Do I do that for Windows hosts ?

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

Post by lafargeuser »

#!/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.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Script Execution Via Nagios

Post by slansing »

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
Locked