2

我一直在寻找,但找不到一个免费/开源的 tomcat 7 监控工具,它会在某些情况发生时发送电子邮件或通知。例如,当 CPU 利用率达到峰值或 RAM 一直满时。像这样的东西。

我看过 JMelody 和 Psi-Probe,但它们都没有在发生某些事件时发送电子邮件的能力。

4

2 回答 2

2

你可以看看jboss RHQ

https://docs.jboss.org/author/display/RHQ/Alerts

于 2013-07-03T19:36:54.833 回答
1

这可能会帮助某人!

如果不想使用任何监控工具,请使用 mailutils 包在 Ubuntu 服务器中设置电子邮件配置。

https://rianjs.net/2013/08/send-email-from-linux-server-using-gmail-and-ubuntu-two-factor-authentication

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04

要监控 Tomcat 状态,您可以使用以下脚本并根据您的需要设置每分钟/小时/天运行的 cron 作业。

#!/bin/bash

TOMCAT_HOME=/opt/tomcat
PUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`
EMAIL_BODY="Hi Admin,\n\n$PUBLIC_IP Tomcat is down at $(date -d "+330 minutes" +"%Y-%m-%d %T") IST, Please take necessary action.\n\n\nDo not reply to this email as it is auto generated by Ubuntu system\n"

tomcat_pid() {
  echo `ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'`
}

start() {
  pid=$(tomcat_pid)
  if [ -n "$pid" ] 
  then
    echo "Tomcat is already running (pid: $pid)"
  else
    # Start tomcat
    echo "Starting tomcat"
    /bin/sh $TOMCAT_HOME/bin/startup.sh
  fi


  return 0
}

pid=$(tomcat_pid)

 if [ -n "$pid" ]
  then
    echo "Tomcat is running with pid: $pid"
    #stop
  else
    echo "Tomcat is not running"
    # send an email alert then start
    echo -e $EMAIL_BODY | mail -s "$PUBLIC_IP Tomcat is down" user@email.com
    echo "Mail sent"
    #remove cache and release memory occupied by heavy processes
    start
  fi
exit 0
于 2018-07-17T10:47:13.583 回答