def _analyze(self, w, c, k, stats): class Opts(object): warning = w critical = c key = k return NagiosHandler().analyze(Opts(), {'localhost:2181': stats})
def test_check_a_specific_key_on_all_hosts(self): class Opts(object): warning = 10 critical = 20 key = 'latency' r = NagiosHandler().analyze(Opts(), { 's1:2181': {'latency': 5}, 's2:2181': {'latency': 15}, 's3:2181': {'latency': 35}, }) self.assertEqual(r, 2) self.assertEqual(self.output(), 'Critical "latency" s3:2181!|s1:2181=5;10;20 '\ 's3:2181=35;10;20 s2:2181=15;10;20\n')