Hello,
I have installed Nagios XI as a VM which is the lastest centos version for a vm. Don't know what version that is but latest.
We are checking out Nagios since a vendor can not seem to fix tomcat service on one of our critical servers. We need a way to monitor the cpu on a windows 2008 server and it goes above 90 or 95 percent then it automatically restarts the tomcat service. This doesn't sound hard but putting the monitor with the execute a batch file or restart the service must be harder than it sounds. I can not figure out Nagios well enough yet to do basic things and it looks like I am going to the hardest thing.
Does anyone know how to, I am told, tell Nagios with a shell script or anything to use a monitor for CPU that reaches 90 or above to restart a specific service on a server (tomcat service)??
Please step by step since I am new to this and my linux is very rusty...........btw how do you copy a windows file to a Nagios VM?
We would wait for the vendor to fix their application that uses tomcat but that is a pending request for a year now. We are into option 2 which is why not automate the tomcat service restart rather than a person onsite having to do it when we get a high cpu email.
Thanks
If High CPU run batch file or restart service.
-
NagiosAnotherNewbie
- Posts: 2
- Joined: Thu Dec 15, 2011 3:12 pm
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: If High CPU run batch file or restart service.
You will need to get the NSClient++ installed and running on the Windows server
http://assets.nagios.com/downloads/nagi ... _Agent.pdf
Then you will want to
http://assets.nagios.com/downloads/nagi ... Client.pdf
The rest in going to need to be customized, but the basic process is laid out in this wiki:
http://www.bluemustard.org/wiki/index.p ... cesRestart
Additionally, there is a quite a bit of information covering these types of items in the Administrator Guide
http://assets.nagios.com/downloads/nagi ... nistrator/
Library
library.nagios.com/library/products/nagiosxi/
and Exchange
exchange.nagios.org/
As for hot to copy a file to a VM, if your linux is rusty, you might want to look at WinSCP, but for sure you will need to look at the permissions of any file you copy over.
http://assets.nagios.com/downloads/nagi ... _Agent.pdf
Then you will want to
http://assets.nagios.com/downloads/nagi ... Client.pdf
The rest in going to need to be customized, but the basic process is laid out in this wiki:
http://www.bluemustard.org/wiki/index.p ... cesRestart
Additionally, there is a quite a bit of information covering these types of items in the Administrator Guide
http://assets.nagios.com/downloads/nagi ... nistrator/
Library
library.nagios.com/library/products/nagiosxi/
and Exchange
exchange.nagios.org/
As for hot to copy a file to a VM, if your linux is rusty, you might want to look at WinSCP, but for sure you will need to look at the permissions of any file you copy over.
Re: If High CPU run batch file or restart service.
You will have to create an event handler, which will get triggered when the CPU load goes above 90-95%. Here is a document on Nagios XI Global Event Handlers:
http://assets.nagios.com/downloads/nagi ... ndlers.pdf
"Global" event handlers are run for all hosts and services - you will need a "service specific" event handler.
Once you are monitoring Windows 2008 server, I would assume you are using the NSClient++. You can have NSClient++ execute a batch file by using NRPE, ie:
and on the nagios side have the "command" be:
On your second questions, you can transfer files between Windows and VM by using any File Transfer Protocol software, for example, Filezilla.
Hope this helps.
http://assets.nagios.com/downloads/nagi ... ndlers.pdf
"Global" event handlers are run for all hosts and services - you will need a "service specific" event handler.
Once you are monitoring Windows 2008 server, I would assume you are using the NSClient++. You can have NSClient++ execute a batch file by using NRPE, ie:
Code: Select all
[NRPE Handlers]
...
run_my_script=c:\myscript.batCode: Select all
check_nrpe ... -c run_my_scriptHope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
NagiosAnotherNewbie
- Posts: 2
- Joined: Thu Dec 15, 2011 3:12 pm
Re: If High CPU run batch file or restart service.
Thanks I will read though the material and hopefully put something together. A side note I am close to being able to do this in vcenter but for some reason it doesn't run the batch file I tell it too otherwise I could handle it there too. Working on both as a possible solution to the restart service if a condition exists. Wish there was a plugin.....
Thanks
Thanks