easymon 1.4.2 → 1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/easymon/checks/active_record_mysql_writeable_check.rb +26 -0
- data/lib/easymon/checks/redis_writeable_check.rb +36 -0
- data/lib/easymon/version.rb +1 -1
- data/lib/easymon.rb +2 -0
- data/test/dummy/log/development.log +24 -66
- data/test/dummy/log/test.log +6934 -1282
- data/test/dummy/tmp/cache/4D4/7A0/health_check +1 -1
- data/test/unit/checks/active_record_mysql_writeable_check_test.rb +27 -0
- data/test/unit/checks/redis_writeable_check_test.rb +28 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46eed6312dd05be2f1cc453b481dbbe26cbed28e6a9954d68aee4ed96b5d2935
|
4
|
+
data.tar.gz: 57a512d8baf55d331a7386ccc80ea9879820cb2775327d321ba8d11d0b630660
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfe6ee337e9353b08dd9dcb7b807f2f8881d471e884257fd8a21e48bf29f79fb6680ba29a56b2cea2b40ac365d46ca9566fa89c1df98808832e11bf93d45ee66
|
7
|
+
data.tar.gz: 13e4c388db907301c04ed04a3fe25b8eba77b78e88496d3b1ac1a993980fb65ecf75db24c91b1f90ad230b47ad4c70919b973b587280a7ec9bd95d6b09433291
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Easymon
|
2
|
+
class ActiveRecordMysqlWriteableCheck
|
3
|
+
attr_accessor :klass
|
4
|
+
|
5
|
+
def initialize(klass)
|
6
|
+
self.klass = klass
|
7
|
+
end
|
8
|
+
|
9
|
+
def check
|
10
|
+
check_status = database_writeable?
|
11
|
+
if check_status
|
12
|
+
message = "@@read_only is 0"
|
13
|
+
else
|
14
|
+
message = "@@read_only is 1"
|
15
|
+
end
|
16
|
+
[check_status, message]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def database_writeable?
|
21
|
+
klass.connection.execute("SELECT @@read_only").entries.flatten.first == 0
|
22
|
+
rescue
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "redis"
|
2
|
+
|
3
|
+
module Easymon
|
4
|
+
class RedisWriteableCheck
|
5
|
+
attr_accessor :config
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
self.config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def check
|
12
|
+
check_status = redis_writeable?
|
13
|
+
message = check_status ? "Writeable" : "Read Only"
|
14
|
+
|
15
|
+
[check_status, message]
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def redis_writeable?
|
20
|
+
redis = Redis.new(@config)
|
21
|
+
key = "easymon_#{Time.now.to_i}"
|
22
|
+
reply = redis.set(key, "true")
|
23
|
+
redis.del(key)
|
24
|
+
|
25
|
+
reply == "OK"
|
26
|
+
rescue
|
27
|
+
false
|
28
|
+
ensure
|
29
|
+
if redis.respond_to? :close
|
30
|
+
redis.close # Redis 4+
|
31
|
+
else
|
32
|
+
redis.client.disconnect # Older redis
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/easymon/version.rb
CHANGED
data/lib/easymon.rb
CHANGED
@@ -8,8 +8,10 @@ require "easymon/repository"
|
|
8
8
|
require "easymon/result"
|
9
9
|
|
10
10
|
require "easymon/checks/active_record_check"
|
11
|
+
require "easymon/checks/active_record_mysql_writeable_check"
|
11
12
|
require "easymon/checks/split_active_record_check"
|
12
13
|
require "easymon/checks/redis_check"
|
14
|
+
require "easymon/checks/redis_writeable_check"
|
13
15
|
require "easymon/checks/memcached_check"
|
14
16
|
require "easymon/checks/semaphore_check"
|
15
17
|
require "easymon/checks/traffic_enabled_check"
|
@@ -1,66 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
Started GET "/up/foobar" for 127.0.0.1 at 2018-11-08 22:49:15 -0500
|
26
|
-
Processing by Easymon::ChecksController#show as */*
|
27
|
-
Parameters: {"check"=>"foobar"}
|
28
|
-
Rendering text template
|
29
|
-
Rendered text template (0.0ms)
|
30
|
-
Completed 404 Not Found in 1ms (Views: 0.5ms)
|
31
|
-
|
32
|
-
|
33
|
-
DEPRECATION WARNING: Using `Rails::Application` subclass to start the server is deprecated and will be removed in Rails 6.0. Please change `run Dummy::Application` to `run Rails.application` in config.ru. (called from require at script/rails:6)
|
34
|
-
Started GET "/up/critical/foobar" for 127.0.0.1 at 2018-11-08 22:50:46 -0500
|
35
|
-
|
36
|
-
ActionController::RoutingError (No route matches [GET] "/up/critical/foobar"):
|
37
|
-
|
38
|
-
actionpack (5.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call'
|
39
|
-
actionpack (5.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
|
40
|
-
railties (5.2.1) lib/rails/rack/logger.rb:38:in `call_app'
|
41
|
-
railties (5.2.1) lib/rails/rack/logger.rb:26:in `block in call'
|
42
|
-
activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `block in tagged'
|
43
|
-
activesupport (5.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
|
44
|
-
activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `tagged'
|
45
|
-
railties (5.2.1) lib/rails/rack/logger.rb:26:in `call'
|
46
|
-
actionpack (5.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
|
47
|
-
actionpack (5.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
|
48
|
-
rack (2.0.6) lib/rack/method_override.rb:22:in `call'
|
49
|
-
rack (2.0.6) lib/rack/runtime.rb:22:in `call'
|
50
|
-
activesupport (5.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
|
51
|
-
actionpack (5.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
|
52
|
-
actionpack (5.2.1) lib/action_dispatch/middleware/static.rb:127:in `call'
|
53
|
-
rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
|
54
|
-
railties (5.2.1) lib/rails/engine.rb:524:in `call'
|
55
|
-
rack (2.0.6) lib/rack/handler/webrick.rb:86:in `service'
|
56
|
-
/Users/nathan/.rbenv/versions/2.5.3/lib/ruby/2.5.0/webrick/httpserver.rb:140:in `service'
|
57
|
-
/Users/nathan/.rbenv/versions/2.5.3/lib/ruby/2.5.0/webrick/httpserver.rb:96:in `run'
|
58
|
-
/Users/nathan/.rbenv/versions/2.5.3/lib/ruby/2.5.0/webrick/server.rb:307:in `block in start_thread'
|
59
|
-
Started GET "/up/critical" for 127.0.0.1 at 2018-11-08 22:51:07 -0500
|
60
|
-
Processing by Easymon::ChecksController#show as */*
|
61
|
-
Parameters: {"check"=>"critical"}
|
62
|
-
Rendering text template
|
63
|
-
Rendered text template (0.0ms)
|
64
|
-
Completed 503 Service Unavailable in 29ms (Views: 0.5ms)
|
65
|
-
|
66
|
-
|
1
|
+
[1m[35m (0.3ms)[0m [1m[35mSET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483[0m
|
2
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE DATABASE `dummy_development` DEFAULT CHARACTER SET `utf8`[0m
|
3
|
+
[1m[35m (0.3ms)[0m [1m[35mSET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483[0m
|
4
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE DATABASE `dummy_test` DEFAULT CHARACTER SET `utf8`[0m
|
5
|
+
[1m[35m (0.3ms)[0m [1m[35mSET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483[0m
|
6
|
+
[1m[35m (0.3ms)[0m [1m[35mSET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483[0m
|
7
|
+
[1m[35m (25.9ms)[0m [1m[35mCREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL PRIMARY KEY)[0m
|
8
|
+
[1m[35m (20.9ms)[0m [1m[35mCREATE TABLE `ar_internal_metadata` (`key` varchar(255) NOT NULL PRIMARY KEY, `value` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL)[0m
|
9
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT GET_LOCK('1721091371569202325', 0)[0m
|
10
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC[0m
|
11
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.2ms)[0m [1m[34mSELECT `ar_internal_metadata`.* FROM `ar_internal_metadata` WHERE `ar_internal_metadata`.`key` = 'environment' LIMIT 1[0m
|
12
|
+
[1m[35m (0.1ms)[0m [1m[35mBEGIN[0m
|
13
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.2ms)[0m [1m[32mINSERT INTO `ar_internal_metadata` (`key`, `value`, `created_at`, `updated_at`) VALUES ('environment', 'development', '2022-05-04 18:01:28', '2022-05-04 18:01:28')[0m
|
14
|
+
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
15
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT RELEASE_LOCK('1721091371569202325')[0m
|
16
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT @@read_only[0m
|
17
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT @@read_only[0m
|
18
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT @@read_only[0m
|
19
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT @@read_only;[0m
|
20
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT @@read_only;[0m
|
21
|
+
[1m[35m (3.2ms)[0m [1m[34mSELECT @@read_only;[0m
|
22
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT @@read_only[0m
|
23
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT @@read_only;[0m
|
24
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC[0m
|