Skip to content

Instantly share code, notes, and snippets.

@longdongjohn
Last active February 29, 2016 05:26
Show Gist options
  • Save longdongjohn/04c28489ea9f129e8865 to your computer and use it in GitHub Desktop.
Save longdongjohn/04c28489ea9f129e8865 to your computer and use it in GitHub Desktop.
(streams
(where (state "expired")
(do (fn [e] (let [new-event (assoc e :stat stat)]
(def rt (sh "ansible-playbook" "--private-key" "/home/ec2-user/ansib/keys/54.88.127.179.pem" "-i" "/home/ec2-user/ansib/inventory-54.88.127.179" "/home/ec2-user/ansib/playbook/test3.yml"))
(def qw (get rt :out))
(reset! colstat (nth (re-find #"(\"msg\"): (\"(\d+)\")" qw) 3))
(reset! stat (get rt :exit))
(if (and (= @stat 0) (= @colstat "1")) (prn :yup)
(prn :nope))
(if (and (= @stat 0) (= @colstat "1")) (rollup 1 1800 (email-ch "[email protected]"))
(prn :some))
(if (= @stat 3) (host-down e)
(do
(prn :host-is-up) (rollup 1 1800 (email-ch "[email protected]"))))
(reset! ch-w (get rt :out))
; (call-rescue new-event children)
)))
))
;Basically if the remote host is down.. stat=3 else it is 0... if collectd instance is down colstat=1 else 2..the ansible playbook just checks that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment