circonus 3.6.1 → 3.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/circonus-add-http-check +17 -6
  2. metadata +1 -1
@@ -10,11 +10,15 @@ host = nil
10
10
  options[:brokers] = []
11
11
  options[:hostname] = nil
12
12
  options[:url] = nil
13
+ options[:timeout] = 10 # seconds
14
+ options[:texttomatch] = nil
13
15
  options[:tags] = ['application:http','source:manual']
14
16
  opts.banner = "Usage: #{File.basename($0)}\n"
15
17
  opts.on( '--tags TAGLIST',"Apply comma separated list of tags (default: empty list)" ) { |t| options[:tags] += t.split(/,/) }
16
18
  opts.on( '--brokers BROKER',"Comma separated list of broker names to use" ) { |t| options[:brokers] = t.split(',') }
17
19
  opts.on( '--hostname HOSTNAME',"Hostname to add" ) { |t| options[:hostname] = t }
20
+ opts.on( '--timeout TIMEOUT',"Host timeout" ) { |t| options[:timeout] = t.to_i }
21
+ opts.on( '--match TEXTTOMATCH',"String to match against in the response" ) { |t| options[:texttomatch] = t }
18
22
  opts.on( '--contactgroups CONTACTGROUPS',"Comma separated list of contact groups to send alerts to" ) { |t| options[:contactgroups] = t }
19
23
  opts.on( '--url URL',"URL to test" ) { |t| options[:url] = t }
20
24
  }
@@ -93,6 +97,7 @@ bundle['target'] = @cu.options[:hostname]
93
97
  bundle['tags'] = @cu.options[:tags]
94
98
  bundle['display_name'] = "#{@cu.options[:hostname]} http"
95
99
  bundle['config']['url'] = @cu.options[:url]
100
+ bundle['config']['body'] = @cu.options[:texttomatch] unless @cu.options[:texttomatch].nil?
96
101
  bundle['config']['header_Host'] = @cu.options[:hostname]
97
102
  search_bundles = @cu.circonus.search_check_bundle(bundle['display_name'],'display_name')
98
103
  if search_bundles.any? # already exists...
@@ -141,7 +146,7 @@ graph = mib_add_graph!("#{@cu.options[:hostname]} http latency",{'style'=>'line'
141
146
  checkids.each do |cid|
142
147
  dpcid = cid.split('/').last.to_i
143
148
  %w{ tt_connect tt_firstbyte duration }.each do |metric|
144
- mib_add_datapoint!(graph,metric,{'name'=>"metric cid:#{dpcid}",'legend_formula'=>'=round(VAL,3)','data_formula'=>'=VAL/1000.0','check_id'=>dpcid})
149
+ mib_add_datapoint!(graph,metric,{'name'=>"#{metric} cid:#{dpcid}",'legend_formula'=>'=round(VAL,3)','data_formula'=>'=VAL/1000.0','check_id'=>dpcid})
145
150
  end
146
151
  end
147
152
  #pp graph
@@ -194,8 +199,7 @@ checkids.each do |cid|
194
199
  rcid = cid.split('/').last.to_i
195
200
  rs = mib_add_rule_set!('duration',{'check'=>rcid})
196
201
  mib_add_rule!(rs,{ "criteria"=>"on absence", "severity"=>1, "value"=>180 })
197
- mib_add_rule!(rs,{ "criteria"=>"max value", "severity"=>1, "value"=>5000 })
198
- mib_add_rule!(rs,{ "criteria"=>"max value", "severity"=>2, "value"=>4000 })
202
+ mib_add_rule!(rs,{ "criteria"=>"max value", "severity"=>1, "value"=>(@cu.options[:timeout]*1000) })
199
203
  #pp rs
200
204
  r = @cu.circonus.add_rule_set(rs)
201
205
  if not r.nil? then
@@ -209,8 +213,15 @@ checkids.each do |cid|
209
213
  if not r.nil? then
210
214
  print "Success\n"
211
215
  end
216
+ ##### missing body
217
+ unless @cu.options[:texttomatch].nil?
218
+ rs = mib_add_rule_set!('body_match',{'metric_type'=>'text','check'=>rcid})
219
+ mib_add_rule!(rs,{ "criteria"=>"does not match", "severity"=>1, "value"=>@cu.options[:texttomatch] })
220
+ #pp rs
221
+ r = @cu.circonus.add_rule_set(rs)
222
+ if not r.nil? then
223
+ print "Success\n"
224
+ end
225
+ end
212
226
  end
213
227
 
214
-
215
-
216
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circonus
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1
4
+ version: 3.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: