htmon-icinga 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9952df5eb685c8cb83f8d80e175e25b003c6f1f5
4
- data.tar.gz: 0342bdf7363b641578d3df89af853c80af597e02
3
+ metadata.gz: 975f860c3dbe63fa993da6d88ed798598d07050b
4
+ data.tar.gz: 8107e4dbfa9b736eeaeed59a74142ba3a5fd87b3
5
5
  SHA512:
6
- metadata.gz: f8ab6af47d9c15c4a5d0cd34ed562b60b5b29408903af40b296d40879f69860361914c3cd399496232e1cc736492544540b70d4d92b6650db1d602bc0e2ea950
7
- data.tar.gz: 6f26765b79b1521370cbd6c4bf104cd6376d7db2e570681e29b7c82dd5b9e6b09a7c6d16b50d0428aa890f73b48dce1254a4ab0a9f1dfa20cfdbf6e3a1a09f4e
6
+ metadata.gz: 49794963fa57bb71e01a6b103cf175fc33d1482629a7f0eb5f8431ffbfc4ab3cb952ba7c6b17ef51cf48bdea8367d0d545bab806bb091f1857d29824d2972a27
7
+ data.tar.gz: 26251938ccfe89451a5868225bdd30ef5c63248d43a8fd6d4c2555841285d41e64988de58b620056b78efae809d5ae23920cc5823565ebe0ff2efcd3bb6e8df4
data/exe/check_htmon CHANGED
File without changes
data/htmon-icinga.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rspec", "~> 3.0"
24
24
 
25
25
  spec.add_dependency "redis"
26
+ spec.add_dependency "activesupport"
26
27
  end
@@ -4,10 +4,11 @@ module Htmon
4
4
 
5
5
  def self.new hostname: nil, metric: nil, thresh: nil, warn: nil, redis: nil
6
6
  a = Module.modules.find do |x|
7
- x.metric_name.to_s == metric.to_s
7
+ x.metric_name.to_s == metric.to_s[/^[^:]+/]
8
8
  end
9
9
  if a
10
- a.new(hostname: hostname, thresh: thresh, warn: warn, redis: redis)
10
+ a.new(hostname: hostname, thresh: thresh, warn: warn,
11
+ redis: redis, metric: metric)
11
12
  else
12
13
  raise "No module found"
13
14
  end
@@ -63,7 +64,7 @@ module Htmon
63
64
  end
64
65
 
65
66
  def metric_name
66
- @metric_name || name.downcase[/::([^:]+)$/,1]
67
+ @metric_name || name.gsub(/^Htmon::Icinga::Module::/, '').underscore
67
68
  end
68
69
 
69
70
  def callback method, &block
@@ -77,10 +78,10 @@ module Htmon
77
78
 
78
79
  end
79
80
 
80
- attr_accessor :hostname, :thresh, :warn, :redis
81
+ attr_accessor :hostname, :thresh, :warn, :redis, :metric
81
82
 
82
- def initialize hostname: nil, thresh: nil, warn: nil, redis: nil
83
- @hostname, @thresh, @warn, @redis = hostname, thresh, warn, redis
83
+ def initialize hostname: nil, thresh: nil, warn: nil, redis: nil, metric: nil
84
+ @hostname, @thresh, @warn, @redis, @metric = hostname, thresh, warn, redis, metric
84
85
  end
85
86
 
86
87
  def redis
@@ -89,7 +90,7 @@ module Htmon
89
90
 
90
91
  def result
91
92
  hv = self.class.callbacks[:handle_value]
92
- post_value = hv ? hv.call(value) : value
93
+ post_value = hv ? hv.call(value, self.metric) : value
93
94
  %i{on_ok on_warn on_crit}.map do |type|
94
95
  c = self.class.callbacks[type]
95
96
  ret = Result.new
@@ -106,7 +107,7 @@ module Htmon
106
107
  end
107
108
 
108
109
  def value
109
- @value ||= redis.get "metric::#{hostname}::#{self.class.metric_name}"
110
+ @value ||= redis.get "metric::#{hostname}::#{self.metric}"
110
111
  end
111
112
 
112
113
  end
@@ -114,4 +115,5 @@ module Htmon
114
115
  end
115
116
 
116
117
  require_relative 'modules/keepalive'
118
+ require_relative 'modules/process'
117
119
 
@@ -14,10 +14,6 @@ module Htmon
14
14
  "Keepalive not received" if value.nil?
15
15
  end
16
16
 
17
- performance_data do |value|
18
- "signals=#{value}"
19
- end
20
-
21
17
  end
22
18
  end
23
19
  end
@@ -0,0 +1,27 @@
1
+
2
+ module Htmon
3
+ module Icinga
4
+ class Module
5
+ class Process < Module
6
+
7
+ Value ||= Struct.new(:amount,:name)
8
+
9
+ callback :handle_value do |value, metric|
10
+ Value.new(value.to_i, metric.split("::").last)
11
+ end
12
+
13
+ callback :on_ok do |value, warn, thresh|
14
+ if value.amount > 0
15
+ "Process #{value.name.inspect} are #{value.amount} times present "+
16
+ "| signals=#{value.amount}"
17
+ end
18
+ end
19
+
20
+ callback :on_crit do |value, warn, thresh|
21
+ "Process #{value.name.inspect} not running" unless value.amount > 0
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  module Htmon
2
2
  module Icinga
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
data/lib/htmon/icinga.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'redis'
2
+ require 'active_support/all'
2
3
  require "htmon/icinga/version"
3
4
  require "htmon/icinga/module"
4
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htmon-icinga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Foerster
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description:
70
84
  email:
71
85
  - github@mailserver.1n3t.de
@@ -88,6 +102,7 @@ files:
88
102
  - lib/htmon/icinga.rb
89
103
  - lib/htmon/icinga/module.rb
90
104
  - lib/htmon/icinga/modules/keepalive.rb
105
+ - lib/htmon/icinga/modules/process.rb
91
106
  - lib/htmon/icinga/version.rb
92
107
  homepage: https://github.com/timmyArch/htmon-icinga
93
108
  licenses: