system_health 0.0.8 → 0.0.9
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 +4 -4
- data/README.md +62 -51
- data/lib/system_health/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d46611b2952413881bc6835fc6346b1402a37184
|
4
|
+
data.tar.gz: e212f39b22d9953e4ad666f2641a20d36c7d379d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8126d5f48e50ffe19475d5a5d450dbe254b247b4e3979ff07a28e5f0899b65776fa05e5a6ec5399586eae76530110982437019b307298607a325fcebf739b7ef
|
7
|
+
data.tar.gz: e37475da47ef504d25037d600957d2f4bbd55012f0d4569916fe489146a02854e331c992dc18b284bd9ac4235fa267e3529f88d1ca4cb4419695927d540176c0
|
data/README.md
CHANGED
@@ -20,79 +20,80 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
and then...
|
22
22
|
|
23
|
-
|
23
|
+
### Create your monitor classes
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
All monitoring classes require a public instance method named `description`.
|
26
|
+
This method should return a string describing the bad data condition that is
|
27
|
+
being tested.
|
28
28
|
|
29
|
-
|
29
|
+
#### Generic monitoring class
|
30
30
|
|
31
|
-
|
31
|
+
For example, in lib/system_health/monitors/bad_data.rb create:
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
```ruby
|
34
|
+
module SystemHealth
|
35
|
+
module Monitors
|
36
|
+
class BadData < Base
|
37
|
+
def description
|
38
|
+
'Bad data was discovered'
|
39
|
+
end
|
40
40
|
|
41
|
-
|
41
|
+
private
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
end
|
43
|
+
def bad_data?
|
44
|
+
# return true from this method if there is bad data
|
46
45
|
end
|
47
46
|
end
|
48
47
|
end
|
49
|
-
|
48
|
+
end
|
49
|
+
```
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
the private instance method `bad_data?` should return true
|
52
|
+
when bad data exists. Note: this class inherits from `Base`.
|
53
53
|
|
54
|
-
|
54
|
+
#### SQL monitoring class
|
55
55
|
|
56
|
-
|
56
|
+
For example, in lib/system_health/monitors/bad_sql_data.rb create:
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
```ruby
|
59
|
+
module SystemHealth
|
60
|
+
module Monitors
|
61
|
+
class BadSqlData < Sql
|
62
|
+
def description
|
63
|
+
'Bad data was discovered through a SQL query'
|
64
|
+
end
|
65
65
|
|
66
|
-
|
66
|
+
private
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
68
|
+
def sql
|
69
|
+
<<-SQL
|
70
|
+
SELECT *
|
71
|
+
FROM some_table
|
72
|
+
WHERE bad_data is true
|
73
|
+
SQL
|
75
74
|
end
|
76
75
|
end
|
77
76
|
end
|
78
|
-
|
77
|
+
end
|
78
|
+
```
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
the private instance method `sql` should include the string version of
|
81
|
+
the SQL to use in the system health check. This SQL should return rows
|
82
|
+
when there is bad data. I.e. no rows returned means no system health problem.
|
83
|
+
Rows returned means there is a problem. Note: this class inherits from
|
84
|
+
`Sql`.
|
84
85
|
|
85
86
|
|
86
|
-
|
87
|
+
### Create an initializer in config/initializers/system_health.rb
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
```ruby
|
90
|
+
SystemHealth.configure do |config|
|
91
|
+
config.monitor_classes = [
|
92
|
+
SystemHealth::Monitors::BadData,
|
93
|
+
SystemHealth::Monitors::BadSqlData
|
94
|
+
]
|
95
|
+
end
|
96
|
+
```
|
96
97
|
|
97
98
|
## Usage
|
98
99
|
|
@@ -106,6 +107,16 @@ mon.error_messages
|
|
106
107
|
mon.error_count
|
107
108
|
```
|
108
109
|
|
110
|
+
by default SystemHealth::Monitor.new uses those classes defined in your
|
111
|
+
initializer but you can initialize with your own classes, if you wish:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
mon =
|
115
|
+
SystemHealth::Monitor.new([SystemMonitor::Monitors::SomeSpecialClass])
|
116
|
+
mon.error_messages
|
117
|
+
mon.error_count
|
118
|
+
```
|
119
|
+
|
109
120
|
## To do?
|
110
121
|
|
111
122
|
1. Add concept of notifiers to make it more seamless to email or report
|