-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from ernestio/rds
monitoring rds instance and cluster messages
- Loading branch information
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package main | ||
|
||
type RDSCluster struct { | ||
} | ||
|
||
func (n *RDSCluster) Handle(subject string, components []interface{}, lines []Message) []Message { | ||
switch subject { | ||
case "rds_clusters.create": | ||
lines = append(lines, Message{Body: "Creating rds clusters:", Level: "INFO"}) | ||
case "rds_clusters.create.done": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS clusters created", Level: "INFO"}) | ||
case "rds_clusters.create.error": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS clusters creation failed", Level: "INFO"}) | ||
case "rds_clusters.update": | ||
lines = append(lines, Message{Body: "Updating rds clusters:", Level: "INFO"}) | ||
case "rds_clusters.update.done": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS clusters modified", Level: "INFO"}) | ||
case "rds_clusters.update.error": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS clusters modification failed", Level: "INFO"}) | ||
case "rds_clusters.delete": | ||
return append(lines, Message{Body: "Deleting rds clusters:", Level: "INFO"}) | ||
case "rds_clusters.delete.done": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS clusters deleted", Level: "INFO"}) | ||
case "rds_clusters.delete.error": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS clusters deletion failed", Level: "INFO"}) | ||
} | ||
return lines | ||
} | ||
|
||
func (n *RDSCluster) getDetails(components []interface{}) (lines []Message) { | ||
for _, v := range components { | ||
r := v.(map[string]interface{}) | ||
name, _ := r["name"].(string) | ||
engine, _ := r["engine"].(string) | ||
endpoint, _ := r["endpoint"].(string) | ||
status, _ := r["status"].(string) | ||
lines = append(lines, Message{Body: " - " + name, Level: ""}) | ||
lines = append(lines, Message{Body: " Engine : " + engine, Level: ""}) | ||
lines = append(lines, Message{Body: " Endpoint : " + endpoint, Level: ""}) | ||
if status == "errored" { | ||
err, _ := r["error"].(string) | ||
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"}) | ||
} | ||
} | ||
|
||
return lines | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package main | ||
|
||
type RDSInstance struct { | ||
} | ||
|
||
func (n *RDSInstance) Handle(subject string, components []interface{}, lines []Message) []Message { | ||
switch subject { | ||
case "rds_instances.create": | ||
lines = append(lines, Message{Body: "Creating rds instances:", Level: "INFO"}) | ||
case "rds_instances.create.done": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS instances created", Level: "INFO"}) | ||
case "rds_instances.create.error": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS instances creation failed", Level: "INFO"}) | ||
case "rds_instances.update": | ||
lines = append(lines, Message{Body: "Updating rds instances:", Level: "INFO"}) | ||
case "rds_instances.update.done": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS instances modified", Level: "INFO"}) | ||
case "rds_instances.update.error": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS instances modification failed", Level: "INFO"}) | ||
case "rds_instances.delete": | ||
return append(lines, Message{Body: "Deleting rds instances:", Level: "INFO"}) | ||
case "rds_instances.delete.done": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS instances deleted", Level: "INFO"}) | ||
case "rds_instances.delete.error": | ||
lines = n.getDetails(components) | ||
return append(lines, Message{Body: "RDS instances deletion failed", Level: "INFO"}) | ||
} | ||
return lines | ||
} | ||
|
||
func (n *RDSInstance) getDetails(components []interface{}) (lines []Message) { | ||
for _, v := range components { | ||
r := v.(map[string]interface{}) | ||
name, _ := r["name"].(string) | ||
engine, _ := r["engine"].(string) | ||
cluster, _ := r["cluster"].(string) | ||
endpoint, _ := r["endpoint"].(string) | ||
status, _ := r["status"].(string) | ||
lines = append(lines, Message{Body: " - " + name, Level: ""}) | ||
lines = append(lines, Message{Body: " Engine : " + engine, Level: ""}) | ||
lines = append(lines, Message{Body: " Cluster : " + cluster, Level: ""}) | ||
lines = append(lines, Message{Body: " Endpoint : " + endpoint, Level: ""}) | ||
if status == "errored" { | ||
err, _ := r["error"].(string) | ||
lines = append(lines, Message{Body: " Error : " + err, Level: "ERROR"}) | ||
} | ||
} | ||
|
||
return lines | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters