#!/usr/bin/env python3

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

sys.path.append('/home/zulip/deployments/current')
import scripts.lib.setup_path_on_import

os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
from django.conf import settings

wildcard = os.path.join(settings.QUEUE_ERROR_DIR, '*.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)
