slashport 0.15.10 → 0.15.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -114,9 +114,9 @@ class SlashPort::Component
114
114
  loads = %x{uptime}.chomp.delete(",").split(/ +/)[-3..-1].map { |x| x.to_f }
115
115
  _reapchild
116
116
  load1, load5, load15 = loads
117
- tuple.data["load-1min"] = load1
118
- tuple.data["load-5min"] = load5
119
- tuple.data["load-15min"] = load15
117
+ tuple.data["load_1min"] = load1
118
+ tuple.data["load_5min"] = load5
119
+ tuple.data["load_15min"] = load15
120
120
 
121
121
  data << tuple
122
122
  return data
@@ -16,12 +16,15 @@ class SlashPort::Component::LinuxProcess < SlashPort::Component
16
16
  procinfo = ProcessInfo.new(pid)
17
17
  limits = procinfo.get_limits
18
18
  tuple = SlashPort::Tuple.new
19
- puts limits.inspect
20
- tuple.data["max_open_files"] = limits["open files"]
21
- tuple.data["open_files"] = procinfo.open_files
19
+ tuple.data["open_files_max"] = limits["open files"].to_f
20
+ tuple.data["open_files_used"] = procinfo.open_files.to_f
21
+ if limits["open files"] == "unlimited"
22
+ tuple.data["open_files_percent"] = 0.0
23
+ else
24
+ tuple.data["open_files_percent"] = procinfo.open_files / limits["open files"].to_f
25
+ end
22
26
  return tuple
23
27
  end
24
-
25
28
  end # class SlashPort::Component
26
29
 
27
30
 
@@ -7,11 +7,11 @@ class SlashPort::Component
7
7
  attr_accessor :user
8
8
  attr_accessor :password
9
9
 
10
- attribute :name => "master-status",
10
+ attribute :name => "master_status",
11
11
  :handler => :MasterStatus,
12
12
  :doc => "Shows the master status of this mysql server"
13
13
 
14
- attribute :name => "slave-status",
14
+ attribute :name => "slave_status",
15
15
  :handler => :SlaveStatus,
16
16
  :doc => "Shows the slave status of this mysql server"
17
17
 
@@ -23,10 +23,6 @@ class SlashPort::Component
23
23
  :handler => :MysqlOK,
24
24
  :doc => "Reports whether we can send queries successfully to mysql."
25
25
 
26
- #multiconfig "settings", :ConfigGetVariables, <<-doc
27
- #Output of 'show variables'
28
- #doc
29
-
30
26
  def initialize
31
27
  super
32
28
  begin
@@ -71,7 +67,7 @@ class SlashPort::Component
71
67
  ret = Hash.new
72
68
  if result == nil
73
69
  # this host is not a slave
74
- tuple.data["is-slave"] = false
70
+ tuple.data["is_slave"] = false
75
71
  else
76
72
  result.each do |key, val|
77
73
  tuple.data[key.to_s.downcase] = val
@@ -28,12 +28,7 @@ parser = OptionParser.new do |opts|
28
28
  end
29
29
 
30
30
  opts.on("-i FILTER", "--ignore FILTER", "Ignore things matching a check") do |v|
31
- check = SlashPort::Check.new_from_string(v)
32
- if check == nil
33
- puts "Invalid check #{v}"
34
- exit 1
35
- end
36
- ignores << check
31
+ ignores << v
37
32
  end
38
33
 
39
34
  opts.on("-h HOST[:PORT]", "--host HOST[:PORT]", "Host to query") do |v|
@@ -44,12 +39,7 @@ parser = OptionParser.new do |opts|
44
39
  end
45
40
 
46
41
  opts.on("-c CHECK", "--check CHECK", "Output if CHECK succeeds") do |v|
47
- check = SlashPort::Check.new_from_string(v)
48
- if check == nil
49
- puts "Invalid check #{v}"
50
- exit 1
51
- end
52
- checks << check
42
+ checks << v
53
43
  end
54
44
 
55
45
  opts.on("-r", "--empty-results-is-ok",
@@ -73,9 +63,21 @@ end
73
63
 
74
64
  matches = 0
75
65
  entries = 0
66
+
67
+ # monkeypatch OpenStruct so we can use it for a weak
68
+ # variable storage for the filters and checks.
69
+ class OpenStruct
70
+ def get_binding
71
+ return binding
72
+ end
73
+ end
74
+
76
75
  fetcher.fetch.each do |entry|
77
- # Skip if this entry matches any ignores
78
- next if ignores.select { |check| check.match?(entry) }.length > 0
76
+ # Convert entry to an openstruct
77
+ data = OpenStruct.new(entry["labels"].merge(entry["data"]))
78
+
79
+ # skip if any ignores evaluate to true
80
+ next if ignores.select { |code| eval code, data.get_binding }.length > 0
79
81
  entries += 1
80
82
 
81
83
  if checks.length == 0
@@ -83,9 +85,9 @@ fetcher.fetch.each do |entry|
83
85
  matches += 1
84
86
  end
85
87
 
86
- checks.each do |check|
87
- if check.match?(entry)
88
- puts "#{check} matches #{entry.inspect}"
88
+ checks.each do |code|
89
+ if eval(code, data.get_binding)
90
+ puts "#{code.inspect} matched: #{entry.inspect}"
89
91
  exitcode = CRITICAL
90
92
  matches += 1
91
93
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slashport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.10
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 15
8
+ - 12
9
+ version: 0.15.12
5
10
  platform: ruby
6
11
  authors:
7
12
  - Jordan Sissel
@@ -9,49 +14,65 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-12 00:00:00 -08:00
17
+ date: 2010-07-21 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: merb-core
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 12
23
31
  version: 1.0.12
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: mongrel
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 1
44
+ - 5
33
45
  version: 1.1.5
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  - !ruby/object:Gem::Dependency
36
49
  name: sequel
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
40
52
  requirements:
41
53
  - - ">="
42
54
  - !ruby/object:Gem::Version
55
+ segments:
56
+ - 3
57
+ - 5
58
+ - 0
43
59
  version: 3.5.0
44
- version:
60
+ type: :runtime
61
+ version_requirements: *id003
45
62
  - !ruby/object:Gem::Dependency
46
63
  name: mysql
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
50
66
  requirements:
51
67
  - - ">="
52
68
  - !ruby/object:Gem::Version
69
+ segments:
70
+ - 2
71
+ - 8
72
+ - 1
53
73
  version: 2.8.1
54
- version:
74
+ type: :runtime
75
+ version_requirements: *id004
55
76
  description: slashport
56
77
  email: jls@semicomplete.com
57
78
  executables:
@@ -137,18 +158,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
158
  requirements:
138
159
  - - ">="
139
160
  - !ruby/object:Gem::Version
161
+ segments:
162
+ - 0
140
163
  version: "0"
141
- version:
142
164
  required_rubygems_version: !ruby/object:Gem::Requirement
143
165
  requirements:
144
166
  - - ">="
145
167
  - !ruby/object:Gem::Version
168
+ segments:
169
+ - 0
146
170
  version: "0"
147
- version:
148
171
  requirements: []
149
172
 
150
173
  rubyforge_project:
151
- rubygems_version: 1.3.5
174
+ rubygems_version: 1.3.6
152
175
  signing_key:
153
176
  specification_version: 3
154
177
  summary: slashport