Browse Source

1.报警提示,增加服务器ip

luxueshi 3 years ago
parent
commit
61845d2f81
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/main/java/MinitorApplication.java

+ 6 - 1
src/main/java/MinitorApplication.java

@@ -1,5 +1,6 @@
 import org.apache.log4j.Logger;
 
+import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Timer;
@@ -27,11 +28,15 @@ public class MinitorApplication {
             public void run() {
                 try {
                     log.info("---调度监控程序---");
+
+
                     if (errorTimes == 5 && requestTimes == 5) {
                         //钉钉群通知,报警
+                        InetAddress address = InetAddress.getLocalHost();
+                        String hostAddress = address.getHostAddress();
                         List<String> mobileList = new ArrayList<>();
                         mobileList.add(SDK_ADMIN_PHONE);
-                        boolean alarmResult = AlarmUtil.alarmByDingDing(ALARM_CONTENT, false, mobileList);
+                        boolean alarmResult = AlarmUtil.alarmByDingDing(ALARM_CONTENT + "\n服务器ip:"+hostAddress, false, mobileList);
                         log.info("钉钉报警发送结果:" + alarmResult);
                         errorTimes = 0;
                         requestTimes = 0;