riemann-tools 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +11 -0
  3. data/.github/workflows/ci.yml +15 -0
  4. data/.github/workflows/codeql-analysis.yml +72 -0
  5. data/.gitignore +2 -0
  6. data/.rubocop.yml +40 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.md +62 -2
  9. data/README.markdown +8 -24
  10. data/Rakefile +14 -5
  11. data/SECURITY.md +42 -0
  12. data/bin/riemann-apache-status +3 -94
  13. data/bin/riemann-bench +4 -67
  14. data/bin/riemann-cloudant +3 -54
  15. data/bin/riemann-consul +3 -102
  16. data/bin/riemann-dir-files-count +3 -51
  17. data/bin/riemann-dir-space +3 -51
  18. data/bin/riemann-diskstats +3 -91
  19. data/bin/riemann-fd +4 -63
  20. data/bin/riemann-freeswitch +4 -116
  21. data/bin/riemann-haproxy +3 -54
  22. data/bin/riemann-health +3 -344
  23. data/bin/riemann-kvminstance +4 -19
  24. data/bin/riemann-memcached +3 -33
  25. data/bin/riemann-net +3 -105
  26. data/bin/riemann-nginx-status +3 -80
  27. data/bin/riemann-ntp +3 -34
  28. data/bin/riemann-portcheck +3 -37
  29. data/bin/riemann-proc +3 -104
  30. data/bin/riemann-varnish +3 -50
  31. data/bin/riemann-wrapper +75 -0
  32. data/bin/riemann-zookeeper +3 -37
  33. data/lib/riemann/tools/apache_status.rb +107 -0
  34. data/lib/riemann/tools/bench.rb +72 -0
  35. data/lib/riemann/tools/cloudant.rb +57 -0
  36. data/lib/riemann/tools/consul_health.rb +107 -0
  37. data/lib/riemann/tools/dir_files_count.rb +56 -0
  38. data/lib/riemann/tools/dir_space.rb +56 -0
  39. data/lib/riemann/tools/diskstats.rb +94 -0
  40. data/lib/riemann/tools/fd.rb +81 -0
  41. data/lib/riemann/tools/freeswitch.rb +119 -0
  42. data/lib/riemann/tools/haproxy.rb +59 -0
  43. data/lib/riemann/tools/health.rb +478 -0
  44. data/lib/riemann/tools/kvm.rb +23 -0
  45. data/lib/riemann/tools/memcached.rb +38 -0
  46. data/lib/riemann/tools/net.rb +105 -0
  47. data/lib/riemann/tools/nginx_status.rb +86 -0
  48. data/lib/riemann/tools/ntp.rb +42 -0
  49. data/lib/riemann/tools/portcheck.rb +45 -0
  50. data/lib/riemann/tools/proc.rb +109 -0
  51. data/lib/riemann/tools/riemann_client_wrapper.rb +43 -0
  52. data/lib/riemann/tools/uptime_parser.tab.rb +323 -0
  53. data/lib/riemann/tools/varnish.rb +55 -0
  54. data/lib/riemann/tools/version.rb +1 -1
  55. data/lib/riemann/tools/zookeeper.rb +40 -0
  56. data/lib/riemann/tools.rb +31 -52
  57. data/riemann-tools.gemspec +8 -2
  58. data/tools/riemann-aws/{Rakefile.rb → Rakefile} +8 -9
  59. data/tools/riemann-aws/bin/riemann-aws-billing +4 -83
  60. data/tools/riemann-aws/bin/riemann-aws-rds-status +4 -50
  61. data/tools/riemann-aws/bin/riemann-aws-sqs-status +4 -40
  62. data/tools/riemann-aws/bin/riemann-aws-status +4 -67
  63. data/tools/riemann-aws/bin/riemann-elb-metrics +4 -163
  64. data/tools/riemann-aws/bin/riemann-s3-list +4 -78
  65. data/tools/riemann-aws/bin/riemann-s3-status +4 -95
  66. data/tools/riemann-aws/lib/riemann/tools/aws/billing.rb +87 -0
  67. data/tools/riemann-aws/lib/riemann/tools/aws/elb_metrics.rb +163 -0
  68. data/tools/riemann-aws/lib/riemann/tools/aws/rds_status.rb +63 -0
  69. data/tools/riemann-aws/lib/riemann/tools/aws/s3_list.rb +82 -0
  70. data/tools/riemann-aws/lib/riemann/tools/aws/s3_status.rb +97 -0
  71. data/tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb +45 -0
  72. data/tools/riemann-aws/lib/riemann/tools/aws/status.rb +74 -0
  73. data/tools/riemann-chronos/{Rakefile.rb → Rakefile} +8 -9
  74. data/tools/riemann-chronos/bin/riemann-chronos +3 -139
  75. data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +157 -0
  76. data/tools/riemann-docker/{Rakefile.rb → Rakefile} +7 -8
  77. data/tools/riemann-docker/bin/riemann-docker +4 -213
  78. data/tools/riemann-docker/lib/riemann/tools/docker.rb +200 -0
  79. data/tools/riemann-elasticsearch/{Rakefile.rb → Rakefile} +8 -9
  80. data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +3 -161
  81. data/tools/riemann-elasticsearch/lib/riemann/tools/elasticsearch.rb +170 -0
  82. data/tools/riemann-marathon/{Rakefile.rb → Rakefile} +8 -9
  83. data/tools/riemann-marathon/bin/riemann-marathon +3 -142
  84. data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +159 -0
  85. data/tools/riemann-mesos/{Rakefile.rb → Rakefile} +8 -9
  86. data/tools/riemann-mesos/bin/riemann-mesos +3 -126
  87. data/tools/riemann-mesos/lib/riemann/tools/mesos.rb +142 -0
  88. data/tools/riemann-munin/{Rakefile.rb → Rakefile} +7 -8
  89. data/tools/riemann-munin/bin/riemann-munin +3 -32
  90. data/tools/riemann-munin/lib/riemann/tools/munin.rb +37 -0
  91. data/tools/riemann-rabbitmq/{Rakefile.rb → Rakefile} +8 -9
  92. data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +3 -264
  93. data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +269 -0
  94. data/tools/riemann-riak/{Rakefile.rb → Rakefile} +7 -8
  95. data/tools/riemann-riak/bin/riemann-riak +3 -326
  96. data/tools/riemann-riak/bin/riemann-riak-keys +0 -1
  97. data/tools/riemann-riak/bin/riemann-riak-ring +0 -1
  98. data/tools/riemann-riak/lib/riemann/tools/riak.rb +317 -0
  99. metadata +112 -16
  100. data/.travis.yml +0 -31
  101. data/tools/riemann-riak/riak_status/key_count.erl +0 -13
  102. data/tools/riemann-riak/riak_status/riak_status.rb +0 -152
  103. data/tools/riemann-riak/riak_status/ringready.erl +0 -9
@@ -1,152 +0,0 @@
1
- #!/usr/bin/env ruby
2
- Process.setproctitle($0)
3
-
4
- $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../vodpod-common/lib")
5
- require 'rubygems'
6
- require 'vodpod-common'
7
- require 'vodpod/alerts'
8
- require 'vodpod/starling'
9
- require 'net/http'
10
- require 'yajl/json_gem'
11
-
12
- class RiakStatus
13
- PORT = 8098
14
- PATH = '/stats'
15
- INTERVAL = 10
16
-
17
- FSM_LIMITS = {
18
- :get => {
19
- 50 => 1000,
20
- 95 => 2000,
21
- 99 => 10000
22
- },
23
- :put => {
24
- 50 => 1000,
25
- 95 => 2000,
26
- 99 => 10000
27
- }
28
- }
29
-
30
- def initialize(opts = {})
31
- @host = opts[:host] || `hostname`.chomp
32
- @port = opts[:port] || PORT
33
- @path = opts[:path] || PATH
34
- end
35
-
36
- def alert(subservice, state, metric, description)
37
- Vodpod.alert(
38
- :service => "riak #{subservice}",
39
- :state => state,
40
- :metric => metric,
41
- :description => description
42
- )
43
- end
44
-
45
- def check_ring
46
- str = `#{File.expand_path(File.dirname(__FILE__))}/ringready.erl riak@#{`hostname`}`.chomp
47
- if str =~ /^TRUE/
48
- alert 'ring', :ok, nil, str
49
- else
50
- alert 'ring', :warning, nil, str
51
- end
52
- end
53
-
54
- def check_keys
55
- keys = `#{File.expand_path(File.dirname(__FILE__))}/key_count.erl riak@#{`hostname`}`.chomp
56
- if keys =~ /^\d+$/
57
- alert 'keys', :ok, keys.to_i, keys
58
- else
59
- alert 'keys', :error, nil, keys
60
- end
61
- end
62
-
63
- def check_disk
64
- gb = `du -s /var/lib/riak/bitcask/`.split(/\s+/).first.to_i / (1024.0**2)
65
- alert 'disk', :ok, gb, "#{gb} GB in bitcask"
66
- end
67
-
68
- # Returns the riak stat for the given fsm type and percentile.
69
- def fsm_stat(type, percentile)
70
- "node_#{type}_fsm_time_#{percentile == 50 ? 'median' : percentile}"
71
- end
72
-
73
- # Returns the alerts state for the given fsm.
74
- def fsm_state(type, percentile, val)
75
- limit = FSM_LIMITS[type][percentile]
76
- case val
77
- when 0 .. limit
78
- :ok
79
- when limit .. limit * 2
80
- :warning
81
- else
82
- :critical
83
- end
84
- end
85
-
86
- def check_stats
87
- begin
88
- res = Net::HTTP.start(@host, @port) do |http|
89
- http.get('/stats')
90
- end
91
- rescue => e
92
- Vodpod.alert(
93
- :service => 'riak',
94
- :state => :critical,
95
- :description => "error fetching /stats: #{e.class}, #{e.message}"
96
- )
97
- return
98
- end
99
-
100
- if res.code.to_i == 200
101
- stats = JSON.parse(res.body)
102
- else
103
- Vodpod.alert(
104
- :service => 'riak',
105
- :state => :critical,
106
- :description => "stats returned HTTP #{res.code}:\n\n#{res.body}"
107
- )
108
- return
109
- end
110
-
111
- Vodpod.alert(
112
- :service => 'riak',
113
- :state => :ok
114
- )
115
-
116
- # Gets/puts/rr
117
- [
118
- 'vnode_gets',
119
- 'vnode_puts',
120
- 'node_gets',
121
- 'node_puts',
122
- 'read_repairs'
123
- ].each do |s|
124
- alert s, :ok, stats[s]/60.0, "#{stats[s]/60.0}/sec"
125
- end
126
-
127
- # FSMs
128
- [:get, :put].each do |type|
129
- [50, 95, 99].each do |percentile|
130
- val = stats[fsm_stat(type, percentile)] || 0
131
- val = 0 if val == 'undefined'
132
- val /= 1000.0 # Convert us to ms
133
- state = fsm_state(type, percentile, val)
134
- alert "#{type} #{percentile}", state, val, "#{val} ms"
135
- end
136
- end
137
- end
138
-
139
- def run
140
- loop do
141
- # check_keys
142
- check_stats
143
- check_ring
144
- check_disk
145
- sleep INTERVAL
146
- end
147
- end
148
- end
149
-
150
- if $0 == __FILE__
151
- RiakStatus.new.run
152
- end
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env escript
2
- Process.setproctitle($0)
3
- %%! -name riakstatuscheck -setcookie riak -hidden
4
-
5
- main([]) -> main(["riak@127.0.0.1"]);
6
- main([Node]) ->
7
- io:format("~p\n", [
8
- rpc:call(list_to_atom(Node), riak_kv_console, ringready, [[]])
9
- ]).