NagiosXI 2024R1
Running on RHEL 7.9
Full install onto VM, not Nagios image.
I have a couple system running tomcat with an app. Use an http check to see if tomcat it responding. I would like to restart tomcat but since it's using the check_http check, when I try to setup a event handler for restart, it wants to restart http, but I need to restart tomcat. I've done some searching but can't find what I am looking for. Any advice or point to a thread in the forum will be greatly appreciate.
Thanks
Mitch
How to setup event handler from a check_http that needs to restart tomcat, not apache
-
- Posts: 190
- Joined: Thu Oct 30, 2014 8:04 am
- Location: Indiana
- Contact:
How to setup event handler from a check_http that needs to restart tomcat, not apache
Last edited by GhostRider2110 on Tue Jan 16, 2024 1:40 pm, edited 1 time in total.
Re: How to setup event handler from a check_http that needs to restart tomcat, not apache
Hi Mitch, thanks for reaching out.
This one is going to be highly dependent on how your service is configured. Event handlers are attached to a service definition, so the first step for you is to make sure that your Tomcat monitoring is happening through a different service that your other HTTP checks (i.e. you should have a separate service definition for these hosts, rather than attaching your service to a hostgroup or some other bulk configuration technique).
The second thing you'll need is a command that implements your "restart-tomcat" event handler. On most systems you'll literally have a init.d or systemd service called "tomcat", but the last time I looked at JVM environments, it looked like most system administrators would write their own service file.
Once you have the service you want and the command that you want, you can just go to Configuration -> Core Config Manager -> Services -> Edit (wrench icon). Then go to the Check Settings tab and change the "Event Handler" and "Event Handler Enabled" settings.
Hopefully that helps - feel free to follow up if you get stuck or if you have any other questions or concerns.
-Sebastian
This one is going to be highly dependent on how your service is configured. Event handlers are attached to a service definition, so the first step for you is to make sure that your Tomcat monitoring is happening through a different service that your other HTTP checks (i.e. you should have a separate service definition for these hosts, rather than attaching your service to a hostgroup or some other bulk configuration technique).
The second thing you'll need is a command that implements your "restart-tomcat" event handler. On most systems you'll literally have a init.d or systemd service called "tomcat", but the last time I looked at JVM environments, it looked like most system administrators would write their own service file.
Once you have the service you want and the command that you want, you can just go to Configuration -> Core Config Manager -> Services -> Edit (wrench icon). Then go to the Check Settings tab and change the "Event Handler" and "Event Handler Enabled" settings.
Hopefully that helps - feel free to follow up if you get stuck or if you have any other questions or concerns.
-Sebastian
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy
-
- Posts: 190
- Joined: Thu Oct 30, 2014 8:04 am
- Location: Indiana
- Contact:
Re: How to setup event handler from a check_http that needs to restart tomcat, not apache
Thanks Sebastian,
I'll have to see what I can do. The tomcat "service" is still running and I am not sure how I can get an alert to the webapp not responding without using the check_http. If anyone can think of something I would greatly appreciate it.
Mitch
I'll have to see what I can do. The tomcat "service" is still running and I am not sure how I can get an alert to the webapp not responding without using the check_http. If anyone can think of something I would greatly appreciate it.
Mitch
Re: How to setup event handler from a check_http that needs to restart tomcat, not apache
Hi @GhostRider2110,
I believe what Sebastian is saying is that you can use the service you already have setup that uses check_http, and attach an event handler (script) to restart Tomcat. He just wants to make sure you are applying it at the lowest level, so it doesn't affect any hostgroup or bulk configurations you may have.
Here is the step by step documentation Introduction to Event Handlers in Nagios XI. The section where it has you setup a dummy host, can be replaced by selecting the service you already have setup, clicking the Check Settings tab and assigning the event handler you created.
You may also want to checkout Restarting Linux Services with NCPA.
I believe what Sebastian is saying is that you can use the service you already have setup that uses check_http, and attach an event handler (script) to restart Tomcat. He just wants to make sure you are applying it at the lowest level, so it doesn't affect any hostgroup or bulk configurations you may have.
Here is the step by step documentation Introduction to Event Handlers in Nagios XI. The section where it has you setup a dummy host, can be replaced by selecting the service you already have setup, clicking the Check Settings tab and assigning the event handler you created.
You may also want to checkout Restarting Linux Services with NCPA.
Please let us know if you have any other questions or concerns.
-Laura
-Laura
-
- Posts: 190
- Joined: Thu Oct 30, 2014 8:04 am
- Location: Indiana
- Contact:
Re: How to setup event handler from a check_http that needs to restart tomcat, not apache
Thanks Laura,
It's been a while since I went though the even handler docs. I'll double check to..
Mitch
It's been a while since I went though the even handler docs. I'll double check to..
Mitch
-
- Posts: 190
- Joined: Thu Oct 30, 2014 8:04 am
- Location: Indiana
- Contact:
Re: How to setup event handler from a check_http that needs to restart tomcat, not apache
Thanks for the direction and help. Got what I needed working.
Crated my own restart script on the client and setup the event handler that way. All is good.
Thanks again
Mitch
Crated my own restart script on the client and setup the event handler that way. All is good.
Thanks again
Mitch
Re: How to setup event handler from a check_http that needs to restart tomcat, not apache
Thats great to hear @GhostRider2110. If you feel like sharing what you've created, or looking into other event handlers that others have created feel free to check the exchange.
https://exchange.nagios.org/
https://exchange.nagios.org/