コード例 #1
0
 def test_ok(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Ok
     from checkpkgaudit.checkpkgaudit import AuditSummary
     results = Results()
     ok_r1 = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     ok_r2 = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     results.add(ok_r1)
     results.add(ok_r2)
     summary = AuditSummary()
     sum_ok = summary.ok(results)
     self.assertEqual(sum_ok, '0 vulnerabilities found !')
コード例 #2
0
 def test_ok(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Ok
     from checkopenbgpd.checkopenbgpd import AuditSummary
     results = Results()
     ok_r1 = Result(Ok, '', nagiosplugin.Metric('met1', 529001))
     ok_r2 = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     results.add(ok_r1)
     results.add(ok_r2)
     summary = AuditSummary()
     sum_ok = summary.ok(results)
     self.assertEqual(sum_ok, 'All bgp sessions in correct state')
コード例 #3
0
 def test_ok(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Ok
     from check_dns_sync.check_dns_sync import AuditSummary
     results = Results()
     ok_r1 = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     ok_r2 = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     results.add(ok_r1)
     results.add(ok_r2)
     summary = AuditSummary(None)
     sum_ok = summary.ok(results)
     self.assertEqual(sum_ok, "All zone are in sync")
コード例 #4
0
 def test_ok(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Ok
     from checkpkgaudit.checkpkgaudit import AuditSummary
     results = Results()
     ok_r1 = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     ok_r2 = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     results.add(ok_r1)
     results.add(ok_r2)
     summary = AuditSummary()
     sum_ok = summary.ok(results)
     self.assertEqual(sum_ok, '0 vulnerabilities found !')
コード例 #5
0
 def test_ok(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Ok
     from checkopenbgpd.checkopenbgpd import AuditSummary
     results = Results()
     ok_r1 = Result(Ok, '', nagiosplugin.Metric('met1', 529001))
     ok_r2 = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     results.add(ok_r1)
     results.add(ok_r2)
     summary = AuditSummary()
     sum_ok = summary.ok(results)
     self.assertEqual(sum_ok, 'All bgp sessions in correct state')
コード例 #6
0
 def test_problem_crit(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Critical
     from checkpkgaudit.checkpkgaudit import AuditSummary
     message = "found 2 vulnerable(s) pkg(s) in : ns1, ns2"
     results = Results()
     r1 = Result(Critical, '', nagiosplugin.Metric('ns1', 1))
     r2 = Result(Critical, '', nagiosplugin.Metric('ns2', 1))
     results.add(r1)
     results.add(r2)
     summary = AuditSummary()
     sum_crit = summary.problem(results)
     self.assertEqual(sum_crit, message)
コード例 #7
0
 def test_critical(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Critical
     from checklayer2link.checklayer2link import AuditSummary
     from checklayer2link.checklayer2link import CheckLayer2Link
     resource = CheckLayer2Link('192.168.0.1')
     results = Results()
     crit_r1 = Result(Critical, '', nagiosplugin.Metric('mac', 0,
                      context='arp', resource=resource))
     results.add(crit_r1)
     summary = AuditSummary()
     sum_pb = summary.problem(results)
     self.assertEquals(sum_pb, 'layer 2 for ip 192.168.0.1 is down')
コード例 #8
0
 def test_problem_crit_non_metric(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Critical
     from check_dns_sync.check_dns_sync import AuditSummary
     message = "ns1,ns2 are behind"
     results = Results()
     r1 = Result(Critical, '', nagiosplugin.Metric('ns1', 1))
     r2 = Result(Critical, '', nagiosplugin.Metric('ns2', 1))
     results.add(r1)
     results.add(r2)
     summary = AuditSummary(False)
     sum_crit = summary.problem(results)
     self.assertEqual(sum_crit, message)
コード例 #9
0
 def test_problem_unknown(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Critical, Unknown
     from checkpkgaudit.checkpkgaudit import AuditSummary
     hint = 'masterdns pkg: jail_attach(masterdns): Operation not permitted'
     results = Results()
     r1 = Result(Critical, '', nagiosplugin.Metric('met1', 1))
     r2 = Result(Unknown, hint, nagiosplugin.Metric('met1', 0))
     results.add(r1)
     results.add(r2)
     summary = AuditSummary()
     sum_unknown = summary.problem(results)
     self.assertEqual(sum_unknown, hint)
コード例 #10
0
 def test_problem_unknown(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Critical, Unknown
     from checkpkgaudit.checkpkgaudit import AuditSummary
     hint = 'masterdns pkg: jail_attach(masterdns): Operation not permitted'
     results = Results()
     r1 = Result(Critical, '', nagiosplugin.Metric('met1', 1))
     r2 = Result(Unknown, hint, nagiosplugin.Metric('met1', 0))
     results.add(r1)
     results.add(r2)
     summary = AuditSummary()
     sum_unknown = summary.problem(results)
     self.assertEqual(sum_unknown, hint)
コード例 #11
0
 def test_problem_crit(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Critical
     from checkpkgaudit.checkpkgaudit import AuditSummary
     message = "found 2 vulnerable(s) pkg(s) in : ns1, ns2"
     results = Results()
     r1 = Result(Critical, '', nagiosplugin.Metric('ns1', 1))
     r2 = Result(Critical, '', nagiosplugin.Metric('ns2', 1))
     results.add(r1)
     results.add(r2)
     summary = AuditSummary()
     sum_crit = summary.problem(results)
     self.assertEqual(sum_crit, message)
コード例 #12
0
 def test_ok(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Ok
     from checklayer2link.checklayer2link import AuditSummary
     from checklayer2link.checklayer2link import CheckLayer2Link
     resource = CheckLayer2Link('192.168.0.1')
     results = Results()
     ok_r1 = Result(Ok, '', nagiosplugin.Metric('mac', 1, context='arp',
                    resource=resource))
     results.add(ok_r1)
     summary = AuditSummary()
     sum_ok = summary.ok(results)
     self.assertEquals(sum_ok, 'layer 2 for ip 192.168.0.1 is up')
コード例 #13
0
 def test_problem_unknown(self):
     from nagiosplugin.result import Result, Results
     from nagiosplugin.state import Critical, Unknown
     from check_dns_sync.check_dns_sync import AuditSummary
     hint = "No result. Domain probably does not exist"
     results = Results()
     r1 = Result(Critical, '', nagiosplugin.Metric('met1', 1))
     r2 = Result(Unknown, hint, nagiosplugin.Metric('met1', 0))
     results.add(r1)
     results.add(r2)
     summary = AuditSummary(None)
     sum_unknown = summary.problem(results)
     self.assertEqual(sum_unknown, hint)
コード例 #14
0
 def test_most_significant_state(self):
     r = Results()
     r.add(Result(Ok))
     self.assertEqual(Ok, r.most_significant_state)
     r.add(Result(Critical))
     self.assertEqual(Critical, r.most_significant_state)
     r.add(Result(Warn))
     self.assertEqual(Critical, r.most_significant_state)
コード例 #15
0
ファイル: test_result.py プロジェクト: adamfitzgibbon/esmond
 def test_most_significant_state(self):
     r = Results()
     r.add(Result(Ok))
     self.assertEqual(Ok, r.most_significant_state)
     r.add(Result(Critical))
     self.assertEqual(Critical, r.most_significant_state)
     r.add(Result(Warn))
     self.assertEqual(Critical, r.most_significant_state)
コード例 #16
0
ファイル: test_result.py プロジェクト: Puneeth-n/nagiosplugin
def test_most_significant_state():
    r = Results()
    r.add(Result(Ok))
    assert Ok == r.most_significant_state
    r.add(Result(Critical))
    assert Critical == r.most_significant_state
    r.add(Result(Warn))
    assert Critical == r.most_significant_state
コード例 #17
0
ファイル: test_result.py プロジェクト: adamfitzgibbon/esmond
 def test_most_signigicant(self):
     r = Results()
     r.add(Result(Ok), Result(Warn), Result(Ok), Result(Warn))
     self.assertEqual([Warn, Warn],
                      [result.state for result in r.most_significant])
コード例 #18
0
 def test_contains(self):
     results = Results()
     r1 = Result(Unknown, 'r1', nagiosplugin.Metric('m1', 1))
     results.add(r1)
     self.assertTrue('m1' in results)
     self.assertFalse('m2' in results)
コード例 #19
0
 def test_first_significant(self):
     r = Results()
     r.add(Result(Critical), Result(Unknown, 'r1'), Result(Unknown, 'r2'),
           Result(Ok))
     self.assertEqual(Result(Unknown, 'r1'), r.first_significant)
コード例 #20
0
 def test_most_signigicant(self):
     r = Results()
     r.add(Result(Ok), Result(Warn), Result(Ok), Result(Warn))
     self.assertEqual([Warn, Warn],
                      [result.state for result in r.most_significant])
コード例 #21
0
ファイル: test_result.py プロジェクト: adamfitzgibbon/esmond
 def test_len(self):
     r = Results()
     r.add(Result(Ok), Result(Ok), Result(Ok))
     self.assertEqual(3, len(r))
コード例 #22
0
ファイル: test_result.py プロジェクト: Puneeth-n/nagiosplugin
def test_first_significant():
    r = Results()
    r.add(Result(Critical), Result(Unknown, 'r1'), Result(Unknown, 'r2'),
          Result(Ok))
    assert Result(Unknown, 'r1') == r.first_significant
コード例 #23
0
ファイル: test_result.py プロジェクト: Puneeth-n/nagiosplugin
def test_lookup_by_index():
    r = Results()
    result = Result(Ok, '', nagiosplugin.Metric('met1', 0))
    r.add(Result(Ok, 'other'), result)
    assert r[1] == result
コード例 #24
0
ファイル: test_result.py プロジェクト: adamfitzgibbon/esmond
 def test_lookup_by_metric_name(self):
     r = Results()
     result = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     r.add(result, Result(Ok, 'other'))
     self.assertEqual(r['met1'], result)
コード例 #25
0
ファイル: test_result.py プロジェクト: Puneeth-n/nagiosplugin
def test_len():
    r = Results()
    r.add(Result(Ok), Result(Ok), Result(Ok))
    assert 3 == len(r)
コード例 #26
0
 def test_lookup_by_metric_name(self):
     r = Results()
     result = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     r.add(result, Result(Ok, 'other'))
     self.assertEqual(r['met1'], result)
コード例 #27
0
 def test_add_should_fail_unless_result_passed(self):
     with self.assertRaises(ValueError):
         Results(True)
コード例 #28
0
 def test_add_in_init(self):
     results = Results(Result(Unknown, 'r1'), Result(Unknown, 'r2'))
     self.assertEqual(2, len(results))
コード例 #29
0
ファイル: test_result.py プロジェクト: Puneeth-n/nagiosplugin
def test_lookup_by_metric_name():
    r = Results()
    result = Result(Ok, '', nagiosplugin.Metric('met1', 0))
    r.add(result, Result(Ok, 'other'))
    assert r['met1'] == result
コード例 #30
0
ファイル: test_result.py プロジェクト: Puneeth-n/nagiosplugin
def test_contains():
    results = Results()
    r1 = Result(Unknown, 'r1', nagiosplugin.Metric('m1', 1))
    results.add(r1)
    assert 'm1' in results
    assert 'm2' not in results
コード例 #31
0
ファイル: test_result.py プロジェクト: Puneeth-n/nagiosplugin
def test_most_signigicant():
    r = Results()
    r.add(Result(Ok), Result(Warn), Result(Ok), Result(Warn))
    assert [Warn, Warn] == [result.state for result in r.most_significant]
コード例 #32
0
ファイル: test_result.py プロジェクト: adamfitzgibbon/esmond
 def test_iterate_in_order_of_descending_states(self):
     r = Results()
     r.add(Result(Warn), Result(Ok), Result(Critical), Result(Warn))
     self.assertEqual([Critical, Warn, Warn, Ok],
                      [result.state for result in r])
コード例 #33
0
 def test_most_significant_should_return_empty_set_if_empty(self):
     self.assertEqual([], Results().most_significant)
コード例 #34
0
 def test_iterate_in_order_of_descending_states(self):
     r = Results()
     r.add(Result(Warn), Result(Ok), Result(Critical), Result(Warn))
     self.assertEqual([Critical, Warn, Warn, Ok],
                      [result.state for result in r])
コード例 #35
0
ファイル: test_result.py プロジェクト: Puneeth-n/nagiosplugin
def test_iterate_in_order_of_descending_states():
    r = Results()
    r.add(Result(Warn), Result(Ok), Result(Critical), Result(Warn))
    assert [Critical, Warn, Warn, Ok] == [result.state for result in r]
コード例 #36
0
ファイル: test_result.py プロジェクト: adamfitzgibbon/esmond
 def test_lookup_by_index(self):
     r = Results()
     result = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     r.add(Result(Ok, 'other'), result)
     self.assertEqual(r[1], result)
コード例 #37
0
 def test_most_significant_state_shoud_raise_valueerror_if_empty(self):
     with self.assertRaises(ValueError):
         Results().most_significant_state
コード例 #38
0
 def test_lookup_by_index(self):
     r = Results()
     result = Result(Ok, '', nagiosplugin.Metric('met1', 0))
     r.add(Result(Ok, 'other'), result)
     self.assertEqual(r[1], result)
コード例 #39
0
ファイル: test_result.py プロジェクト: adamfitzgibbon/esmond
 def test_first_significant(self):
     r = Results()
     r.add(Result(Critical), Result(Unknown, 'r1'), Result(Unknown, 'r2'),
           Result(Ok))
     self.assertEqual(Result(Unknown, 'r1'), r.first_significant)
コード例 #40
0
 def test_len(self):
     r = Results()
     r.add(Result(Ok), Result(Ok), Result(Ok))
     self.assertEqual(3, len(r))
コード例 #41
0
ファイル: test_result.py プロジェクト: adamfitzgibbon/esmond
 def test_contains(self):
     results = Results()
     r1 = Result(Unknown, 'r1', nagiosplugin.Metric('m1', 1))
     results.add(r1)
     self.assertTrue('m1' in results)
     self.assertFalse('m2' in results)