#!/usr/bin/python """ Nagios plugin to check the length of the FTS update log. """ import psycopg2 states = { "OK": 0, "WARNING": 1, "CRITICAL": 2, "UNKNOWN": 3 } def report(state, num): print "%s: %s rows in fts_update_log table" % (state, num) exit(states[state]) conn = psycopg2.connect("host=localhost user=zulip") cursor = conn.cursor() cursor.execute("SELECT count(*) FROM fts_update_log") num = cursor.fetchall()[0][0] if num > 5: report('CRITICAL', num) report('OK', num)