kurchatov 0.0.5.pre5 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +1 -0
  3. data/README.md +6 -7
  4. data/Rakefile +1 -1
  5. data/Vagrantfile +5 -6
  6. data/bin/kurchatov +2 -2
  7. data/examples/check_file_contains.rb +4 -4
  8. data/examples/count_proc.rb +5 -5
  9. data/examples/cpu.rb +5 -5
  10. data/examples/disk.rb +3 -3
  11. data/examples/disk_stat.rb +6 -6
  12. data/examples/dns_check.rb +2 -2
  13. data/examples/exim.rb +1 -1
  14. data/examples/file_age.rb +5 -5
  15. data/examples/find_files.rb +1 -1
  16. data/examples/http.rb +3 -3
  17. data/examples/iptables.rb +3 -3
  18. data/examples/la.rb +12 -12
  19. data/examples/mdadm.rb +1 -1
  20. data/examples/memory.rb +8 -8
  21. data/examples/net.rb +6 -6
  22. data/examples/net_stat.rb +4 -4
  23. data/examples/nfs.rb +2 -2
  24. data/examples/nginx.rb +1 -1
  25. data/examples/nginx_500.rb +8 -8
  26. data/examples/ntp.rb +5 -5
  27. data/examples/openfiles.rb +2 -2
  28. data/examples/pgsql.rb +3 -3
  29. data/examples/ping_icmp.rb +4 -4
  30. data/examples/ping_tcp.rb +4 -4
  31. data/examples/proc_mem.rb +6 -6
  32. data/examples/rabbitmq.rb +4 -4
  33. data/examples/runit.rb +1 -1
  34. data/examples/sidekiq.rb +12 -12
  35. data/examples/sidekiq_queue_state.rb +3 -3
  36. data/examples/status_file.rb +4 -4
  37. data/examples/tw_cli.rb +4 -4
  38. data/examples/uptime.rb +4 -4
  39. data/kurchatov.gemspec +19 -18
  40. data/lib/kurchatov/application.rb +73 -74
  41. data/lib/kurchatov/mashie.rb +32 -27
  42. data/lib/kurchatov/mixin/command.rb +0 -5
  43. data/lib/kurchatov/mixin/event.rb +7 -5
  44. data/lib/kurchatov/mixin/http.rb +4 -4
  45. data/lib/kurchatov/mixin/init.rb +5 -5
  46. data/lib/kurchatov/mixin/ohai.rb +11 -3
  47. data/lib/kurchatov/mixin/queue.rb +7 -4
  48. data/lib/kurchatov/plugin/config.rb +8 -7
  49. data/lib/kurchatov/plugin/dsl.rb +3 -1
  50. data/lib/kurchatov/plugin/riemann.rb +7 -8
  51. data/lib/kurchatov/responders/http.rb +6 -6
  52. data/lib/kurchatov/responders/init.rb +3 -3
  53. data/lib/kurchatov/responders/riemann.rb +2 -4
  54. data/lib/kurchatov/responders/udp.rb +2 -3
  55. data/lib/kurchatov/riemann/client.rb +12 -12
  56. data/lib/kurchatov/riemann/event.rb +1 -1
  57. data/lib/kurchatov/riemann/message.rb +2 -2
  58. data/lib/kurchatov/version.rb +1 -1
  59. data/lib/kurchatov.rb +4 -2
  60. data/lib/ohai/plugins/darwin/cpu.rb +3 -3
  61. data/lib/ohai/plugins/darwin/hostname.rb +3 -3
  62. data/lib/ohai/plugins/darwin/platform.rb +12 -12
  63. data/lib/ohai/plugins/hostname.rb +2 -2
  64. data/lib/ohai/plugins/linux/cpu.rb +29 -29
  65. data/lib/ohai/plugins/linux/hostname.rb +4 -4
  66. data/lib/ohai/plugins/linux/platform.rb +40 -40
  67. data/lib/ohai/plugins/linux/virtualization.rb +51 -51
  68. data/lib/ohai/plugins/os.rb +26 -26
  69. data/lib/ohai/plugins/platform.rb +4 -4
  70. data/lib/ohai/plugins/virtualization.rb +17 -17
  71. data/lib/ohai/plugins/windows/cpu.rb +11 -11
  72. data/lib/ohai/plugins/windows/platform.rb +1 -1
  73. data/tests/run.sh +4 -4
  74. data/tests/server.rb +2 -2
  75. metadata +18 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d9b812d956ce964926a66077100dff0bbc2e9f0
4
- data.tar.gz: d440b2fd8e239385bd9fe137b4084985eef1de09
3
+ metadata.gz: d56d67f5c0e53abde4637ffc9c0ea9e73d9cb5b9
4
+ data.tar.gz: 76270270572fb0917640a25fbbd325c5176266c3
5
5
  SHA512:
6
- metadata.gz: 72c0bb6d6e342539e5ecf4e450467985ae9aba2fe9f5f7033b4588479e3e9b39e9e37c6e914ba4d35e5b9366b04bb74470780106eda3b10df09e0daaf6c05897
7
- data.tar.gz: 59f68d75f37054b7312cc13479221bd61551ff965473b6d1699dcad442481e839a83f7e76360a957fa8f8c9ffa9a25626c17b5d2d6c846ca0984b446f074ae25
6
+ metadata.gz: 77bd8989916268732da475ebc707649c7cd22b77f1803da1b834ad07a2013984a11e95b4989b77e8669067096c6b90528127d2561ff1bddb1a0fcee66827562f
7
+ data.tar.gz: 30796cf0f8942e999bfdb59ffd7cc7d8bd55e814078f2730b9dd3a620509dc253a2e096b87ceb4be9bc02e402a0850094ddee78030b9f83a8f82a802fac28fff
data/CHANGELOG ADDED
@@ -0,0 +1 @@
1
+ * Version 0.0.5: Windows support
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
+ [![Gem Version](https://badge.fury.io/rb/kurchatov.png)](http://badge.fury.io/rb/kurchatov)
1
2
  [![Build Status](https://travis-ci.org/vadv/kurchatov.png)](https://travis-ci.org/vadv/kurchatov)
3
+ [![Code Climate](https://codeclimate.com/github/vadv/kurchatov.png)](https://codeclimate.com/github/vadv/kurchatov)
2
4
 
3
5
  # Kurchatov
4
6
 
@@ -64,7 +66,7 @@ end
64
66
 
65
67
  Больше примеров вы найдете [тут](https://github.com/vadv/kurchatov/tree/master/examples).
66
68
 
67
- ## OHAI
69
+ ## Ohai
68
70
 
69
71
  И в африке ohai. Минимальный пример:
70
72
  ```ruby
@@ -80,7 +82,7 @@ postgres[:version] = stdout.strip
80
82
  Это обычный yml-файл с настройками плагинов, eго удобно генерить chef'ом :)
81
83
  ```yaml
82
84
  plugin name:
83
- settins name:
85
+ settings name:
84
86
  - 'bla-bla'
85
87
  ```
86
88
 
@@ -103,9 +105,6 @@ robots txt watcher: # новый плагин name == 'robots txt watcher'
103
105
 
104
106
  Удобно писать плагины, использовать 1 процесс, 1 коннект, и проч.
105
107
 
106
- Мне не нравиться официальная реализация [riemann-client](https://github.com/aphyr/riemann-ruby-client),
107
- она течет и создает много ненужных *конкретно* для меня полей для протобуфа (но все равно спасибо [aphyr](http://aphyr.com) за
108
- прекрасный сервер :) ), так что вы тут не найдете search и udp.
109
-
110
- Упор сделан на потребление памяти (эх, ruby), поэтому все на тредах и на данный момент на 1.9.3 вы можете получить 8Mb RES.
108
+ Посмотрите официальную реализацию [riemann-client](https://github.com/aphyr/riemann-ruby-client),
109
+ По сравнению с ней вы тут не найдете search и udp.
111
110
 
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
data/Vagrantfile CHANGED
@@ -1,16 +1,15 @@
1
1
  # -*- mode: ruby -*-
2
2
  # vi: set ft=ruby :
3
3
 
4
- Vagrant.configure("2") do |config|
4
+ Vagrant.configure('2') do |config|
5
5
 
6
- config.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box"
7
- config.vm.box = "precise64_kurchatov_gem"
6
+ config.vm.box_url = 'http://files.vagrantup.com/precise64_vmware.box'
7
+ config.vm.box = 'precise64_kurchatov_gem'
8
8
  config.ssh.forward_agent = true
9
9
 
10
10
  config.vm.provider :vmware_fusion do |vmware|
11
- vmware.vm.vmx["memsize"] = "2048"
12
- vmware.vm.gui = false
13
- vmware.box_url = "http://files.vagrantup.com/precise64_vmware.box"
11
+ vmware.vm.vmx['memsize'] = '2048'
12
+ vmware.vm.gui = false
14
13
  end
15
14
 
16
15
  end
data/bin/kurchatov CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- require "kurchatov/application"
4
+ require 'kurchatov/application'
5
5
 
6
- Kurchatov::Aplication.new.run
6
+ Kurchatov::Application.new.run
@@ -3,12 +3,12 @@ interval 60
3
3
  default[:base_uri] = 'http://localhost/check'
4
4
  default[:expression] = 'ERROR'
5
5
  default[:contains] = false # Contains or not expression
6
- default[:service] = "check_file_contains"
6
+ default[:service] = 'check_file_contains'
7
7
 
8
8
  collect do
9
9
  event(
10
- :service => "#{plugin.service} #{plugin.base_uri} #{plugin.expression}",
11
- :description => "#{plugin.base_uri} contains #{plugin.expression}",
12
- :metric => rest_get(plugin.base_uri).include?(plugin.expression) == plugin.contains
10
+ :service => "#{plugin.service} #{plugin.base_uri} #{plugin.expression}",
11
+ :description => "#{plugin.base_uri} contains #{plugin.expression}",
12
+ :metric => rest_get(plugin.base_uri).include?(plugin.expression) == plugin.contains
13
13
  )
14
14
  end
@@ -5,10 +5,10 @@ collect :os => 'linux' do
5
5
  count = 0
6
6
  Dir['/proc/[0-9]*/cmdline'].each { |p| count += 1 if File.read(p) =~ /#{plugin.proc}/ }
7
7
  event(
8
- :service => "count proc #{plugin.proc}",
9
- :metric => count,
10
- :description => "count proc #{plugin.proc}, count: #{count}",
11
- :warning => 5,
12
- :critical => 20
8
+ :service => "count proc #{plugin.proc}",
9
+ :metric => count,
10
+ :description => "count proc #{plugin.proc}, count: #{count}",
11
+ :warning => 5,
12
+ :critical => 20
13
13
  )
14
14
  end
data/examples/cpu.rb CHANGED
@@ -14,13 +14,13 @@ collect :os => 'linux' do
14
14
  _, u2, n2, s2, i2 = [$1, $2, $3, $4, $5].map { |e| e.to_i }
15
15
  unless @old_cpu[cpu_number].nil?
16
16
  u1, n1, s1, i1 = @old_cpu[cpu_number]
17
- used = (u2+n2+s2) - (u1+n1+s1)
18
- total = used + i2-i1
19
- fraction = used.to_f / total
17
+ used = (u2+n2+s2) - (u1+n1+s1)
18
+ total = used + i2-i1
19
+ fraction = used.to_f / total
20
20
  end
21
21
  @old_cpu[cpu_number] = [u2, n2, s2, i2]
22
- service = "cpu usage cpu#{cpu_number}"
23
- description = "Cpu#{cpu_number} usage"
22
+ service = "cpu usage cpu#{cpu_number}"
23
+ description = "Cpu#{cpu_number} usage"
24
24
  if cpu_number == '_total'
25
25
  event(:service => service, :metric => fraction, :desc => description, :warning => 70, :critical => 58)
26
26
  else
data/examples/disk.rb CHANGED
@@ -14,7 +14,7 @@ collect :os => 'linux' do
14
14
  def get_monit_points_for_size
15
15
  monit_points = []
16
16
  File.open('/proc/mounts', 'r') do |file|
17
- while line = file.gets
17
+ while (line = file.gets)
18
18
  mtab = line.split(/\s+/)
19
19
  monit_points << mtab[1] unless plugin.not_monit_fs_4_size.include? mtab[2]
20
20
  end
@@ -25,7 +25,7 @@ collect :os => 'linux' do
25
25
  def get_monit_points_for_fstab
26
26
  monit_points = []
27
27
  File.open('/proc/mounts', 'r') do |file|
28
- while line = file.gets
28
+ while (line = file.gets)
29
29
  mtab = line.split(/\s+/)
30
30
  if plugin.monit_fs_4_fstab.include?(mtab[2]) &&
31
31
  !plugin.not_monit_point_4_fstab.include?(mtab[1]) &&
@@ -38,7 +38,7 @@ collect :os => 'linux' do
38
38
  end
39
39
 
40
40
  get_monit_points_for_size.each do |point|
41
- point_stat = Sys::Filesystem.stat(point)
41
+ point_stat = Sys::Filesystem.stat(point)
42
42
  human_point = point == '/' ? '/root' : point
43
43
  human_point = human_point.gsub(/^\//, '').gsub(/\//, '_')
44
44
  event(:warning => 70, :critical => 85, :service => "disk #{human_point} % block", :desc => "Disk usage #{point}, %", :metric => (1- point_stat.blocks_available.to_f/point_stat.blocks).round(2) * 100) unless point_stat.blocks == 0
@@ -1,21 +1,21 @@
1
1
  always_start true
2
2
  interval 60
3
3
 
4
- default[:words] = [ 'reads reqs', 'reads merged', 'reads sector', 'reads time',
5
- 'writes reqs', 'writes merged', 'writes sector', 'writes time',
6
- 'io reqs', 'io time', 'io weighted' ]
4
+ default[:words] = ['reads reqs', 'reads merged', 'reads sector', 'reads time',
5
+ 'writes reqs', 'writes merged', 'writes sector', 'writes time',
6
+ 'io reqs', 'io time', 'io weighted']
7
7
 
8
- default[:filter] = [ 'reads reqs', 'writes reqs' ]
8
+ default[:filter] = ['reads reqs', 'writes reqs']
9
9
 
10
10
  run_if do
11
11
  File.exists? '/proc/diskstats'
12
12
  end
13
13
 
14
- collect :os => "linux" do
14
+ collect :os => 'linux' do
15
15
  f = File.read('/proc/diskstats')
16
16
  f.split("\n").reject { |d| d =~ /(ram|loop)/ }.inject({}) do |_, line|
17
17
  if line =~ /^(?:\s+\d+){2}\s+([\w\d]+) (.*)$/
18
- dev = $1
18
+ dev = $1
19
19
  values = $2.split(/\s+/).map { |str| str.to_i }
20
20
  next if !!(dev.match /\d+$/ || !(dev.match =~ /^xvd/))
21
21
  plugin.filter.each do |filter|
@@ -1,5 +1,5 @@
1
1
  collect do
2
2
  event(
3
- :state => Resolv::DNS.new.getresources(ohai[:fqdn], Resolv::DNS::Resource::IN::A).count == 1,
4
- :desc => "Check resolv self FQDN")
3
+ :state => Resolv::DNS.new.getresources(ohai[:fqdn], Resolv::DNS::Resource::IN::A).count == 1,
4
+ :desc => 'Check resolv self FQDN')
5
5
  end
data/examples/exim.rb CHANGED
@@ -7,6 +7,6 @@ run_if do
7
7
  end
8
8
 
9
9
  collect do
10
- event(:service => 'exim', :metric => shell(plugin.exim, ' -bpc').to_i,
10
+ event(:service => 'exim', :metric => shell(plugin.exim, ' -bpc').to_i,
11
11
  :desc => 'Exim: count frozen mails', :warning => 5, :critical => 20)
12
12
  end
data/examples/file_age.rb CHANGED
@@ -2,10 +2,10 @@ default[:file] = '/notexists'
2
2
 
3
3
  collect do
4
4
  event(
5
- :service => "#{name} #{plugin.file}",
6
- :metric => (unixnow - File.stat(plugin.file).mtime.to_i).abs.to_f/60,
7
- :description => "File #{plugin.file} age",
8
- :warning => 1,
9
- :critical => 5
5
+ :service => "#{name} #{plugin.file}",
6
+ :metric => (unixnow - File.stat(plugin.file).mtime.to_i).abs.to_f/60,
7
+ :description => "File #{plugin.file} age",
8
+ :warning => 1,
9
+ :critical => 5
10
10
  )
11
11
  end
@@ -9,7 +9,7 @@ default[:age] = 24 * 60 * 60
9
9
  collect do
10
10
  if File.directory?(plugin.dir)
11
11
  count_files = 0
12
- file_mask = Regexp.new(plugin.file_mask)
12
+ file_mask = Regexp.new(plugin.file_mask)
13
13
  Find.find(plugin.dir).each do |file|
14
14
  next unless File.file? file
15
15
  next unless file_mask.match file
data/examples/http.rb CHANGED
@@ -14,9 +14,9 @@ collect do
14
14
 
15
15
  @cmd ||= begin
16
16
  "curl -X#{plugin.http_method} -s --connect-timeout #{plugin.connect_timeout}" +
17
- " #{'--insecure' if plugin.insecure} " +
18
- " -w '%{http_code}\\n' --retry #{plugin.retry} --retry-delay #{plugin.retry_delay}" +
19
- " --max-time #{plugin.max_time} --fail #{plugin.url} -o /dev/null"
17
+ " #{'--insecure' if plugin.insecure} " +
18
+ " -w '%{http_code}\\n' --retry #{plugin.retry} --retry-delay #{plugin.retry_delay}" +
19
+ " --max-time #{plugin.max_time} --fail #{plugin.url} -o /dev/null"
20
20
  end
21
21
 
22
22
  out = shell_out(@cmd).stdout.to_i
data/examples/iptables.rb CHANGED
@@ -20,8 +20,8 @@ collect do
20
20
  end.compact.join("\n")
21
21
 
22
22
  event(
23
- :service => "iptables #{plugin.rule_file}",
24
- :state => current_rules == saved_rules,
25
- :description => "iptables rules different between file: #{plugin.rule_file} and iptables-save"
23
+ :service => "iptables #{plugin.rule_file}",
24
+ :state => current_rules == saved_rules,
25
+ :description => "iptables rules different between file: #{plugin.rule_file} and iptables-save"
26
26
  )
27
27
  end
data/examples/la.rb CHANGED
@@ -3,22 +3,22 @@ interval 60
3
3
 
4
4
  default[:cpu] = ohai[:cpu][:real]
5
5
 
6
- collect :os => "linux" do
6
+ collect :os => 'linux' do
7
7
  event(
8
- :metric => File.read('/proc/loadavg').scan(/[\d\.]+/)[0].to_f,
9
- :desc => 'LA averaged over 1 minute',
10
- :service => 'la la_1',
11
- :warning => plugin.cpu,
12
- :critical => plugin.cpu * 2
8
+ :metric => File.read('/proc/loadavg').scan(/[\d\.]+/)[0].to_f,
9
+ :desc => 'LA averaged over 1 minute',
10
+ :service => 'la la_1',
11
+ :warning => plugin.cpu,
12
+ :critical => plugin.cpu * 2
13
13
  )
14
14
  end
15
15
 
16
- collect :os => "darwin" do
16
+ collect :os => 'darwin' do
17
17
  event(
18
- :metric => shell('uptime | cut -d":" -f4- | sed s/,//g').to_f,
19
- :desc => 'LA averaged over 1 minute',
20
- :service => 'la la_1',
21
- :warning => plugin.cpu,
22
- :critical => plugin.cpu * 2
18
+ :metric => shell('uptime | cut -d":" -f4- | sed s/,//g').to_f,
19
+ :desc => 'LA averaged over 1 minute',
20
+ :service => 'la la_1',
21
+ :warning => plugin.cpu,
22
+ :critical => plugin.cpu * 2
23
23
  )
24
24
  end
data/examples/mdadm.rb CHANGED
@@ -33,7 +33,7 @@ collect do
33
33
  mdstat = File.read('/proc/mdstat').split("\n")
34
34
  mdstat.each_with_index do |line, index|
35
35
  next unless line.include?('blocks')
36
- device = file[index-1].split(':')[0].strip
36
+ device = file[index-1].split(':')[0].strip
37
37
  mdstatus = rm_bracket(line.split(' ').last) # UUU
38
38
  next if status_well?(mdstatus) # пропускаем все збс
39
39
  next if mdstatus == plugin[states][device].to_s # disabled in config
data/examples/memory.rb CHANGED
@@ -3,18 +3,18 @@ always_start true
3
3
 
4
4
  collect :os => 'linux' do
5
5
  m = File.read('/proc/meminfo').split(/\n/).inject({}) do |info, line|
6
- x = line.split(/:?\s+/)
6
+ x = line.split(/:?\s+/)
7
7
  info[x[0]] = x[1].to_i
8
8
  info
9
9
  end
10
10
 
11
- free = m['MemFree'].to_i * 1024
12
- cached = m['Cached'].to_i * 1024
13
- buffers = m['Buffers'].to_i * 1024
14
- total = m['MemTotal'].to_i * 1024
15
- used = total - free
16
- free_bc = free + buffers + cached
17
- fraction = 1 - (free_bc.to_f / total)
11
+ free = m['MemFree'].to_i * 1024
12
+ cached = m['Cached'].to_i * 1024
13
+ buffers = m['Buffers'].to_i * 1024
14
+ total = m['MemTotal'].to_i * 1024
15
+ used = total - free
16
+ free_bc = free + buffers + cached
17
+ fraction = 1 - (free_bc.to_f / total)
18
18
  swap_fraction = m['SwapTotal'] == 0 ? 0 : 1 - m['SwapFree'].to_f/m['SwapTotal']
19
19
 
20
20
  event(:service => 'memory % free', :desc => 'Memory usage, %', :metric => fraction.round(2) * 100, :critical => 85, :warning => 75)
data/examples/net.rb CHANGED
@@ -2,12 +2,12 @@ interval 60
2
2
  always_start true
3
3
 
4
4
  default[:include_alias] = false
5
- default[:filter] = [ 'rx bytes', 'rx errs', 'rx drop', 'tx bytes', 'tx errs', 'tx drop' ]
6
- default[:words] = [ 'rx bytes', 'rx packets', 'rx errs', 'rx drop', 'rx fifo', 'rx frame',
7
- 'rx compressed', 'rx multicast', 'tx bytes', 'tx packets', 'tx drops',
8
- 'tx fifo', 'tx colls', 'tx carrier', 'tx compressed' ]
5
+ default[:filter] = ['rx bytes', 'rx errs', 'rx drop', 'tx bytes', 'tx errs', 'tx drop']
6
+ default[:words] = ['rx bytes', 'rx packets', 'rx errs', 'rx drop', 'rx fifo', 'rx frame',
7
+ 'rx compressed', 'rx multicast', 'tx bytes', 'tx packets', 'tx drops',
8
+ 'tx fifo', 'tx colls', 'tx carrier', 'tx compressed']
9
9
 
10
- collect :os => "linux" do
10
+ collect :os => 'linux' do
11
11
  File.read('/proc/net/dev').each_line do |line|
12
12
  iface = line.split(':')[0].strip
13
13
  iface.gsub!(/\./, '_')
@@ -16,7 +16,7 @@ collect :os => "linux" do
16
16
  plugin.words.map do |service|
17
17
  service
18
18
  end.zip(
19
- $2.split(/\s+/).map { |str| str.to_i }
19
+ $2.split(/\s+/).map { |str| str.to_i }
20
20
  ).each do |service, value|
21
21
  next unless plugin.filter.include? service
22
22
  event(:service => "net #{iface} #{service}", :metric => value.to_f/interval, :diff => true)
data/examples/net_stat.rb CHANGED
@@ -12,14 +12,14 @@ collect do
12
12
  end
13
13
  end
14
14
  filter += " \\) and not dst 127.0.0.1:*"
15
- cmd = 'ss -t -4 -n state established ' + filter + ' | wc -l'
15
+ cmd = 'ss -t -4 -n state established ' + filter + ' | wc -l'
16
16
 
17
17
  count = shell!(cmd).to_i - 1
18
18
 
19
19
  event(
20
- :service => "netstat tcp #{plugin.ports.join(', ')}",
21
- :metric => count,
22
- :description => "count established connects: #{count} to ports #{plugin.ports.join(', ')}"
20
+ :service => "netstat tcp #{plugin.ports.join(', ')}",
21
+ :metric => count,
22
+ :description => "count established connects: #{count} to ports #{plugin.ports.join(', ')}"
23
23
  )
24
24
 
25
25
  end
data/examples/nfs.rb CHANGED
@@ -3,7 +3,7 @@ default[:file] = '/tmp/file'
3
3
 
4
4
  collect do
5
5
  event(
6
- :state => system("test -f #{file.file}"),
7
- :desc => "Check file #{file.file}"
6
+ :state => system("test -f #{file.file}"),
7
+ :desc => "Check file #{file.file}"
8
8
  )
9
9
  end
data/examples/nginx.rb CHANGED
@@ -10,7 +10,7 @@ run_if do
10
10
  File.exists? plugin.file
11
11
  end
12
12
 
13
- collect :os => "linux" do
13
+ collect :os => 'linux' do
14
14
  lines = http_get(plugin.url).split("\n")
15
15
  lines[2].scan(/\d+/).each_with_index do |value, index|
16
16
  event(:service => "nginx #{plugin.nginx_status_1[index]}", :metric => value.to_f/interval, :diff => true)
@@ -27,7 +27,7 @@ collect do
27
27
  file = File::Tail::Logfile.new(plugin.file)
28
28
  file.backward(plugin.check_last_lines)
29
29
  file.readlines.each do |line|
30
- line.force_encoding("UTF-8")
30
+ line.force_encoding('UTF-8')
31
31
  next unless line.valid_encoding?
32
32
  time = get_unix_time_from_line(line)
33
33
  count_interval += 1 if time > (unixnow - plugin.interval)
@@ -35,14 +35,14 @@ collect do
35
35
  end
36
36
 
37
37
  event(
38
- :service => "nginx log parse #{plugin.file} interval errors",
39
- :metric => count_all,
40
- :desc => "Count errors in file #{plugin.file}, last #{plugin.check_interval} sec"
38
+ :service => "nginx log parse #{plugin.file} interval errors",
39
+ :metric => count_all,
40
+ :desc => "Count errors in file #{plugin.file}, last #{plugin.check_interval} sec"
41
41
  )
42
42
  event(
43
- :service => "nginx log parse #{plugin.file} realtime errors",
44
- :metric => count_interval,
45
- :state => 'ok',
46
- :desc => "Count errors in file #{plugin.file}, last #{plugin.interval} sec"
43
+ :service => "nginx log parse #{plugin.file} realtime errors",
44
+ :metric => count_interval,
45
+ :state => 'ok',
46
+ :desc => "Count errors in file #{plugin.file}, last #{plugin.interval} sec"
47
47
  )
48
48
  end
data/examples/ntp.rb CHANGED
@@ -6,10 +6,10 @@ default[:timeout] = 30
6
6
 
7
7
  collect do
8
8
  event(
9
- :service => "ntp #{plugin.host}",
10
- :desc => "Ntp lag with host #{plugin.host}",
11
- :metric => (::Net::NTP.get(plugin.host, 'ntp', plugin.timeout).time.to_f - Time.now.to_f).abs,
12
- :critical => 0.5,
13
- :warning => 0.1
9
+ :service => "ntp #{plugin.host}",
10
+ :desc => "Ntp lag with host #{plugin.host}",
11
+ :metric => (::Net::NTP.get(plugin.host, 'ntp', plugin.timeout).time.to_f - Time.now.to_f).abs,
12
+ :critical => 0.5,
13
+ :warning => 0.1
14
14
  )
15
15
  end
@@ -1,6 +1,6 @@
1
1
  collect do
2
2
  event(
3
- :metric => File.read('/proc/sys/fs/file-nr').split(' ').first.to_i,
4
- :description => "Number of allocated file handles"
3
+ :metric => File.read('/proc/sys/fs/file-nr').split(' ').first.to_i,
4
+ :description => 'Number of allocated file handles'
5
5
  )
6
6
  end
data/examples/pgsql.rb CHANGED
@@ -27,14 +27,14 @@ collect do
27
27
  def run_master_sql
28
28
  run_sql("create database #{plugin.db4monit}") unless db4monit_exists?
29
29
  run_sql(
30
- "drop table if exists timestamp; \
30
+ "drop table if exists timestamp; \
31
31
  create table timestamp ( id int primary key, value timestamp default now() ); \
32
32
  insert into timestamp (id) values (1); \
33
- ", plugin.db4monit)
33
+ ", plugin.db4monit)
34
34
  end
35
35
 
36
36
  def repl_lag
37
- unixnow - run_sql("select extract(epoch from value::timestamp) from timestamp where id = 1;", plugin.db4monit).to_i
37
+ unixnow - run_sql('select extract(epoch from value::timestamp) from timestamp where id = 1;', plugin.db4monit).to_i
38
38
  end
39
39
 
40
40
  def connections
@@ -1,12 +1,12 @@
1
1
  require 'net/ping'
2
2
 
3
3
  interval 60
4
- default[:host] = "localhost"
4
+ default[:host] = 'localhost'
5
5
 
6
6
  collect do
7
7
  event(
8
- :service => "ping icmp #{plugin.host}",
9
- :state => ::Net::Ping::External.new(ip).ping,
10
- :description => "ping icmp host: #{plugin.host}"
8
+ :service => "ping icmp #{plugin.host}",
9
+ :state => ::Net::Ping::External.new(ip).ping,
10
+ :description => "ping icmp host: #{plugin.host}"
11
11
  )
12
12
  end
data/examples/ping_tcp.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  require 'net/ping'
2
2
 
3
- default[:host] = "localhost"
3
+ default[:host] = 'localhost'
4
4
  default[:port] = 22
5
5
  default[:timeout] = 5
6
6
 
7
7
  collect do
8
8
  ::Net::Ping::TCP.econnrefused = true
9
9
  event(
10
- :service => "ping tcp #{plugin.host}:#{plugin.port}",
11
- :state => ::Net::Ping::TCP.new(plugin.host, plugin.port, plugin.timeout).ping,
12
- :description => "Ping tcp #{plugin.host}:#{plugin.port}"
10
+ :service => "ping tcp #{plugin.host}:#{plugin.port}",
11
+ :state => ::Net::Ping::TCP.new(plugin.host, plugin.port, plugin.timeout).ping,
12
+ :description => "Ping tcp #{plugin.host}:#{plugin.port}"
13
13
  )
14
14
  end
data/examples/proc_mem.rb CHANGED
@@ -13,12 +13,12 @@ collect do
13
13
  end
14
14
 
15
15
  event(
16
- :diff => true,
17
- :description => "RSS usage delta #{plugin.pidfile}",
18
- :metric => mem_total,
19
- :service => "procmem #{plugin.pidfile}",
20
- :warning => 30*1024, #kibibytes
21
- :critical => 90*1024
16
+ :diff => true,
17
+ :description => "RSS usage delta #{plugin.pidfile}",
18
+ :metric => mem_total,
19
+ :service => "procmem #{plugin.pidfile}",
20
+ :warning => 30*1024, #kibibytes
21
+ :critical => 90*1024
22
22
  ) if File.stat(plugin.pidfile).mtime > interval
23
23
 
24
24
  end
data/examples/rabbitmq.rb CHANGED
@@ -6,10 +6,10 @@ collect do
6
6
  vhost_uri = "#{plugin.api_url}/queues/#{CGI.escape(vhost)}"
7
7
  JSON.parse(rest_get(vhost_uri)).each do |queue|
8
8
  event(
9
- :service => "rabbitmq queue #{queue['name'].gsub('.', '_')} messages count",
10
- :metric => queue['messages'].to_i,
11
- :desc => "Rabbitmq queue count in #{queue['name']}",
12
- :critical => 1000
9
+ :service => "rabbitmq queue #{queue['name'].gsub('.', '_')} messages count",
10
+ :metric => queue['messages'].to_i,
11
+ :desc => "Rabbitmq queue count in #{queue['name']}",
12
+ :critical => 1000
13
13
  )
14
14
  end
15
15
  end
data/examples/runit.rb CHANGED
@@ -27,7 +27,7 @@ collect do
27
27
  Dir.glob('/etc/service/*').each do |srv|
28
28
  srv_uptime = uptime(srv)
29
29
  srv_runned = runned?(srv)
30
- srv_name = human_srv(srv)
30
+ srv_name = human_srv(srv)
31
31
 
32
32
  # сервис запущен и работает дольше чем мы приходили к нему в прошлый раз
33
33
  if srv_runned && srv_uptime > interval
data/examples/sidekiq.rb CHANGED
@@ -2,20 +2,20 @@ default[:url] = 'http://localhost/admin/sidekiq/dashboard/stats'
2
2
 
3
3
  collect do
4
4
  stats = JSON.parse(rest_get(plugin.url))
5
- stats = stats["sidekiq"] ? stats["sidekiq"] : stats
5
+ stats = stats['sidekiq'] ? stats['sidekiq'] : stats
6
6
  event(
7
- :service => "#{name} #{plugin.url}",
8
- :metric => stats["enqueued"].to_i,
9
- :description => "sidekiq queue from #{plugin.url}",
10
- :warning => 10,
11
- :critical => 60
7
+ :service => "#{name} #{plugin.url}",
8
+ :metric => stats['enqueued'].to_i,
9
+ :description => "sidekiq queue from #{plugin.url}",
10
+ :warning => 10,
11
+ :critical => 60
12
12
  )
13
13
  event(
14
- :service => "#{name} #{plugin.url}",
15
- :metric => stats["failed"].to_i,
16
- :diff => true,
17
- :description => "sidekiq failed from #{plugin.url}",
18
- :warning => 10,
19
- :critical => 60
14
+ :service => "#{name} #{plugin.url}",
15
+ :metric => stats['failed'].to_i,
16
+ :diff => true,
17
+ :description => "sidekiq failed from #{plugin.url}",
18
+ :warning => 10,
19
+ :critical => 60
20
20
  )
21
21
  end
@@ -2,8 +2,8 @@ default[:url] = 'http://localhost/sidekiq/queue-state'
2
2
 
3
3
  collect do
4
4
  event(
5
- :service => "#{name} #{plugin.url}",
6
- :metric => rest_get(plugin.url).strip == "OK",
7
- :description => "sidekiq queue status #{plugin.url}"
5
+ :service => "#{name} #{plugin.url}",
6
+ :metric => rest_get(plugin.url).strip == 'OK',
7
+ :description => "sidekiq queue status #{plugin.url}"
8
8
  )
9
9
  end