#!/bin/bash

FAILURES=$(/usr/bin/wget --timeout=60 -q -O- http://koji.{{ datacenter }}.fedoraproject.org/koji/builds | /bin/grep -c failed.png)
WARNING=20
CRITICAL=25

if [ $FAILURES -gt $CRITICAL ]
then
    echo "Koji: CRITICAL failed builds: $FAILURES"
    exit 2
elif [ $FAILURES -gt $WARNING ]
then
    echo "Koji: WARNING failed builds: $FAILURES"
    exit 1
else
    echo "Koji: OK failed builds: $FAILURES"
    exit 0
fi
