kanshi 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +23 -3
- data/bin/kanshi +9 -1
- data/lib/kanshi.rb +1 -1
- data/lib/kanshi/scrolls_reporter.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
## Purpose
|
4
4
|
|
5
5
|
Kanshi watches your Postgres database and reports metrics to the log
|
6
|
-
stream. You can then drain this log to an application
|
7
|
-
|
8
|
-
|
6
|
+
stream. You can then drain this log to an application (or provide your
|
7
|
+
own reporter class) to send these metrics to a service, like Librato or
|
8
|
+
Splunk.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -37,6 +37,26 @@ of your choosing, e.g. monitor specific databases or provide your own
|
|
37
37
|
reporter for output. An easy way to do this would be to create a Rake
|
38
38
|
task to run Kanshi.
|
39
39
|
|
40
|
+
## Configuration
|
41
|
+
|
42
|
+
If using the `kanshi` binary, configuration is optional but is done
|
43
|
+
through environment variables:
|
44
|
+
|
45
|
+
* Kanshi will monitor all `postgres://` URLs in your environment.
|
46
|
+
* `KANSHI_SAMPLE_DELAY` will change how often Kanshi monitors your
|
47
|
+
database in seconds. Default: 300
|
48
|
+
* `KANSHI_PREFIX` will change the prefix used on metrics. Default:
|
49
|
+
`kanshi`
|
50
|
+
|
51
|
+
Environment variables have no effect on the Kanshi library code, so if
|
52
|
+
executing Kanshi manually, configuration is done via the options hash
|
53
|
+
passed to `Kanshi.run`:
|
54
|
+
|
55
|
+
* `:databases`: A hash of database names to URLs ({String => String})
|
56
|
+
* `:delay`: The delay between samples (Fixnum). Default: 300.
|
57
|
+
* `:reporter`: A Class that responds to `#report` to recieve metrics
|
58
|
+
(Class). Default: `Kanshi::ScrollsReporter`.
|
59
|
+
|
40
60
|
## Name
|
41
61
|
|
42
62
|
Kanshi (監視) is Japanese for _surveillance_.
|
data/bin/kanshi
CHANGED
@@ -4,7 +4,15 @@ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
|
4
4
|
|
5
5
|
require 'kanshi'
|
6
6
|
|
7
|
+
databases = ENV.select { |k, v| v =~ %r{^postgres://} }.invert.invert
|
8
|
+
prefix = ENV['KANSHI_PREFIX'] || 'kanshi'
|
9
|
+
unless prefix.empty?
|
10
|
+
databases.keys.each do |db|
|
11
|
+
databases["#{prefix}.#{db}"] = databases.delete(db)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
Kanshi.run(
|
8
|
-
:databases =>
|
16
|
+
:databases => databases,
|
9
17
|
:delay => (ENV['KANSHI_SAMPLE_DELAY'] || 300).to_i
|
10
18
|
)
|
data/lib/kanshi.rb
CHANGED
@@ -11,7 +11,7 @@ class Kanshi::ScrollsReporter
|
|
11
11
|
def report(name, url, data)
|
12
12
|
data = calculate_hit_rate(record_and_diff(name, data))
|
13
13
|
if data
|
14
|
-
Scrolls.context(:app =>
|
14
|
+
Scrolls.context(:app => name, :measure => true) do
|
15
15
|
data.each do |k, v|
|
16
16
|
Scrolls.log(:at => k, :last => v)
|
17
17
|
end
|