servicemonitor 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/servicemonitor +2 -1
- data/lib/MonitorType/HttpGetJsonList.rb +57 -0
- data/lib/MonitorType.rb +5 -5
- metadata +9 -8
data/bin/servicemonitor
CHANGED
@@ -12,6 +12,7 @@ require "MonitorType/Beanstalk"
|
|
12
12
|
require "MonitorType/Dir"
|
13
13
|
require "MonitorType/FluidDb"
|
14
14
|
require "MonitorType/Process"
|
15
|
+
require "MonitorType/HttpGetJsonList"
|
15
16
|
require "MonitorManager"
|
16
17
|
require "helper_functions"
|
17
18
|
|
@@ -23,7 +24,7 @@ abort( "Usage: servicemonitor <path to dsl>" ) if ARGV.length != 1
|
|
23
24
|
|
24
25
|
dslName = ARGV[0]
|
25
26
|
|
26
|
-
#Need to remove file name extension
|
27
|
+
#Need to remove file name extension
|
27
28
|
ENV["APP_NAME"] = File.basename( dslName ) if ENV["APP_NAME"].nil?
|
28
29
|
|
29
30
|
$a = MonitorManager.new
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "restclient"
|
2
|
+
require "MonitorType/Threshold"
|
3
|
+
|
4
|
+
#An http class for checking the length of a json list.
|
5
|
+
# For example,
|
6
|
+
# Get the list of outstandinig errors
|
7
|
+
# => check that the number is not greater than 2
|
8
|
+
|
9
|
+
class MonitorType_HttpGetJsonList<MonitorType_Threshold
|
10
|
+
|
11
|
+
#Extract parameters
|
12
|
+
#
|
13
|
+
# @param [String] uri Connection string to db
|
14
|
+
# @param [String] sql SQL statement to gather a single value
|
15
|
+
def extractParams
|
16
|
+
if @params[:uri].nil? then
|
17
|
+
string = "*** HttpGetJsonList parameter missing, uri\n"
|
18
|
+
string = "#{string}*** :uri => <uri pointing to url to be monitored>"
|
19
|
+
raise MonitorTypeParameterMissingError.new(string)
|
20
|
+
end
|
21
|
+
begin
|
22
|
+
@uri = URI.parse( @params[:uri] )
|
23
|
+
rescue URI::InvalidURIError=>e
|
24
|
+
string = "*** HttpGetJsonList encountered an error while parsing the uri"
|
25
|
+
string = "#{string}*** uri: #{@params[:uri]}"
|
26
|
+
string = "#{string}*** Please fix the uri and run again"
|
27
|
+
raise MonitorTypeParameterMissingError.new(string)
|
28
|
+
end
|
29
|
+
|
30
|
+
url = "#{@uri.scheme}://#{@uri.host}#{@uri.path}"
|
31
|
+
@context_sentence = "Checking size of json list returned from, #{url}"
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def getValue
|
36
|
+
begin
|
37
|
+
content = RestClient.get( @uri.to_s )
|
38
|
+
list = JSON.parse( content )
|
39
|
+
raise MonitorTypeExceptionHandled.new( "Expected type, Array - Actual type, #{list.class.name}") unless list.class.name == "Array"
|
40
|
+
return list.length
|
41
|
+
|
42
|
+
rescue MonitorTypeExceptionHandled=>e
|
43
|
+
raise e
|
44
|
+
|
45
|
+
rescue Exception=>e
|
46
|
+
string = "*** HttpGetJsonList encountered an error while running the HTTP Get\n"
|
47
|
+
string = "#{string}*** uri: #{@uri}\n"
|
48
|
+
string = "#{string}*** Please fix the query and run again\n"
|
49
|
+
|
50
|
+
raise MonitorTypeExceptionHandled.new(string)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def httpgetjsonlist( params )
|
56
|
+
$a.add( MonitorType_HttpGetJsonList.new( params ) )
|
57
|
+
end
|
data/lib/MonitorType.rb
CHANGED
@@ -63,19 +63,19 @@ class MonitorType
|
|
63
63
|
|
64
64
|
log "Loaded Monitor, #{@name}."
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
#Overload this method if any parameters should be checked in context
|
68
68
|
def extractParams
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
#Overload this method if any parameters should be checked in context
|
72
72
|
def setup
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
#Overload this method if any parameters should be checked in context
|
76
76
|
def teardown
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
#Check if the monitor has tripped
|
80
80
|
def process
|
81
81
|
raise "Method needs to be overridden"
|
@@ -113,5 +113,5 @@ class MonitorType
|
|
113
113
|
puts body
|
114
114
|
end
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servicemonitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parse-cron
|
16
|
-
requirement: &
|
16
|
+
requirement: &70285031820400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70285031820400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: beanstalk-client
|
27
|
-
requirement: &
|
27
|
+
requirement: &70285031819720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70285031819720
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fluiddb
|
38
|
-
requirement: &
|
38
|
+
requirement: &70285031819020 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70285031819020
|
47
47
|
description: The fastest way to reliably monitor your system.
|
48
48
|
email: guy@guyirvine.com
|
49
49
|
executables:
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/MonitorType/Dir.rb
|
60
60
|
- lib/MonitorType/Drive.rb
|
61
61
|
- lib/MonitorType/FluidDb.rb
|
62
|
+
- lib/MonitorType/HttpGetJsonList.rb
|
62
63
|
- lib/MonitorType/Process.rb
|
63
64
|
- lib/MonitorType/Threshold.rb
|
64
65
|
- lib/MonitorType.rb
|