Skip to content

Commit

Permalink
Merge pull request #752 from walkeran/master
Browse files Browse the repository at this point in the history
haproxy - Calculate used session percentage
  • Loading branch information
remh committed Jan 10, 2014
2 parents 2d2a494 + c03b44c commit 807be28
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions checks.d/haproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, name, init_config, agentConfig):
"qcur": ("gauge", "queue.current"),
"scur": ("gauge", "session.current"),
"slim": ("gauge", "session.limit"),
"spct": ("gauge", "session.pct"), # Calculated as: (scur/slim)*100
"stot": ("rate", "session.rate"),
"bin": ("rate", "bytes.in_rate"),
"bout": ("rate", "bytes.out_rate"),
Expand Down Expand Up @@ -111,6 +112,13 @@ def _process_data(self, data, collect_aggregates_only, process_events, url=None)
pass
data_dict[fields[i]] = val

# The percentage of used sessions based on 'scur' and 'slim'
if 'slim' in data_dict and 'scur' in data_dict:
try:
data_dict['spct'] = (data_dict['scur'] / data_dict['slim']) * 100
except (TypeError, ZeroDivisionError):
pass

# Don't create metrics for aggregates
service = data_dict['svname']
if data_dict['svname'] in Services.ALL:
Expand Down

0 comments on commit 807be28

Please sign in to comment.