Skip to content

Commit 469954d

Browse files
nevins-bsstarcher
authored andcommitted
Fix logic to check critical first then warning (#24)
* standardizing on database instead of db * fixing percentage check * fixing the logic for non-percentage checks as well
1 parent 33394d7 commit 469954d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

bin/check-postgres-connections.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,19 @@ def run
108108

109109
if config[:use_percentage]
110110
message = "PostgreSQL connections at #{percent}%, #{current_conns} out of #{max_conns} connections"
111-
if percent >= config[:warning]
112-
warning message
113-
elsif percent >= config[:critical]
111+
if percent >= config[:critical]
114112
critical message
113+
elsif percent >= config[:warning]
114+
warning message
115115
else
116116
ok "PostgreSQL connections under threshold: #{percent}%, #{current_conns} out of #{max_conns} connections"
117117
end
118118
else
119119
message = "PostgreSQL connections at #{current_conns} out of #{max_conns} connections"
120-
if current_conns >= config[:warning]
121-
warning message
122-
elsif current_conns >= config[:critical]
120+
if current_conns >= config[:critical]
123121
critical message
122+
elsif current_conns >= config[:warning]
123+
warning message
124124
else
125125
ok "PostgreSQL connections under threshold: #{current_conns} out of #{max_conns} connections"
126126
end

0 commit comments

Comments
 (0)