Skip to content

Commit

Permalink
Controller: Provide "is_exploited" metric
Browse files Browse the repository at this point in the history
Useful for automated "first blood" notifications, which don't work
reliably with "exploiting_teams".

Improves: #39
  • Loading branch information
F30 committed Oct 5, 2020
1 parent 89cad39 commit 45ed137
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ctf_gameserver/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,16 @@ def collect(self):
'Number of teams that submitted at least one flag',
labels=['service']
)
is_exploited = prometheus_client.core.GaugeMetricFamily(
metric_prefix+'is_exploited',
'Whether at least one team submitted at least one flag',
labels=['service']
)
for service, count in database.get_exploiting_teams_counts(db_conn).items():
exploiting_teams.add_metric([service], count)
is_exploited.add_metric([service], int(count > 0))
yield exploiting_teams
yield is_exploited

unplaced_flags = prometheus_client.core.CounterMetricFamily(
metric_prefix+'unplaced_flags',
Expand Down

0 comments on commit 45ed137

Please sign in to comment.