Browse Source

1.增加停止脚本
2.修改日志级别、输出路径

luxueshi 3 years ago
parent
commit
69862e00ee

+ 4 - 3
src/main/java/MinitorApplication.java

@@ -26,8 +26,9 @@ public class MinitorApplication {
                 try {
                     if (errorTimes == 5 && requestTimes == 5) {
                         //钉钉群通知,报警
-                        boolean alarmResult = AlarmUtil.alarmByDingDing(ALARM_CONTENT, true, null);
-                        log.info("钉钉报警发送结果:" + alarmResult);
+//                        boolean alarmResult = AlarmUtil.alarmByDingDing(ALARM_CONTENT, true, null);
+//                        log.info("钉钉报警发送结果:" + alarmResult);
+                        log.error("发送报警");
                         errorTimes = 0;
                         requestTimes = 0;
                     } else {
@@ -51,6 +52,6 @@ public class MinitorApplication {
         // 计时器
         Timer timer = new Timer();
         // 添加执行任务(延迟 0s 执行,每 60s 执行一次)
-        timer.schedule(timerTask, 0, 60000);
+        timer.schedule(timerTask, 0, 5000);
     }
 }

+ 0 - 1
src/main/java/RequestUtil.java

@@ -11,7 +11,6 @@ public class RequestUtil {
     public static boolean requestSDK() {
         try {
             String result = HttpUtil.post(SDK_URL, REQUEST_STR);
-            log.debug("SDK接口返回:" + result);
             return JSONUtil.isJson(result);
         } catch (Exception e) {
             log.error("SDK接口调用异常", e);

+ 1 - 1
src/main/resources/log4j.properties

@@ -8,7 +8,7 @@ log4j.appender.stdout.layout.ConversionPattern=[%d{yyyy-MM-ddHH:mm:ssa}]:%p%l%m%
 log4j.logger.error=error
 log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
 log4j.appender.error.DatePattern='_'yyyy-MM-dd'.log'
-log4j.appender.error.File=E:/minitor-logs/error.log
+log4j.appender.error.File=D:/minitor-logs/error.log
 log4j.appender.error.Append=true
 log4j.appender.error.Threshold=ERROR
 log4j.appender.error.layout=org.apache.log4j.PatternLayout

+ 1 - 1
start-up.bat

@@ -1 +1 @@
-java -jar -Xms16m -Xmx32m sdk-minitor-1.0-RELEASE.jar
+javaw -jar -Xms16m -Xmx32m sdk-minitor-1.0-RELEASE.jar

+ 3 - 0
stop.bat

@@ -0,0 +1,3 @@
+set pid = wmic process where "name like '%javaw%' and commandline like '%[sdk-minitor-1.0-RELEASE]%' " get processid
+echo pid
+taskkill -F /pid %pid%