@@ -51,28 +51,41 @@ Alert script file can be edited from scouter client ui or directly in scouter se
51
51
* alert when ```GcTime``` is over than 2 sec
52
52
```java
53
53
// void process(RealCounter $counter, PluginHelper $$)
54
+ //################ widget chart url setting ####################
55
+ String counterName = "TPS";
54
56
String objType = $counter.objType();
55
57
String objName = $counter.objName();
56
58
57
- String widgetUrl = "http://127.0.0.1:6180/widget/simple/counter.html?source="
59
+ java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyyMMdd");
60
+ long now = System.currentTimeMillis();
61
+ String today = dateFormat.format(new java.util.Date(now));
62
+ String yesterday = dateFormat.format(new java.util.Date(now-24*60*60*1000));
58
63
59
- String counterApi5Min = "TPS/ofType/" + objType;
60
- counterApi5Min += "?startTimeMillis=" + (System.currentTimeMillis()-300*1000);
61
- counterApi5Min += "?endTimeMillis=" + System.currentTimeMillis();
64
+ String widgetUrl = "http://127.0.0.1:6180/widget/simple/counter.html?source=";
62
65
63
- String counterApiLatest5Min = "TPS/latest/300/ofType" + objType;
66
+ String counterApi = counterName + "/ofType/" + objType;
67
+ counterApi += "?startTimeMillis=" + (now-600*1000L);
68
+ counterApi += "&endTimeMillis=" + now;
69
+
70
+ String counterApiLatest = counterName + "/latest/600/ofType/" + objType;
71
+
72
+ String statApi = "stat/" + counterName + "/ofType/" + objType;
73
+ statApi += "?startYmd=" + yesterday;
74
+ statApi += "&endYmd=" + today;
75
+ //##############################################################
64
76
65
77
int gcTime = $counter.intValue();
66
78
if(gcTime > 2000) {
67
- String message = "gc time:" + respTime + "ms";
68
-
69
- message = "\n [Check TPS]\n ";
70
- message += widgetUrl + java.net.UrlEncoder.encode(counterApi5Min) + "\n ";
79
+ String message = "gc time:" + respTime + "ms\n ";
71
80
72
- message += "[Current 5 min TPS]\n ";
73
- message += widgetUrl + java.net.UrlEncoder.encode(counterApiLatest5Min) + "\n ";
81
+ message = "[On-time chart]\n ";
82
+ message += widgetUrl + java.net.URLEncoder.encode(counterApi) + "\n ";
83
+ message += "[Current chart]\n ";
84
+ message += widgetUrl + java.net.URLEncoder.encode(counterApiLatest) + "\n ";
85
+ message += "[Daily chart]\n ";
86
+ message += widgetUrl + java.net.URLEncoder.encode(statApi) + "\n ";
74
87
75
- $counter.fatal("gc time fatal", message);
88
+ $counter.fatal("gc time fatal", message);
76
89
}
77
90
```
78
91
* sample2 (**Elasped90%.alert**)
0 commit comments