munin-ruby 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2011-2013 Dan Sosedoff <dan.sosedoff@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Munin-Ruby
2
2
 
3
- Munin-ruby is a sockets-based ruby client library to communicate and fetch information from munin-node servers.
3
+ Munin-ruby is a sockets-based ruby client library to communicate and fetch
4
+ information from munin-node servers.
4
5
 
5
6
  ## Installation
6
7
 
@@ -29,9 +30,11 @@ node = Munin::Node.new
29
30
  node = Munin::Node.new('YOUR_HOST', YOUR_PORT)
30
31
  ```
31
32
 
32
- If munin-node has any restrictions on IP addresses, client will trigger ```Munin::AccessDenied``` exception.
33
+ If munin-node has any restrictions on IP addresses, client will trigger ```Munin::AccessDenied```
34
+ exception.
33
35
 
34
- By default client will reconnect if connection was lost. To disable that specify ```false``` after port option.
36
+ By default client will reconnect if connection was lost. To disable that
37
+ specify ```false``` after port option.
35
38
 
36
39
  ```ruby
37
40
  node = Munin::Node.new('YOUR_HOST', 4949, false)
@@ -45,7 +48,8 @@ node.disconnect
45
48
  node.connection.close
46
49
  ```
47
50
 
48
- In case if automatic reconnection was enabled, service will establish connection even after you call 'disconnect' method.
51
+ In case if automatic reconnection was enabled, service will establish
52
+ connection even after you call 'disconnect' method.
49
53
 
50
54
  To force client not to open connection: ```node.disconnect(false)```.
51
55
 
@@ -156,10 +160,21 @@ Output:
156
160
 
157
161
  ## License
158
162
 
159
- Copyright (c) 2011-2012 Dan Sosedoff.
163
+ Copyright (c) 2011-2013 Dan Sosedoff.
160
164
 
161
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
165
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
166
+ this software and associated documentation files (the "Software"), to deal in
167
+ the Software without restriction, including without limitation the rights to
168
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
169
+ the Software, and to permit persons to whom the Software is furnished to do so,
170
+ subject to the following conditions:
162
171
 
163
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
172
+ The above copyright notice and this permission notice shall be included in all
173
+ copies or substantial portions of the Software.
164
174
 
165
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
175
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
176
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
177
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
178
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
179
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
180
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,20 +1,25 @@
1
1
  module Munin
2
2
  class Connection
3
3
  include Munin::Parser
4
-
4
+
5
+ DEFAULT_OPTIONS = {:timeout => Munin::TIMEOUT_TIME}
6
+
5
7
  attr_reader :host, :port
6
8
 
7
9
  # Initialize a new connection to munin-node server
8
10
  #
9
- # host - Server host (default: 127.0.0.1)
10
- # port - Server port (default: 4949)
11
- #
12
- def initialize(host='127.0.0.1', port=4949, reconnect=true)
11
+ # host - Server host (default: 127.0.0.1)
12
+ # port - Server port (default: 4949)
13
+ # options - A hash containing different options
14
+ # :timeout => A timeout in seconds to be used in the connection
15
+
16
+ def initialize(host='127.0.0.1', port=4949, reconnect=true, options = {})
13
17
  @host = host
14
18
  @port = port
15
19
  @socket = nil
16
20
  @connected = false
17
21
  @reconnect = reconnect
22
+ @options = DEFAULT_OPTIONS.merge(options)
18
23
  end
19
24
 
20
25
  # Returns true if socket is connected
@@ -114,7 +119,7 @@ module Munin
114
119
 
115
120
  # Execute operation with timeout
116
121
  # @param [Block] block Block to execute
117
- def with_timeout(time=Munin::TIMEOUT_TIME)
122
+ def with_timeout(time=@options[:timeout])
118
123
  raise ArgumentError, "Block required" if !block_given?
119
124
  if Munin::TIMEOUT_CLASS.respond_to?(:timeout_after)
120
125
  Munin::TIMEOUT_CLASS.timeout_after(time) { yield }
@@ -4,20 +4,23 @@ module Munin
4
4
  class Node
5
5
  include Munin::Parser
6
6
  include Munin::Cache
7
-
7
+
8
8
  attr_reader :connection
9
-
9
+
10
+ DEFAULT_OPTIONS = {:timeout => Munin::TIMEOUT_TIME}
11
+
10
12
  # Initialize a new Node instance
11
13
  #
12
14
  # host - Server host
13
15
  # port - Server port
14
16
  # reconnect - Reconnect if connection was closed (default: true)
15
- #
16
-
17
- def initialize(host='127.0.0.1', port=4949, reconnect=true)
18
- @connection = Munin::Connection.new(host, port, reconnect)
17
+ # options - A hash containing different options
18
+ # :timeout => A timeout in seconds to be used in the connection
19
+ def initialize(host='127.0.0.1', port=4949, reconnect=true, options = {})
20
+ @options = DEFAULT_OPTIONS.merge(options)
21
+ @connection = Munin::Connection.new(host, port, reconnect, @options)
19
22
  end
20
-
23
+
21
24
  # Open service connection
22
25
  #
23
26
  def connect
@@ -42,9 +45,13 @@ module Munin
42
45
  # Get a list of all available nodes
43
46
  #
44
47
  def nodes
45
- cache 'nodes' do
48
+ nodes = []
49
+ cache 'nodes' do
46
50
  connection.send_data("nodes")
47
- connection.read_line.split
51
+ while ( ( line = connection.read_line ) != "." )
52
+ nodes << line
53
+ end
54
+ nodes
48
55
  end
49
56
  end
50
57
 
@@ -1,5 +1,5 @@
1
1
  module Munin
2
2
  unless defined?(::Munin::VERSION)
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.4'
4
4
  end
5
5
  end
data/lib/munin-ruby.rb CHANGED
@@ -7,13 +7,6 @@ rescue LoadError
7
7
  require 'timeout'
8
8
  end
9
9
 
10
- require 'munin-ruby/version'
11
- require 'munin-ruby/errors'
12
- require 'munin-ruby/parser'
13
- require 'munin-ruby/cache'
14
- require 'munin-ruby/connection'
15
- require 'munin-ruby/node'
16
-
17
10
  module Munin
18
11
  TIMEOUT_TIME = 10
19
12
 
@@ -22,4 +15,12 @@ module Munin
22
15
  else
23
16
  TIMEOUT_CLASS = Timeout
24
17
  end
25
- end
18
+ end
19
+
20
+ require 'munin-ruby/version'
21
+ require 'munin-ruby/errors'
22
+ require 'munin-ruby/parser'
23
+ require 'munin-ruby/cache'
24
+ require 'munin-ruby/connection'
25
+ require 'munin-ruby/node'
26
+
data/munin-ruby.gemspec CHANGED
@@ -15,5 +15,5 @@ Gem::Specification.new do |gem|
15
15
  gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
16
16
  gem.require_paths = ['lib']
17
17
 
18
- gem.add_development_dependency 'rspec', '~> 2.6'
18
+ gem.add_development_dependency 'rspec', '~> 2.13'
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: munin-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,19 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-20 00:00:00.000000000Z
12
+ date: 2013-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2152614540 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '2.6'
21
+ version: '2.13'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2152614540
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.13'
25
30
  description: Munin Node client
26
31
  email: dan.sosedoff@gmail.com
27
32
  executables: []
@@ -30,6 +35,8 @@ extra_rdoc_files: []
30
35
  files:
31
36
  - .gitignore
32
37
  - .rspec
38
+ - Gemfile
39
+ - LICENSE
33
40
  - README.md
34
41
  - Rakefile
35
42
  - lib/munin-ruby.rb
@@ -67,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
74
  version: '0'
68
75
  requirements: []
69
76
  rubyforge_project:
70
- rubygems_version: 1.8.15
77
+ rubygems_version: 1.8.25
71
78
  signing_key:
72
79
  specification_version: 3
73
80
  summary: Ruby client library to communicate with munin-node servers
@@ -79,4 +86,3 @@ test_files:
79
86
  - spec/node_spec.rb
80
87
  - spec/parser_spec.rb
81
88
  - spec/spec_helper.rb
82
- has_rdoc: