"""
 Nagios check to make sure we have NEXRAD attribute data
"""
import sys
import os
import iemdb

POSTGIS = iemdb.connect('postgis', bypass=True)
pcursor = POSTGIS.cursor()

pcursor.execute("""
 select count(*) from nexrad_attributes WHERE 
 valid > now() - '30 minutes'::interval
""")
row = pcursor.fetchone()
count = row[0]

if count > 30:
    print 'OK - attrs %s |count=%s;15;30;0' % (count, count)
    sys.exit(0)
elif count > 15:
    print 'OK - attrs %s |count=%s;15;30;0' % (count, count)
    sys.exit(1)
else:
    print 'CRITICAL - attrs %s |count=%s;15;30;0' % (count, count)
    sys.exit(2)
"""
 Nagios check to make sure we have NEXRAD attribute data
"""
import sys
# Since we are not running as mesonet!
sys.path.insert(0, '/mesonet/www/apps/iemwebsite/scripts/lib')
import os
import iemdb

POSTGIS = iemdb.connect('postgis', bypass=True)
pcursor = POSTGIS.cursor()

pcursor.execute("""
 select count(*) from nexrad_attributes WHERE 
 valid > now() - '30 minutes'::interval
""")
row = pcursor.fetchone()
count = row[0]

if count > 30:
    print 'OK - attrs %s |count=%s;15;30;0' % (count, count)
    sys.exit(0)
elif count > 15:
    print 'OK - attrs %s |count=%s;15;30;0' % (count, count)
    sys.exit(1)
else:
    print 'CRITICAL - attrs %s |count=%s;15;30;0' % (count, count)
    sys.exit(2)
adjust system.path