Last active
May 11, 2017 19:28
-
-
Save gregarndt/eab4b1354c7443904264f47134cb5cfb to your computer and use it in GitHub Desktop.
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
import os | |
import psycopg2 | |
conn = psycopg2.connect(os.environ['PGCONNECTIONSTRING']) | |
cur = conn.cursor() | |
all_worker_ids = set(["t-yosemite-r7-0040", "t-yosemite-r7-0041", "t-yosemite-r7-0042", "t-yosemite-r7-0045"]) | |
try: | |
cur.execute("select worker_id, count(*) from tasks where provisioner = 'scl3-puppet' and resolved > now() - interval '5 hours' group by worker_id") | |
found_ids = set([r[0] for r in cur]) | |
possible_zombies = all_worker_ids - found_ids | |
print possible_zombies | |
finally: | |
cur.close() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment