Page 1 of 2

I would like to run a batch file when a threshold is exceede

Posted: Fri Feb 14, 2014 4:00 pm
by benningtonr
I have a batch file that will start wireshark on a remote machine. I would like for nagios to execute said batch file when the bandwidth on a port is exceeded.

Thank for any help.

Re: I would like to run a batch file when a threshold is exc

Posted: Fri Feb 14, 2014 4:12 pm
by BanditBBS
Just to get you started before someone offers more help, you'll be using eventhandlers to do this.

How you'll do it will depend on the remote machine OS and what method you currently use to monitor, NRPE, NSCLient, etc...

Re: I would like to run a batch file when a threshold is exc

Posted: Fri Feb 14, 2014 4:19 pm
by benningtonr
the remote maching is not monitored, the bandwidth would be monitored on my brocade router.
when the router reaches 890Mbs i want to fire off the batch file which inturn start my wireshark capture.

Re: I would like to run a batch file when a threshold is exc

Posted: Fri Feb 14, 2014 4:23 pm
by BanditBBS
Well, I'm sure there are other ways to do it, but this is how I would:

Install NSClient++ on the remote machine and create a command that points to and executes that batch file.
In XI, create a command that uses nrpe to execute that command
On the BW monitoring service, set the event handler to that new command

I think that'll work :) I'm sure nagios will step in and say I'm nuts if not, LOL.

Re: I would like to run a batch file when a threshold is exc

Posted: Mon Feb 17, 2014 10:28 am
by tmcdonald
Just to add on to what Bandit said, there is no way for Nagios to execute things on a remote machine unless you install an agent that allows this.

Re: I would like to run a batch file when a threshold is exc

Posted: Tue Feb 18, 2014 7:55 am
by benningtonr
nsclient has been installed om remote machine.
A batch file has been created and put into a shared folder accesable by Nagios.
I have created a command that I think will execute the batch file on the remote machine.

I am now stuck on how to:
1. make the command visable under the event Handler pull down.
2. execute the command

Re: I would like to run a batch file when a threshold is exc

Posted: Tue Feb 18, 2014 8:07 am
by BanditBBS
1.) Edit the command and set it to "Misc Command" instead of check
2.) It should kick off once the port floods. You can test from the command line of the nagios server using the check_nrpe command.

Re: I would like to run a batch file when a threshold is exc

Posted: Tue Feb 18, 2014 8:58 am
by benningtonr
okay, i see that the command is now available, question:
1. How will i know that it is running.
2. will it attempt to run it everytime
3. if so how do I get it to run only once?

Thanks

Re: I would like to run a batch file when a threshold is exc

Posted: Tue Feb 18, 2014 9:01 am
by BanditBBS
1.) You wont really
2.) Depends on your coding of the batch file
3.) Here is some help http://nagios.sourceforge.net/docs/3_0/ ... dlers.html

Re: I would like to run a batch file when a threshold is exc

Posted: Tue Feb 18, 2014 10:49 am
by abrist
benningtonr wrote:1. How will i know that it is running.
BanditBBS wrote:1.) You wont really
You may want to add a line to your script/batch file to write a line to a text file. This will let you know if it runs.