Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
change flag heartbeat-map
Browse files Browse the repository at this point in the history
  • Loading branch information
betorvs committed Apr 14, 2021
1 parent 4a4b127 commit 2310e00
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ spec:
filters: null
```

Using all with `--heartbeat-map`:
```
--hearbeat-map webserver01/check-nginx=heartbeat_webserver01_nginx,webserver01/all=heartbeat_webserver01_all,all/check-nginx=heartbeat_all_nginx
```
In order: should match entity/check; should match entity with any check; should match any entity with check-nginx.


## Contributing

Expand Down
23 changes: 22 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ func executeHandler(event *types.Event) error {
if err != nil {
return err
}
// match entity/check names
entity_check := fmt.Sprintf("%s/%s", event.Entity.Name, event.Check.Name)
if heartbeats[entity_check] != "" {
fmt.Printf("Pinging heartbeat %s \n", heartbeats[entity_check])
Expand All @@ -499,9 +500,29 @@ func executeHandler(event *types.Event) error {
return errPing
}
}
// use any check
entity_all := fmt.Sprintf("%s/all", event.Entity.Name)
if heartbeats[entity_all] != "" {
// ping all alerts
fmt.Printf("Pinging heartbeat %s with entity/all defined\n", heartbeats[entity_all])
errPing := pingHeartbeat(heartbeats[entity_all])
if errPing != nil {
return errPing
}
}
// use any entity
all_check := fmt.Sprintf("all/%s", event.Check.Name)
if heartbeats[all_check] != "" {
// ping all alerts
fmt.Printf("Pinging heartbeat %s with all/check defined\n", heartbeats[all_check])
errPing := pingHeartbeat(heartbeats[all_check])
if errPing != nil {
return errPing
}
}
if heartbeats["all"] != "" {
// ping all alerts
fmt.Printf("Pinging heartbeat %s without entity/check defined\n", heartbeats["all"])
fmt.Printf("Pinging heartbeat %s with all/all defined\n", heartbeats["all"])
errPing := pingHeartbeat(heartbeats["all"])
if errPing != nil {
return errPing
Expand Down

0 comments on commit 2310e00

Please sign in to comment.