#!/usr/bin/env python3

"""
Nagios plugin to check that none of our queue workers have reported errors.
"""
import glob
import os
import sys

# settings.QUEUE_ERROR_DIR; not importing Django so that this can run
# as the nagios user.
wildcard = os.path.join("/var/log/zulip/queue_error", '*.errors')
clean = True
for fn in glob.glob(wildcard):
    print('WARNING: Queue errors logged in %s' % (fn,))
    clean = False

if not clean:
    sys.exit(1)

sys.exit(0)
