Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Commit

Permalink
Send a hourly throughput number
Browse files Browse the repository at this point in the history
  • Loading branch information
vrutkovs committed May 11, 2016
1 parent 02cd862 commit 81ec67d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions zabbix_metrics_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ def _send_zabbix_message(zabbix_host, osbs_master, key, value, print_command=Tru
pass


def filter_completed_builds(completed_builds):
# Remove all completed_builds which are not within this hour
now = int(time())
return {k: v for k, v in completed_builds.items() if (v - now) < 3600}


def heartbeat(zabbix_host, osbs_master):
while True:
_send_zabbix_message(zabbix_host, osbs_master,
Expand All @@ -123,6 +129,7 @@ def heartbeat(zabbix_host, osbs_master):
def run(zabbix_host, osbs_master):
running_builds = set()
pending = {}
completed_builds = {}

thread.start_new_thread(heartbeat, (zabbix_host, osbs_master, ))

Expand Down Expand Up @@ -151,6 +158,11 @@ def run(zabbix_host, osbs_master):
else:
try:
running_builds.remove(build_name)
if status != 'Cancelled':
completed_builds[build_name] = int(time())
completed_builds = filter_completed_builds(completed_builds)
_send_zabbix_message(zabbix_host, osbs_master,
"throughput", len(completed_builds))
except:
pass

Expand Down

0 comments on commit 81ec67d

Please sign in to comment.