Skip to content

Commit

Permalink
Merge pull request #4 from nices96/master
Browse files Browse the repository at this point in the history
Add feature to alert in case of agent reconnected.
  • Loading branch information
nices96 committed Apr 5, 2016
2 parents 546bb35 + 9fdb79e commit babef81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- Agent의 Memory (warning / fatal)
- Agent의 Disk (warning / fatal)
- 신규 Agent 연결
- Agent의 연결 해제 (연결 해제된 Agent의 재접속은 Scouter Server 내부 이슈로 지연)
- Agent의 연결 해제
- Agent의 재접속

### Properties (스카우터 서버 설치 경로 하위의 conf/scouter.conf)
* **_ext\_plugin\_telegram\_send\_alert_** : Telegram 메시지 발송 여부 (true / false) - 기본 값은 false
Expand All @@ -26,7 +27,7 @@ ext_plugin_telegram_bot_token=185780011:AAGVaPyWCoZ8y1mHZEK1jFmbLwpcjlsJoJY
ext_plugin_telegram_chat_id=@ScouterDemoChannel
```

### dependencies
### Dependencies
* Project
- scouter.common
- scouter.server
Expand Down
47 changes: 24 additions & 23 deletions src/scouter/plugin/server/alert/telegram/TelegramPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,34 +128,35 @@ public void run() {

@ServerPlugin(PluginConstants.PLUGIN_SERVER_OBJECT)
public void object(ObjectPack pack) {
if (pack.version != null && pack.version.length() > 0) {
AlertPack p = null;
if (pack.wakeup == 0L) {
if (pack.version != null && pack.version.length() > 0) {
AlertPack ap = null;
ObjectPack op = AgentManager.getAgent(pack.objHash);

if (op == null && pack.wakeup == 0L) {
// in case of new agent connected
p = new AlertPack();
p.level = AlertLevel.INFO;
p.objHash = pack.objHash;
p.title = "An object has been activated.";
p.message = pack.objName + " is connected.";
p.time = System.currentTimeMillis();
p.objType = "scouter";
ap = new AlertPack();
ap.level = AlertLevel.INFO;
ap.objHash = pack.objHash;
ap.title = "An object has been activated.";
ap.message = pack.objName + " is connected.";
ap.time = System.currentTimeMillis();
ap.objType = "scouter";

alert(p);
} else if (pack.alive == false) {
alert(ap);
} else if (op.alive == false) {
// in case of agent reconnected
p = new AlertPack();
p.level = AlertLevel.INFO;
p.objHash = pack.objHash;
p.title = "An object has been activated.";
p.message = pack.objName + " is reconnected.";
p.time = System.currentTimeMillis();
p.objType = "scouter";
ap = new AlertPack();
ap.level = AlertLevel.INFO;
ap.objHash = pack.objHash;
ap.title = "An object has been activated.";
ap.message = pack.objName + " is reconnected.";
ap.time = System.currentTimeMillis();
ap.objType = "scouter";

alert(p);
}

alert(ap);
}
// inactive state can be handled in alert() method.
}
}
}

private void println(Object o) {
Expand Down

0 comments on commit babef81

Please sign in to comment.