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

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
benningtonr
Posts: 524
Joined: Tue May 22, 2012 2:16 pm

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

Post 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.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

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

Post 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...
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
benningtonr
Posts: 524
Joined: Tue May 22, 2012 2:16 pm

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

Post 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.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

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

Post 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.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

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

Post 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.
Former Nagios employee
benningtonr
Posts: 524
Joined: Tue May 22, 2012 2:16 pm

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

Post 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
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

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

Post 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.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
benningtonr
Posts: 524
Joined: Tue May 22, 2012 2:16 pm

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

Post 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
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

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

Post 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
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked