Last active
February 26, 2016 08:58
-
-
Save longdongjohn/2b274f1b6d786ce07373 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
(include "globals.clj") | |
(def c-subj (atom "")) | |
(def temp1 (atom 0)) | |
(def m1_flag (atom "")) | |
(def m2_flag (atom "")) | |
(def temp3 (atom 0)) | |
(def flag (atom 0)) | |
(def temp2 (atom 0)) | |
(def email-c (mailer {:host "smtp.gmail.com" | |
:port 587 | |
:user "[email protected]" | |
:pass "pwd" | |
:tls "true" | |
:subject (fn [events](str "Cpu Threshold reached")) | |
:body (fn [eve](apply str @temp3 "Host " (get-in (first events) [:host]))) | |
:from "[email protected]"})) | |
(defn user [& children] | |
(fn [e] (let [new-event (assoc e :warning "warning-limit-file")] | |
(reset! temp1 (get e :metric)) | |
(reset! m1_flag 1) | |
))) | |
(defn system [& children] | |
(fn [e] (let [new-event (assoc e :warning "warning-limit-file")] | |
(reset! temp2 (get e :metric)) | |
(reset! m2_flag 1) | |
))) | |
(defn gt [& children] | |
(fn [e] | |
(reset! c-subj (str (get e :host))) | |
(rollup 1 180 ((email-c "[email protected]") e)) | |
)) | |
(streams | |
(by [:host :time] | |
(where (service #"aggregation-cpu-sum/cpu-user") | |
(user) | |
) | |
(where | |
(service #"aggregation-cpu-sum/cpu-system") | |
(system) | |
) | |
(where (and (= 1 @m2_flag) (= 1 @m1_flag) (false? (= @temp3 0))); | |
(reset! temp3 (+ @temp1 @temp2)) | |
(reset! m2_flag 0) | |
(reset! m1_flag 0) | |
(if (< @temp3 cpu_threshold) (fn [& children] (prn @temp3)) | |
(rollup 1 1800 (email-c "[email protected]"))) | |
)))) |
pyr
commented
Feb 26, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment