def test_age_status_fn_should_return_ok_when_age_less_than_warning(self): collector = PgStatCollector.from_cluster(self.cluster, 1049) formatter = StatusFormatter(collector) row = [ 11139, None, 'backend', None, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9, '0:04:05', 'postgres', 'postgres', False, 'idle in transaction for 20:51:17' ] col = {'warning': 300, 'critical': 500, 'out': 'age'} self.assertEqual({-1: 0}, formatter.age_status_fn(row, col))
def test_query_status_fn_should_return_ok_when_no_warning(self): collector = PgStatCollector.from_cluster(self.cluster, 1049) formatter = StatusFormatter(collector) row = [ 11139, None, 'backend', None, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.9, '21:05:45', 'postgres', 'postgres', False, 'ok' ] col = {'warning': 'idle in transaction', 'critical': 'locked', 'out': 'query'} self.assertEqual({-1: 0}, formatter.query_status_fn(row, col))
def test_load_avg_state_should_return_every_state_when_warning_critical_ok(self): collector = HostStatCollector() formatter = StatusFormatter(collector) row = ['0.0 5.01 20.05', '2 days, 15:33:30', 'ubuntu-trusty-64', 1, 'Linux 3.13.0-100-generic'] col = {'warning': 5, 'critical': 20, 'out': 'load average'} self.assertEqual({0: 0, 1: 1, 2: 2}, formatter.load_avg_state(row, col))