Skip to content

Commit d3b2b3c

Browse files
author
Pavel Pulec
committed
fix issue #7
Do not calculate statistics when there is no session so far. Return zero instead of that. Signed-off-by: Pavel Pulec <[email protected]>
1 parent b9b4a3b commit d3b2b3c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: check_haproxy.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@
115115
perf_id = "#{row['pxname']}".downcase
116116

117117
if row['svname'] == 'FRONTEND'
118-
session_percent_usage = row['scur'].to_i * 100 / row['slim'].to_i
118+
if row['slim'].to_i == 0
119+
session_percent_usage = 0
120+
else
121+
session_percent_usage = row['scur'].to_i * 100 / row['slim'].to_i
122+
end
119123
@perfdata << "#{perf_id}_sessions=#{session_percent_usage}%;#{options.warning ? options.warning : ""};#{options.critical ? options.critical : ""};;"
120124
@perfdata << "#{perf_id}_rate=#{row['rate']};;;;#{row['rate_max']}"
121125
if options.critical && session_percent_usage > options.critical.to_i

0 commit comments

Comments
 (0)