Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ open http://localhost:8080/seyren

#### PagerDuty
* `PAGERDUTY_DOMAIN` - The PagerDuty domain to be notified. Default: ``
* `PAGERDUTY_USERNAME` - The PagerDuty API username. Default: ``
* `PAGERDUTY_PASSWORD` - The PagerDuty API Password. Default: ``

#### Hubot
* `HUBOT_URL` - The location where Hubot is running. Default ``
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public PagerDutyNotificationService(SeyrenConfig seyrenConfig) {

@Override
public void sendNotification(Check check, Subscription subscription, List<Alert> alerts) throws NotificationFailedException {
PagerDutyClient client = createPagerDutyClient();

PagerDutyClient client = new PagerDutyClient(seyrenConfig.getPagerDutyDomain(), "username", "password");
try {
Map<String, Object> details = createNotificationDetails(check, alerts);

Expand Down Expand Up @@ -77,4 +77,19 @@ private Map<String, Object> createNotificationDetails(Check check, List<Alert> a
return details;
}

private PagerDutyClient createPagerDutyClient() {
// Awaiting merge of https://github.com/webmetrics/pagerduty-java/pull/2 to allow token auth.
// if (null != seyrenConfig.getPagerDutyToken() && !seyrenConfig.getPagerDutyToken().isEmpty()) {
// return new PagerDutyClient(seyrenConfig.getPagerDutyDomain(),
// seyrenConfig.getPagerDutyToken());
// } else {
// return new PagerDutyClient(seyrenConfig.getPagerDutyDomain(),
// seyrenConfig.getPagerDutyUsername(),
// seyrenConfig.getPagerDutyPassword());
// }
return new PagerDutyClient(seyrenConfig.getPagerDutyDomain(),
seyrenConfig.getPagerDutyUsername(),
seyrenConfig.getPagerDutyPassword());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class SeyrenConfig {
private final String graphiteUsername;
private final String graphitePassword;
private final String pagerDutyDomain;
private final String pagerDutyToken;
private final String pagerDutyUsername;
private final String pagerDutyPassword;
private final String hipChatAuthToken;
private final String hipChatUsername;
private final String hubotUrl;
Expand Down Expand Up @@ -64,6 +67,9 @@ public SeyrenConfig() {

// PagerDuty
this.pagerDutyDomain = configOrDefault("PAGERDUTY_DOMAIN", "");
this.pagerDutyToken = configOrDefault("PAGERDUTY_TOKEN", "");
this.pagerDutyUsername = configOrDefault("PAGERDUTY_USERNAME", "");
this.pagerDutyPassword = configOrDefault("PAGERDUTY_PASSWORD", "");

// Hubot
this.hubotUrl = configOrDefault(list("HUBOT_URL", "SEYREN_HUBOT_URL"), "");
Expand All @@ -81,6 +87,18 @@ public String getPagerDutyDomain() {
return pagerDutyDomain;
}

public String getPagerDutyToken() {
return pagerDutyToken;
}

public String getPagerDutyUsername() {
return pagerDutyUsername;
}

public String getPagerDutyPassword() {
return pagerDutyPassword;
}

public String getHipChatAuthToken() {
return hipChatAuthToken;
}
Expand Down