(ns riemann.campfire
  "Forwards events to Campfire"
  (:use [clojure.string :only [join]])
  (:require [clj-campfire.core :as cf]))

(defn cf-settings
  "Setup settings for campfire. Required information is your api-token, ssl connection
  true or false, and your campfire sub-domain."
  [token ssl sub-domain]
  {:api-token token, :ssl ssl, :sub-domain sub-domain})

(defn room
  "Sets up the room to send events too. Pass in the settings created with cf-settings
  and the room name"
  [settings room-name]
  (cf/room-by-name settings room-name))

(defn campfire
  "Creates an adaptor to forward events to campfire.
  TODO: write more here once the event formatting is better.
  TODO: tests
  Tested with:
  (streams
    (by [:host, :service]
      (let [camp (campfire \"token\", true, \"sub-domain\", \"room\")]
        camp)))"
  [token ssl sub-domain room-name]
  (fn [e]
   (let [string (str (join " " ["HOST:" (str (:host e)) "SERVICE:" (str (:service e)) "STATE:" (str (:state e)) "DESC:" (str (:description e))]))]
   (cf/message (room (cf-settings token ssl sub-domain) room-name) string))))

(ns riemann.campfire
  "Forwards events to Campfire"
  (:use [clojure.string :only [join]])
  (:require [clj-campfire.core :as cf]))

(defn cf-settings
  "Setup settings for campfire. Required information is your api-token, ssl connection
  true or false, and your campfire sub-domain."
  [token ssl sub-domain]
  {:api-token token, :ssl ssl, :sub-domain sub-domain})

(defn room
  "Sets up the room to send events too. Pass in the settings created with cf-settings
  and the room name"
  [settings room-name]
  (cf/room-by-name settings room-name))

(defn format_string
  [e]
  (str (join " " ["HOST:" (str (:host e)) "SERVICE:" (str (:service e)) "STATE:" (str (:state e)) "DESC:" (str (:description e))]))
  )

(defn campfire
  "Creates an adaptor to forward events to campfire.
  TODO: write more here once the event formatting is better.
  TODO: tests
  Tested with:
  (streams
    (by [:host, :service]
      (let [camp (campfire \"token\", true, \"sub-domain\", \"room\")]
        camp)))"
  [token ssl sub-domain room-name]
  (fn [e]
   (let [string (str (join " " ["HOST:" (str (:host e)) "SERVICE:" (str (:service e)) "STATE:" (str (:state e)) "DESC:" (str (:description e))]))]
   (cf/message (room (cf-settings token ssl sub-domain) room-name) string))))

Add a string formatting function
Add a string formatting function

ClodoCorp/riemann,patrickod/riemann,riemann/riemann,forter/riemann,rekhajoshm/riemann,jamtur01/riemann,hugoduncan/riemann,pradeepchhetri/riemann,eric/riemann,pyr/riemann,hugoduncan/riemann,stanislas/riemann,pyr/riemann,algernon/riemann,udoprog/riemann,mirwan/riemann,ClodoCorp/riemann,VideoAmp/riemann-1,joerayme/riemann,rhysr/riemann,topecz/riemann,lispmeister/riemann,bowlofstew/riemann,nberger/riemann,AkihiroSuda/riemann,mfournier/riemann,mfournier/riemann,yeller/riemann,lispmeister/riemann,Anvil/riemann,patrox/riemann,algernon/riemann,bwilber/riemann,yeller/riemann,irudyak/riemann,fullcontact/riemann,ClodoCorp/riemann,DasAllFolks/riemann,pharaujo/riemann,algernon/riemann,counsyl/riemann,mirwan/riemann,shokunin/riemann,patrox/riemann,bwilber/riemann,micrub/riemann,bg451/riemann,tzach/riemann,LubyRuffy/riemann,irudyak/riemann,twosigma/riemann,LubyRuffy/riemann,twosigma/riemann,timbuchwaldt/riemann,rhysr/riemann,DasAllFolks/riemann,stanislas/riemann,alq666/riemann,mbuczko/riemann,patrickod/riemann,cswaroop/riemann,patrox/riemann,zamaterian/riemann,cswaroop/riemann,udoprog/riemann,abailly/riemann,nelhage/riemann,abailly/riemann,lispmeister/riemann,robashton/riemann,patrickod/riemann,bg451/riemann,shokunin/riemann,moonranger/riemann,jeanpralo/riemann,timbuchwaldt/riemann,aphyr/riemann,yeller/riemann,mfournier/riemann,vincentbernat/riemann,fullcontact/riemann,forter/riemann,jamtur01/riemann,cswaroop/riemann,bfritz/riemann,alq666/riemann,topecz/riemann,moonranger/riemann,rhysr/riemann,udoprog/riemann,counsyl/riemann,nberger/riemann,micrub/riemann,jeanpralo/riemann,zamaterian/riemann,eric/riemann,vincentbernat/riemann,bmhatfield/riemann,twosigma/riemann,mirwan/riemann,bfritz/riemann,bowlofstew/riemann,mbuczko/riemann,rekhajoshm/riemann,robashton/riemann,tzach/riemann,riemann/riemann,hugoduncan/riemann,rekhajoshm/riemann,stanislas/riemann,pharaujo/riemann,bmhatfield/riemann,fullcontact/riemann,Anvil/riemann,joerayme/riemann,vixns/riemann,AkihiroSuda/riemann,micrub/riemann,pradeepchhetri/riemann,forter/riemann,shokunin/riemann,topecz/riemann,VideoAmp/riemann-1,tzach/riemann,aphyr/riemann,vixns/riemann,nelhage/riemann,nelhage/riemann