circonus 3.1.1 → 3.1.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-delete-host +53 -0
  2. metadata +3 -2
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+ # Delete a single host (and all associated check bundles, graphs, and rule sets)
3
+ # Use FQDN tag to identify it.
4
+
5
+ require 'rubygems'
6
+ require 'circonus'
7
+ require 'optparse'
8
+ require "#{ENV['HOME']}/.circonus.rb"
9
+
10
+ options = {}
11
+ OptionParser.new { |opts|
12
+ opts.banner = "Usage: #{File.basename($0)} [-h] hostname\n"
13
+ opts.on( '-h', '--help', "This usage menu") do
14
+ puts opts
15
+ exit
16
+ end
17
+ }.parse!
18
+
19
+ def usage()
20
+ print <<EOF
21
+ Usage: #{File.basename($0)} hostname
22
+ -h,--help This usage menu
23
+ EOF
24
+ end
25
+
26
+ host = ARGV[0]
27
+ if host.nil? or host.empty? then
28
+ usage()
29
+ exit -1
30
+ end
31
+
32
+ @c = Circonus.new(@apitoken,@appname,@agent)
33
+
34
+ print "Deleting check bundles for host #{host}\n"
35
+ cbs = @c.list_check_bundle({'tags_has'=>"fqdn:#{host.downcase}"})
36
+ checks = cbs.map { |m| m['_checks'] }.flatten
37
+ graphs = @c.list_graph({'tags_has'=>"fqdn:#{host.downcase}"})
38
+ checks.each do |check|
39
+ rule_sets = @c.list_rule_set({'check'=>check})
40
+ rule_sets.each do |rs|
41
+ delete_rule_set(rs['_cid'])
42
+ puts "Deleting rule set id: #{rs['_cid']}"
43
+ end
44
+ end
45
+ graphs.each do |graph|
46
+ delete_graph(graph['_cid'])
47
+ puts "Deleting graph id: #{graph['_cid']}"
48
+ end
49
+ cbs.each do |cb|
50
+ delete_check_bundle(cb['_cid'])
51
+ puts "Deleting check bundle id: #{cb['_cid']}"
52
+ end
53
+
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.1.1
4
+ version: 3.1.2
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: 2014-02-06 00:00:00.000000000 Z
12
+ date: 2014-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -68,6 +68,7 @@ extensions: []
68
68
  extra_rdoc_files: []
69
69
  files:
70
70
  - lib/circonus.rb
71
+ - bin/circonus-delete-host
71
72
  - bin/update_all_composites.rb
72
73
  - bin/circonus_list_checkbundle
73
74
  - bin/circonus-data-cli