detector 0.8.1 → 0.8.2
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/bin/detector +5 -1
- data/lib/detector/addons/mariadb.rb +11 -0
- data/lib/detector/addons/mysql.rb +15 -1
- data/lib/detector/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1005a81a12b0ba3854590f05209d1c420a32fa1a01ff6e12b6ce8e8d98aebc9
|
4
|
+
data.tar.gz: 071f0840a62f62af205f42e2fc314e5a0b02a202f229d7aaa91b89deb2b29ea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77b605d95e6ba1f5aab74d2060121b28bd44ee6057e4d6ceecf153e79065d7287a17e0b9e046cb24f7e056a4af53d445b757b02fc7a20e0be1eb1f7039206178
|
7
|
+
data.tar.gz: 05d528909480534ded0b1ce8b89aad390465e53713b8a8e8e5895d8a282a2bc7dc503ec1e3a82fc2aff4a203e0e71dfe6143b4fee4d8914b377b65d4ea427593
|
data/bin/detector
CHANGED
@@ -50,7 +50,11 @@ puts "Host: #{detector.host}:#{detector.port}"
|
|
50
50
|
|
51
51
|
if detector.respond_to?(:connection_info) && detector.connection_info
|
52
52
|
conn_info = detector.connection_info
|
53
|
-
|
53
|
+
if conn_info[:error]
|
54
|
+
puts "Connections: #{conn_info[:error]}"
|
55
|
+
else
|
56
|
+
puts "Connections: global #{conn_info[:connection_count][:global]}/#{conn_info[:connection_limits][:global]} (user #{conn_info[:connection_count][:user]}/#{conn_info[:connection_limits][:user]})"
|
57
|
+
end
|
54
58
|
elsif detector.connection_count && detector.connection_limit
|
55
59
|
usage = detector.connection_usage_percentage
|
56
60
|
puts "Connections: #{detector.connection_count}/#{detector.connection_limit} (#{usage}%)"
|
@@ -68,6 +68,17 @@ module Detector
|
|
68
68
|
connection_count: { user: user_count, global: global_count },
|
69
69
|
connection_limits: { user: user_limit, global: global_limit }
|
70
70
|
}
|
71
|
+
rescue Mysql2::Error => e
|
72
|
+
if e.error_number == 1226 # User has exceeded max_user_connections
|
73
|
+
{
|
74
|
+
connection_count: { user: "LIMIT EXCEEDED", global: "N/A" },
|
75
|
+
connection_limits: { user: "EXCEEDED", global: "N/A" },
|
76
|
+
error: "Error: User has exceeded max_user_connections limit"
|
77
|
+
}
|
78
|
+
else
|
79
|
+
puts "Error getting connection info: #{e.message}"
|
80
|
+
nil
|
81
|
+
end
|
71
82
|
rescue => e
|
72
83
|
puts "Error getting connection info: #{e.message}"
|
73
84
|
nil
|
@@ -18,7 +18,11 @@ module Detector
|
|
18
18
|
username: uri.user,
|
19
19
|
password: uri.password,
|
20
20
|
database: uri.path[1..-1],
|
21
|
-
port: port
|
21
|
+
port: port,
|
22
|
+
connect_timeout: 5,
|
23
|
+
read_timeout: 10,
|
24
|
+
write_timeout: 10,
|
25
|
+
init_command: "SET wait_timeout=900; SET interactive_timeout=900;"
|
22
26
|
) rescue nil
|
23
27
|
end
|
24
28
|
|
@@ -109,6 +113,16 @@ module Detector
|
|
109
113
|
connection_count: { user: user_count, global: global_count },
|
110
114
|
connection_limits: { user: user_limit, global: global_limit }
|
111
115
|
}
|
116
|
+
rescue Mysql2::Error => e
|
117
|
+
if e.error_number == 1226 # User has exceeded max_user_connections
|
118
|
+
{
|
119
|
+
connection_count: { user: "LIMIT EXCEEDED", global: "N/A" },
|
120
|
+
connection_limits: { user: "EXCEEDED", global: "N/A" },
|
121
|
+
error: "Error: User has exceeded max_user_connections limit"
|
122
|
+
}
|
123
|
+
else
|
124
|
+
nil
|
125
|
+
end
|
112
126
|
rescue => e
|
113
127
|
nil
|
114
128
|
end
|
data/lib/detector/version.rb
CHANGED