openldap_monitor_extractor 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/.gitignore
CHANGED
@@ -8,11 +8,12 @@ require 'yaml'
|
|
8
8
|
require 'openldap_monitor_extractor'
|
9
9
|
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
config = YAML.load_file(ARGV[0])
|
14
|
-
puts OpenldapMonitorExtractor.configure(config).get(:total_connections)
|
15
|
-
else
|
16
|
-
|
11
|
+
unless ARGV[0] && File.exist?(ARGV[0])
|
12
|
+
|
17
13
|
puts "usage: #{$0} config_file.yml"
|
18
|
-
|
14
|
+
Kernel.exit 1
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
config = YAML.load_file(ARGV[0])
|
19
|
+
puts OpenldapMonitorExtractor.configure(config).get(:all).inspect
|
@@ -1,57 +1,82 @@
|
|
1
|
+
require "ostruct"
|
1
2
|
require "openldap_monitor_extractor/version"
|
2
3
|
require "openldap_monitor_extractor/connection"
|
3
4
|
|
4
5
|
|
5
6
|
module OpenldapMonitorExtractor
|
6
7
|
extend self
|
8
|
+
|
9
|
+
class ExtractorError < StandardError
|
10
|
+
end
|
7
11
|
|
8
12
|
MAPPER = {
|
9
|
-
:total_connections =>{ :dn =>"cn=Total,cn=Connections,cn=Monitor", :attribute =>:monitorcounter
|
10
|
-
:referals_statistics =>{ :dn =>"cn=Referrals,cn=Statistics,cn=Monitor",:attribute =>:monitorcounter
|
11
|
-
:bytes_statistics =>{ :dn =>"cn=Bytes,cn=Statistics,cn=Monitor", :attribute =>:monitorcounter
|
12
|
-
:entries_statistics =>{ :dn =>"cn=Entries,cn=Statistics,cn=Monitor", :attribute =>:monitorcounter
|
13
|
-
:initiated_operations =>{ :dn =>"cn=Operations,cn=Monitor", :attribute =>:monitoropinitiated
|
14
|
-
:completed_operations =>{ :dn =>"cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
15
|
-
:bind_operations =>{ :dn =>"cn=Bind,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
16
|
-
:unbind_operations =>{ :dn =>"cn=Unbind,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
17
|
-
:search_operations =>{ :dn =>"cn=Search,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
18
|
-
:compare_operations =>{ :dn =>"cn=Compare,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
19
|
-
:modify_operations =>{ :dn =>"cn=Modify,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
20
|
-
:modrdn_operations =>{ :dn =>"cn=Modrdn,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
21
|
-
:add_operations =>{ :dn =>"cn=Add,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
22
|
-
:delete_operations =>{ :dn =>"cn=Delete,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
23
|
-
:abandon_operations =>{ :dn =>"cn=Abandon,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
24
|
-
:extended_operations =>{ :dn =>"cn=Extended,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted
|
25
|
-
:write_waiters =>{ :dn =>"cn=Write,cn=Waiters,cn=Monitor", :attribute =>:monitorcounter
|
26
|
-
:read_waiters =>{ :dn =>"cn=Read,cn=Waiters,cn=Monitor", :attribute =>:monitorcounter
|
13
|
+
:total_connections =>{ :dn =>"cn=Total,cn=Connections,cn=Monitor", :attribute =>:monitorcounter },
|
14
|
+
:referals_statistics =>{ :dn =>"cn=Referrals,cn=Statistics,cn=Monitor",:attribute =>:monitorcounter },
|
15
|
+
:bytes_statistics =>{ :dn =>"cn=Bytes,cn=Statistics,cn=Monitor", :attribute =>:monitorcounter },
|
16
|
+
:entries_statistics =>{ :dn =>"cn=Entries,cn=Statistics,cn=Monitor", :attribute =>:monitorcounter },
|
17
|
+
:initiated_operations =>{ :dn =>"cn=Operations,cn=Monitor", :attribute =>:monitoropinitiated },
|
18
|
+
:completed_operations =>{ :dn =>"cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
19
|
+
:bind_operations =>{ :dn =>"cn=Bind,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
20
|
+
:unbind_operations =>{ :dn =>"cn=Unbind,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
21
|
+
:search_operations =>{ :dn =>"cn=Search,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
22
|
+
:compare_operations =>{ :dn =>"cn=Compare,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
23
|
+
:modify_operations =>{ :dn =>"cn=Modify,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
24
|
+
:modrdn_operations =>{ :dn =>"cn=Modrdn,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
25
|
+
:add_operations =>{ :dn =>"cn=Add,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
26
|
+
:delete_operations =>{ :dn =>"cn=Delete,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
27
|
+
:abandon_operations =>{ :dn =>"cn=Abandon,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
28
|
+
:extended_operations =>{ :dn =>"cn=Extended,cn=Operations,cn=Monitor", :attribute =>:monitoropcompleted },
|
29
|
+
:write_waiters =>{ :dn =>"cn=Write,cn=Waiters,cn=Monitor", :attribute =>:monitorcounter },
|
30
|
+
:read_waiters =>{ :dn =>"cn=Read,cn=Waiters,cn=Monitor", :attribute =>:monitorcounter }
|
27
31
|
}
|
28
32
|
|
29
33
|
KEYS = MAPPER.keys
|
30
34
|
|
35
|
+
private
|
36
|
+
def get_monitor_parameter(dn, attribute)
|
37
|
+
|
38
|
+
@connection.search(
|
39
|
+
:filter =>Net::LDAP::Filter.eq("objectClass", "*"),
|
40
|
+
:base =>dn,
|
41
|
+
:attributes =>[attribute])
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
public
|
31
46
|
def configure(config)
|
32
47
|
|
33
48
|
@connection ||= Connection.new(config).connection
|
34
|
-
|
35
49
|
self
|
36
50
|
end
|
37
51
|
|
38
|
-
|
52
|
+
|
53
|
+
def validate_key(key)
|
54
|
+
|
55
|
+
key == :all || KEYS.include?(key)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def get(key=:all)
|
39
60
|
|
40
|
-
raise
|
61
|
+
raise ExtractorError.new("You need to configure a valid LDAP connection") unless @connection
|
62
|
+
raise ArgumentError.new("Invalid key: #{key}, valid keys are: #{KEYS.inspect}") unless validate_key(key)
|
41
63
|
|
42
|
-
|
43
|
-
|
64
|
+
result = OpenStruct.new()
|
65
|
+
keys = (key == :all ? KEYS : [key])
|
66
|
+
|
67
|
+
keys.each do |k|
|
44
68
|
|
45
|
-
|
46
|
-
|
69
|
+
dn = MAPPER[k][:dn]
|
70
|
+
attr = MAPPER[k][:attribute]
|
71
|
+
entry = get_monitor_parameter(dn, attr)
|
72
|
+
|
73
|
+
raise ExtractorError.new("Problems getting #{dn} data") unless entry
|
47
74
|
|
48
|
-
|
49
|
-
|
50
|
-
:base =>dn,
|
51
|
-
:attributes =>[attribute])
|
52
|
-
|
53
|
-
raise StandardError.new("Problems getting information: #{dn} from Monitor backend") unless entry
|
75
|
+
result.send("#{k}=", entry[0][attr][0].to_i)
|
76
|
+
end
|
54
77
|
|
55
|
-
|
78
|
+
result
|
79
|
+
rescue Exception => exc
|
80
|
+
raise ExtractorError.new(exc.message)
|
56
81
|
end
|
57
82
|
end
|
@@ -13,6 +13,7 @@ module OpenldapMonitorExtractor
|
|
13
13
|
|
14
14
|
def self.builder(parameters={ })
|
15
15
|
|
16
|
+
parameters = { :base =>DEFAULT_MONITOR_BASE }.merge(parameters)
|
16
17
|
uri = URI.parse(parameters[:url])
|
17
18
|
auth = {
|
18
19
|
:method =>:simple,
|
@@ -23,7 +24,7 @@ module OpenldapMonitorExtractor
|
|
23
24
|
cparameters = {
|
24
25
|
:host =>uri.host,
|
25
26
|
:port =>uri.port,
|
26
|
-
:base =>
|
27
|
+
:base =>parameters[:base],
|
27
28
|
:auth =>auth
|
28
29
|
}
|
29
30
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openldap_monitor_extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ldap
|
@@ -87,7 +87,7 @@ files:
|
|
87
87
|
- LICENSE.txt
|
88
88
|
- README.md
|
89
89
|
- Rakefile
|
90
|
-
- examples/
|
90
|
+
- examples/get_all_stats.rb
|
91
91
|
- examples/sample_settings.yml
|
92
92
|
- lib/openldap_monitor_extractor.rb
|
93
93
|
- lib/openldap_monitor_extractor/connection.rb
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
segments:
|
112
112
|
- 0
|
113
|
-
hash:
|
113
|
+
hash: 720276235540630360
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
none: false
|
116
116
|
requirements:
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
segments:
|
121
121
|
- 0
|
122
|
-
hash:
|
122
|
+
hash: 720276235540630360
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
125
|
rubygems_version: 1.8.25
|