Skip to content

Commit e0a2068

Browse files
committed
initial documentation
1 parent dc883b2 commit e0a2068

File tree

6 files changed

+134
-33
lines changed

6 files changed

+134
-33
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
hs_err_pid*
1313

1414
*.iml
15+
/target

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,54 @@
11
# scouter-plugin-server-alert-line
2-
Scouter plugin for alerting to Line messenger.
2+
![Englsh](https://img.shields.io/badge/language-English-red.svg) [![Korean](https://img.shields.io/badge/language-Korean-blue.svg)](README_kr.md)
3+
4+
### Scouter server plugin to send a alert via line
5+
6+
- This plug-in sends alert messages generated from the server to the line messenger specific group or chat room.
7+
- Currently supported types of Alert are as follows
8+
- All alert occurred from agents.
9+
- on exceeding CPU threshold of Host agent(warning / fatal)
10+
- on exceeding Memory threshold of Host agent (warning / fatal)
11+
- on exceeding Disk usage threshold of Host agent (warning / fatal)
12+
- agent's connection
13+
- agent's disconnection
14+
- agent's reconnection
15+
- on exceeding service response time
16+
- ...
17+
18+
### Properties (conf/scouter.conf)
19+
* **_ext\_plugin\_line\_send\_alert_** : use alert to a line messenger feature or not (true / false) - default false
20+
* **_ext\_plugin\_line\_debug_** : debug logging option - default false
21+
* **_ext\_plugin\_line\_level_** : alert level to send (0 : INFO, 1 : WARN, 2 : ERROR, 3 : FATAL) - default 0
22+
* **_ext\_plugin\_line\_access\_token_** : Line channel access token
23+
* **_ext\_plugin\_line\_group\_id_** : group id or chat room id (It should be gotten from line webhook request)
24+
25+
* Example
26+
```
27+
# External Interface (Line)
28+
ext_plugin_line_send_alert=true
29+
ext_plugin_line_debug=false
30+
ext_plugin_line_level=0
31+
ext_plugin_line_access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
32+
ext_plugin_line_group_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
33+
```
34+
35+
### Dependencies
36+
* Project
37+
- scouter.common
38+
- scouter.server
39+
* Library
40+
- commons-codec-1.9.jar
41+
- commons-logging-1.2.jar
42+
- gson-2.6.2.jar
43+
- httpclient-4.5.2.jar
44+
- httpcore-4.4.4.jar
45+
46+
### Build & Deploy
47+
* mvn clean package
48+
49+
* Deploy
50+
- copy scouter-plugin-server-alert-line-xxx.jar and all dependent libraries(exclude scouter.server and scouter.commong) to lib directory of scouter server home.
51+
52+
## Appendix
53+
##### Step by Step about notification to Line messenger #####
54+
* ?????

README_kr.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# scouter-plugin-server-alert-line
2+
[![Englsh](https://img.shields.io/badge/language-English-red.svg)](README.md) ![Korean](https://img.shields.io/badge/language-Korean-blue.svg)
3+
4+
### Scouter server plugin to send a alert via line
5+
6+
- 본 프로젝트는 스카우터 서버 플러그인으로써 서버에서 발생한 Alert 메시지를 Line으로 전송하는 역할을 한다.
7+
- 현재 지원되는 Alert의 종류는 다음과 같다.
8+
9+
- Agent의 CPU (warning / fatal)
10+
- Agent의 Memory (warning / fatal)
11+
- Agent의 Disk (warning / fatal)
12+
- 신규 Agent 연결
13+
- Agent의 연결 해제
14+
- Agent의 재접속
15+
- 특정서비스 응답시간의 임계치 초과(Java agent에서 설정)
16+
17+
### Properties (스카우터 서버 설치 경로 하위의 conf/scouter.conf)
18+
* **_ext\_plugin\_line\_send\_alert_** : Line 메시지 발송 여부 (true / false) - 기본 값은 false
19+
* **_ext\_plugin\_line\_debug_** : 로깅 여부 - 기본 값은 false
20+
* **_ext\_plugin\_line\_level_** : 수신 레벨(0 : INFO, 1 : WARN, 2 : ERROR, 3 : FATAL) - 기본 값은 0
21+
* **_ext\_plugin\_line\_access\_token_** : Line 채널 Token
22+
* **_ext\_plugin\_line\_group\_id_** : 메시지를 전송할 그룹 id 또는 채팅방 id (이 id는 Line의 webhook 호출시 request에서 확인 가능)
23+
24+
* Example
25+
```
26+
# External Interface (Line)
27+
ext_plugin_line_send_alert=true
28+
ext_plugin_line_debug=false
29+
ext_plugin_line_level=0
30+
ext_plugin_line_access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
31+
ext_plugin_line_group_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
32+
```
33+
34+
### Dependencies
35+
* Project
36+
- scouter.common
37+
- scouter.server
38+
* Library
39+
- commons-codec-1.9.jar
40+
- commons-logging-1.2.jar
41+
- gson-2.6.2.jar
42+
- httpclient-4.5.2.jar
43+
- httpcore-4.4.4.jar
44+
45+
### Build & Deploy
46+
* mvn clean package
47+
48+
* Deploy
49+
- dependency library와 함께 scouter-plugin-server-alert-line-xxx.jar 파일을 복사하여 Scouter Server 설치 경로 하위의 lib/ 폴더에 Copy 한다.
50+
51+
## Appendix
52+
##### Step by Step about notification to Line messenger #####
53+
* ?????

pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@
3939
<groupId>com.github.scouter-project</groupId>
4040
<artifactId>scouter-server</artifactId>
4141
<version>1.1.1</version>
42+
<scope>provided</scope>
4243
</dependency>
4344
<dependency>
4445
<groupId>com.github.scouter-project</groupId>
4546
<artifactId>scouter-common</artifactId>
4647
<version>1.1.1</version>
48+
<scope>provided</scope>
4749
</dependency>
4850
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
4951
<dependency>
@@ -95,4 +97,28 @@
9597
</dependency>
9698
</dependencies>
9799

100+
<build>
101+
<plugins>
102+
<plugin>
103+
<groupId>org.apache.maven.plugins</groupId>
104+
<artifactId>maven-dependency-plugin</artifactId>
105+
<executions>
106+
<execution>
107+
<id>copy-dependencies</id>
108+
<phase>prepare-package</phase>
109+
<goals>
110+
<goal>copy-dependencies</goal>
111+
</goals>
112+
<configuration>
113+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
114+
<overWriteReleases>false</overWriteReleases>
115+
<overWriteSnapshots>false</overWriteSnapshots>
116+
<overWriteIfNewer>true</overWriteIfNewer>
117+
<includeScope>runtime</includeScope>
118+
</configuration>
119+
</execution>
120+
</executions>
121+
</plugin>
122+
</plugins>
123+
</build>
98124
</project>

src/main/java/scouter/plugin/server/alert/line/LinePlugin.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,17 @@
2626
import org.apache.http.impl.client.HttpClientBuilder;
2727
import org.apache.http.util.EntityUtils;
2828
import scouter.lang.AlertLevel;
29-
import scouter.lang.TextTypes;
3029
import scouter.lang.TimeTypeEnum;
3130
import scouter.lang.counters.CounterConstants;
3231
import scouter.lang.pack.AlertPack;
3332
import scouter.lang.pack.ObjectPack;
3433
import scouter.lang.pack.PerfCounterPack;
35-
import scouter.lang.pack.XLogPack;
3634
import scouter.lang.plugin.PluginConstants;
3735
import scouter.lang.plugin.annotation.ServerPlugin;
3836
import scouter.server.Configure;
3937
import scouter.server.CounterManager;
4038
import scouter.server.Logger;
4139
import scouter.server.core.AgentManager;
42-
import scouter.server.db.TextRD;
43-
import scouter.util.DateUtil;
4440
import scouter.util.HashUtil;
4541

4642
import java.util.ArrayList;
@@ -180,33 +176,6 @@ public void object(ObjectPack pack) {
180176
// inactive state can be handled in alert() method.
181177
}
182178
}
183-
184-
@ServerPlugin(PluginConstants.PLUGIN_SERVER_XLOG)
185-
public void xlog(XLogPack pack) {
186-
try {
187-
int elapsedThreshold = conf.getInt("ext_plugin_elapsed_time_threshold", 0);
188-
189-
if (elapsedThreshold != 0 && pack.elapsed > elapsedThreshold) {
190-
String serviceName = TextRD.getString(DateUtil.yyyymmdd(pack.endTime), TextTypes.SERVICE, pack.service);
191-
192-
AlertPack ap = new AlertPack();
193-
194-
ap.level = AlertLevel.WARN;
195-
ap.objHash = pack.objHash;
196-
ap.title = "Elapsed time exceed a threshold.";
197-
ap.message = "[" + AgentManager.getAgentName(pack.objHash) + "] "
198-
+ pack.service + "(" + serviceName + ") "
199-
+ "elapsed time(" + pack.elapsed + " ms) exceed a threshold.";
200-
ap.time = System.currentTimeMillis();
201-
ap.objType = AgentManager.getAgent(pack.objHash).objType;
202-
203-
alert(ap);
204-
}
205-
206-
} catch (Exception e) {
207-
Logger.printStackTrace(e);
208-
}
209-
}
210179

211180
@ServerPlugin(PluginConstants.PLUGIN_SERVER_COUNTER)
212181
public void counter(PerfCounterPack pack) {

src/test/java/scouter/plugin/server/alert/line/LinePluginTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void alert() throws Exception {
3030
AlertPack ap = genAlertPack();
3131
plugin.alert(ap);
3232

33-
Thread.sleep(300000);
33+
Thread.sleep(10000);
3434
}
3535

3636
private static AlertPack genAlertPack() {

0 commit comments

Comments
 (0)