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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 160f91ff5337a5e65db122754c58acf167ea6c92a2628b6c4cae37dfbebbd2e9
4
- data.tar.gz: '0691d5918ca772909057ebf059947f4f1b08cd8b5388f0cc7836842d980bf677'
3
+ metadata.gz: c1005a81a12b0ba3854590f05209d1c420a32fa1a01ff6e12b6ce8e8d98aebc9
4
+ data.tar.gz: 071f0840a62f62af205f42e2fc314e5a0b02a202f229d7aaa91b89deb2b29ea8
5
5
  SHA512:
6
- metadata.gz: a192f06a2497b21ac4475d2686615450eb800a888367a02eefb36dcf3ae5f7959712a49f4a33012aaa554fabd4d18390aac08e9671dddef38f6f4d8d97c9e561
7
- data.tar.gz: f9426467573fae22f8fb192b342d376cc1fd04036079821c62c354f3dc0fe426417cdf34a8e3a18e7b09bda36ee2478176fcd1d70d2ac4c3642ea4b10aaa69e6
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
- puts "Connections: global #{conn_info[:connection_count][:global]}/#{conn_info[:connection_limits][:global]} (user #{conn_info[:connection_count][:user]}/#{conn_info[:connection_limits][:user]})"
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
@@ -1,3 +1,3 @@
1
1
  module Detector
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: detector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel