Last active
August 29, 2015 14:22
-
-
Save jamtur01/b68af37bbddf7b34fc56 to your computer and use it in GitHub Desktop.
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
(alert "email" [ "[email protected]" "[email protected]" ]) |
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
(def header "Monitoring alert from Riemann\n\n") | |
(def footer "This is an automated Riemann notification. Please do not reply.") | |
(defn format-subject | |
"Format the email subject" | |
[events] | |
(apply format "Alert for service %s on host %s" (clojure.string/join ", " (map :service events)) (map :host events)) | |
) | |
(defn format-body | |
"Format the email body" | |
[events] | |
(apply str header "Host: " (get-in (first events) [:host]) "\nService: " (get-in (first events) [:service]) "\nTime: " (riemann.common/time-at (get-in (first events) [:time])) "\nService state is " (get-in (first events) [:state]) "\n\n" footer)) | |
(def email (mailer {:from "[email protected]" | |
:subject (fn [events] (format-subject events)) | |
:body (fn [events] (format-body events)) | |
})) | |
(defn alert | |
"Generic alert processor" | |
[destination & recipients] | |
(condp = destination | |
"email" (email (apply str recipients)) | |
#(info "Invalid alert destination" destination "specified for event:" %)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment