forked from learningequality/studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[learningequality#3827][learningequality#3828] Add probers for alerti…
…ng to task and change abnormalities
- Loading branch information
Showing
7 changed files
with
127 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python | ||
from base import BaseProbe | ||
|
||
|
||
class TaskQueueProbe(BaseProbe): | ||
|
||
metric = "task_queue_ping_latency_msec" | ||
threshold = 50 | ||
|
||
def do_probe(self): | ||
r = self.request("api/probers/task_queue_status/") | ||
r.raise_for_status() | ||
results = r.json() | ||
|
||
task_count = results.get('queued_task_count', 0) | ||
if task_count >= self.threshold: | ||
raise Exception("Task queue length is over threshold! {} > {}".format(task_count, self.threshold)) | ||
|
||
|
||
if __name__ == "__main__": | ||
TaskQueueProbe().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
from base import BaseProbe | ||
|
||
|
||
class UnappliedChangesProbe(BaseProbe): | ||
|
||
metric = "unapplied__changes_ping_latency_msec" | ||
|
||
def do_probe(self): | ||
r = self.request("api/probers/unapplied_changes_status/") | ||
r.raise_for_status() | ||
results = r.json() | ||
|
||
active_task_count = results.get('active_task_count', 0) | ||
unapplied_changes_count = results.get('unapplied_changes_count', 0) | ||
|
||
if active_task_count == 0 and unapplied_changes_count > 0: | ||
raise Exception("There are unapplied changes and no active tasks! {} unapplied changes".format(unapplied_changes_count)) | ||
|
||
|
||
if __name__ == "__main__": | ||
UnappliedChangesProbe().run() |