simple clojure-based http monitoring tool
(simple clojure-based http monitoring tool)
Clone the project to your target machine git clone https://github.com/SupplyFrame/grunf
Install leiningen if you don't have it on your target machine. you can either
sudo apt-get install leiningen
/usr/local/bin
), then chmod 755 ~/usr/local/bin/lein
.In the grunf source code directory, run lein deps
to install all the dependency libraries.
Checkout graphite setup guide on our wiki!
read config file and log in console.
lein run --log-level info --config conf.example.clj
Send events to graphite
lein run --config conf.example.clj --graphite-host localhost
Log in file logs/foo.log
. Note lein trampoline
let you send lein process to background without pausing the program.
mkdir logs
lein trampoline run --log logs/foo.log -c conf.example.clj &
tail -f logs/foo.log
Read smtp config, will send mails when receive error
lein run -c conf.example.clj -s smtp.example.clj
export csv in logs/bar.csv
lein run -c conf.example.clj --csv logs/bar.csv
The command line options for grunf are:
Usage:
Switches Default Desc
-------- ------- ----
-c, --config Path to the config file
--log log path for log4j. If not specified, log to console
--log-level debug log level for log4j, (fatal|error|warn|info|debug)
--graphite-host Graphite server host
--graphite-port 2003 Graphite server port
--hostname 127.0.0.1 This server's hostname
--csv csv log path
--interval 60000 Default interval for each url request
--user-agent Grunf Default user agent string
--timeout 6000 Default timeout per request
-s, --smtp-config Path to smtp config file
-h, --no-help, --help false Print this message
The configuration file format for conf.example.clj
is
[{:url "http://www.yahoo.com/"
:interval 1000 ;; optional
:validator #(re-find #"yahoo" %) ;; optional
:http-options {:timeout 2000 ;; :http-options itself is also optional
:user-agent "Mozilla"}
:graphite-ns "com.yahoo.www" ;; defualt to reverse domain name
}
{:url "http://www.google.com/?search=abc"
:name "search" ;; append to graphite namespace
;; in this case it would be
;; "com.google.www.search"
} ;; only url is required
]
The smtp configuration file for smtp.example.clj
is
^{:host "smtp.gmail.com"
:user "example@gmail.com"
:pass "password"
:port 1234
:tls true
}
{:from "sysalerts@example.com"
:to ["user1@gmail.com" "user2@gmail.com"]
:subject "Will be overwirtten by grunf!"
:body "Will be overwritten by grunf!"
}
For full documentaion of SMTP setup, please visit postal -- internet email library for clojure.
The CSV fields are
HH:MM:ss,SSS,*log type*,*http status*,*url*,*response time (milliseconds)*
This tool is still in experimental status, but all the example configs should work just fine.
Refactor to make it testable (and more funtional idiomatic).
Tutorial of writing verification in configuration file.
Distributed under the Eclipse Public License, the same as Clojure.