#!/bin/bash

#"OK": 0
#"WARNING": 1
#"CRITICAL": 2
#"UNKNOWN": 3

cd /home/zulip/deployments/current

BACKLOG=$(./manage.py print_email_delivery_backlog)

if [ "$BACKLOG" -gt 0 ] && [ "$BACKLOG" -lt 10 ]
then
    echo "backlog of $BACKLOG"
    exit 1
elif [ "$BACKLOG" -ge 10 ]
then
    echo "backlog of $BACKLOG"
    exit 2
else
    echo "no backlog"
    exit 0
fi
