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 0aac148 + 5dac969 commit 88fee54
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\_email\_send_alert_** : Email 발송 여부 (true / false) - 기본 값은 false
Expand Down Expand Up @@ -38,7 +39,7 @@ [email protected],[email protected]
[email protected]
```

### dependencies
### Dependencies
* Project
- scouter.common
- scouter.server
Expand Down
47 changes: 24 additions & 23 deletions src/scouter/plugin/server/alert/email/EmailPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,34 +138,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 88fee54

Please sign in to comment.