ruby-nagios 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/check_check CHANGED
@@ -155,7 +155,7 @@ def main(args)
155
155
  puts "Services in #{state}:"
156
156
  results[state].sort { |a,b| a["host_name"] <=> b["host_name"] }.each do |service|
157
157
  total_results += 1
158
- puts " #{service["host_name"]} => #{service["service_description"]}"
158
+ puts " #{service["host_name"]} => #{service["service_description"]} (#{service["plugin_output"]})"
159
159
  end
160
160
  end # if results[state]
161
161
  end # for each non-OK state
data/bin/nagsrv CHANGED
@@ -46,6 +46,9 @@
46
46
  # --acknowledge
47
47
  # Ackknowledge services without sending notifies
48
48
  #
49
+ # --delete-comments
50
+ # Delete the comments for selected services
51
+ #
49
52
  # Released under the terms of the Apache version 2
50
53
  # license
51
54
  #
@@ -63,6 +66,7 @@ forhost = []
63
66
  notify = nil
64
67
  action = nil
65
68
  options = nil
69
+ current_state = nil
66
70
 
67
71
  OptionParser.new do |opts|
68
72
  opts.separator "General Options"
@@ -91,6 +95,21 @@ OptionParser.new do |opts|
91
95
  forhost << v
92
96
  end
93
97
 
98
+ opts.on("--critical", "List only services which are critical") do
99
+ raise("Cannot use --critical with --ok or --warning") unless current_state.nil?
100
+ current_state = 2
101
+ end
102
+
103
+ opts.on("--warning", "List only services which are warning") do
104
+ raise("Cannot use --warning with --critical or --ok") unless current_state.nil?
105
+ current_state = 1
106
+ end
107
+
108
+ opts.on("--ok", "List only services which are ok") do
109
+ raise("Cannot use --ok with --critical or --warning") unless current_state.nil?
110
+ current_state = 0
111
+ end
112
+
94
113
  opts.on("--notify-enabled", "List only services with notification enabled") do
95
114
  notify = 1
96
115
  end
@@ -124,6 +143,12 @@ OptionParser.new do |opts|
124
143
  opts.on("--ackknowledge", "Ackknowledge services without sending notifies") do
125
144
  action = "[${tstamp}] ACKNOWLEDGE_SVC_PROBLEM;${host};${service};1;0;1;#{ENV['USER']};Acknowledged from CLI"
126
145
  end
146
+
147
+ opts.on("--delete-comments", "") do
148
+ comment_id = 1
149
+ action = "[${tstamp}] DEL_SVC_COMMENT;${comment_id};${tstamp}"
150
+ end
151
+
127
152
  end.parse!
128
153
 
129
154
  abort "Cannot find #{statusfile}" unless File.exist?(statusfile)
@@ -145,7 +170,7 @@ if listservices && action == nil
145
170
  action = "${service}"
146
171
  end
147
172
 
148
- options = {:forhost => forhost, :notifyenabled => notify, :action => action, :withservice => withservice}
173
+ options = {:forhost => forhost, :notifyenabled => notify, :action => action, :withservice => withservice, :current_state => current_state}
149
174
  services = nagios.find_services(options)
150
175
 
151
176
  puts services.join("\n")
@@ -133,6 +133,7 @@ module Nagios
133
133
  end
134
134
 
135
135
  output << { data: params, result: messages.empty? , messages: messages }
136
+ result &&= messages.empty?
136
137
  end # data.each
137
138
 
138
139
  { result: result, data: output }
data/lib/nagios/status.rb CHANGED
@@ -89,6 +89,7 @@ module Nagios
89
89
  withservice = options.fetch(:withservice, [])
90
90
  acknowledged = options.fetch(:acknowledged, nil)
91
91
  passive = options.fetch(:passive, nil)
92
+ current_state = options.fetch(:current_state, nil)
92
93
 
93
94
  services = []
94
95
  searchquery = []
@@ -103,6 +104,7 @@ module Nagios
103
104
  searchquery << search_term("service_description", s)
104
105
  end
105
106
 
107
+ searchquery << {"current_state" => current_state } if current_state
106
108
  searchquery << {"notifications_enabled" => notifications.to_s} if notifications
107
109
  searchquery << {"problem_has_been_acknowledged" => acknowledged.to_s} if acknowledged
108
110
  if passive
data/ruby-nagios.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'ruby-nagios'
3
- s.version = "0.1.0"
3
+ s.version = "0.2.0"
4
4
  s.author = 'R.I.Pienaar'
5
5
  s.email = 'rip@devco.net'
6
6
  s.homepage = 'http://devco.net/'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nagios
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-02-27 00:00:00 +00:00
18
+ date: 2013-07-16 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency