我有一个在Tomcat上运行的Web应用程序,并希望有一个自动的方式监视应用程序,以确保它正在运行,如果不启动/重新启动tomcat(并发送电子邮件警报)。 我想做的不仅仅是检查Tomcat是否正在运行,并确保可以加载应用程序的默认页面。
除了编写shell脚本并将其作为cron作业运行之外,是否有任何工具可以做到这一点?
请查看Monit实用程序 。
这是一个守护进程和进程监视工具,可以提供您可能需要的警报和已定义的操作。
一个简单的例子:
check process tomcat with pidfile "/var/run/tomcat/tomcat.pid" start program = "/usr/local/tomcat/bin/startup.sh" as uid tomcat gid tomcat stop program = "/usr/local/tomcat/bin/shutdown.sh" as uid tomcat gid tomcat if failed port 8080 then alert if failed port 8080 for 5 cycles then restart