Skip to content

Instantly share code, notes, and snippets.

@gregarndt
Last active May 11, 2017 19:28
Show Gist options
  • Save gregarndt/eab4b1354c7443904264f47134cb5cfb to your computer and use it in GitHub Desktop.
Save gregarndt/eab4b1354c7443904264f47134cb5cfb to your computer and use it in GitHub Desktop.
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