monittr 0.0.3 → 0.0.4
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.markdown +12 -21
- data/lib/monittr.rb +2 -0
- data/lib/monittr/version.rb +1 -1
- data/test/monittr_test.rb +2 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -1,16 +1,8 @@
|
|
1
|
-
# Monittr
|
1
|
+
# Monittr #
|
2
2
|
|
3
|
-
|
3
|
+
Monittr provides a Ruby interface for the [Monit](http://mmonit.com/monit/) systems management system. Its main goal is to display statistics from multiple Monit instances in an attractive web interface.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
_Monittr_ loads XML from the [web server embedded in _Monit_](http://mmonit.com/monit/documentation/monit.html#monit_httpd) and makes it accessible as Ruby objects.
|
8
|
-
|
9
|
-
It also provides helpers for [_Sinatra_](http://www.sinatrarb.com/) applications, to display the information as HTML. You can insert the _Monit_ information into any page, or create a dedicated page.
|
10
|
-
|
11
|
-
You can use the default template, or create your own. The default template is located in `lib/monittr/sinatra/template.erb`.
|
12
|
-
|
13
|
-
The default template is pictured below.
|
5
|
+
Monittr loads XML from the [web server embedded in Monit](http://mmonit.com/monit/documentation/monit.html#monit_httpd) and makes it accessible as Ruby objects. It also provides helpers for [Sinatra](http://www.sinatrarb.com/) applications, to display the information as HTML. You can insert the statistics into any page, or create a dedicated one. You can use the default template, or create your own. The default template is located in `lib/monittr/sinatra/template.erb` and pictured below.
|
14
6
|
|
15
7
|

|
16
8
|
|
@@ -18,7 +10,7 @@ The default template is pictured below.
|
|
18
10
|
## Usage ##
|
19
11
|
|
20
12
|
First, clone or [download](https://github.com/karmi/monittr/zipball/master)
|
21
|
-
the sources from [
|
13
|
+
the sources from [Github](https://github.com/karmi/monittr/), to get the latest version:
|
22
14
|
|
23
15
|
$ git clone http://github.com/karmi/monittr.git
|
24
16
|
$ cd monittr
|
@@ -31,7 +23,7 @@ You have to pass one or more full URLs to a local or remote Monit web server out
|
|
31
23
|
|
32
24
|
cluster = Monittr::Cluster.new ['http://localhost:2812/']
|
33
25
|
|
34
|
-
In case you don't have a running
|
26
|
+
In case you don't have a running Monit server at hand, use the provided FakeWeb setup:
|
35
27
|
|
36
28
|
require 'fakeweb'
|
37
29
|
FakeWeb.register_uri(:get, 'http://localhost:2812/_status?format=xml', :body => File.read('test/fixtures/status.xml') ); nil
|
@@ -62,17 +54,16 @@ You can also check out the HTML display by running the example application:
|
|
62
54
|
|
63
55
|
You should see the information about two faked Monit instances in your browser.
|
64
56
|
|
65
|
-
Provide the URLs to live
|
57
|
+
Provide the URLs to live Monit instances by setting the appropriate option in `application.rb`:
|
66
58
|
|
67
59
|
set :monit_urls, %w[ http://production.example.com:2812 http://staging.example.com:2812 ]
|
68
60
|
|
69
|
-
You may also need to comment out the
|
61
|
+
You may also need to comment out the FakeWeb section, if you're passing `localhost` URLs.
|
70
62
|
|
71
63
|
|
72
64
|
## Customization ##
|
73
65
|
|
74
|
-
It's easy to customize the HTML output by setting the appropriate options in your
|
75
|
-
|
66
|
+
It's easy to customize the HTML output by setting the appropriate options in your Sinatra application.
|
76
67
|
|
77
68
|
set :template, Proc.new { File.join(root, 'template.erb') }
|
78
69
|
set :stylesheet, '/path/to/my/stylesheet'
|
@@ -82,22 +73,22 @@ Please see the example application for prepared examples.
|
|
82
73
|
|
83
74
|
## Installation ##
|
84
75
|
|
85
|
-
The best way
|
76
|
+
The best way to install the gem is from the source:
|
86
77
|
|
87
78
|
$ git clone http://github.com/karmi/monittr.git
|
88
79
|
$ cd monittr
|
89
80
|
$ rake install
|
90
81
|
|
91
|
-
Stable versions of the gem can be installed from
|
82
|
+
Stable versions of the gem can be installed from Rubygems:
|
92
83
|
|
93
84
|
$ gem install monittr
|
94
85
|
|
95
86
|
|
96
87
|
## Other ##
|
97
88
|
|
98
|
-
|
89
|
+
Any feedback, suggestions or patches are welcome via [e-mail](mailto:karmi@karmi.cz) or Github Issues/Pull Requests.
|
99
90
|
|
100
|
-
Check out the [
|
91
|
+
Check out the [`monit`](https://github.com/k33l0r/monit) gem for another Ruby interface to _Monit_.
|
101
92
|
|
102
93
|
-----
|
103
94
|
|
data/lib/monittr.rb
CHANGED
@@ -31,6 +31,8 @@ module Monittr
|
|
31
31
|
@system = Services::Base.new :name => error.attributes['name'].content,
|
32
32
|
:message => error.attributes['message'].content,
|
33
33
|
:status => 3
|
34
|
+
@filesystems = []
|
35
|
+
@processes = []
|
34
36
|
else
|
35
37
|
@system = Services::System.new(@xml.xpath("//service[@type=5]").first)
|
36
38
|
@filesystems = @xml.xpath("//service[@type=0]").map { |xml| Services::Filesystem.new(xml) }
|
data/lib/monittr/version.rb
CHANGED
data/test/monittr_test.rb
CHANGED
@@ -23,6 +23,8 @@ module Monittr
|
|
23
23
|
assert_equal 2, cluster.servers.size
|
24
24
|
assert_equal 3, cluster.servers.first.system.status
|
25
25
|
assert cluster.servers.first.system.message =~ /bad hostname/, "Should be bad hostname"
|
26
|
+
assert_not_nil cluster.servers.first.filesystems
|
27
|
+
assert_equal [], cluster.servers.first.filesystems
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|