Ejemplo n.º 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 !')
Ejemplo n.º 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')
Ejemplo n.º 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")
Ejemplo n.º 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 !')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 15
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)
Ejemplo n.º 16
0
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
Ejemplo n.º 17
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])
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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])
Ejemplo n.º 21
0
 def test_len(self):
     r = Results()
     r.add(Result(Ok), Result(Ok), Result(Ok))
     self.assertEqual(3, len(r))
Ejemplo n.º 22
0
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
Ejemplo n.º 23
0
def test_lookup_by_index():
    r = Results()
    result = Result(Ok, '', nagiosplugin.Metric('met1', 0))
    r.add(Result(Ok, 'other'), result)
    assert r[1] == result
Ejemplo n.º 24
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)
Ejemplo n.º 25
0
def test_len():
    r = Results()
    r.add(Result(Ok), Result(Ok), Result(Ok))
    assert 3 == len(r)
Ejemplo n.º 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)
Ejemplo n.º 27
0
 def test_add_should_fail_unless_result_passed(self):
     with self.assertRaises(ValueError):
         Results(True)
Ejemplo n.º 28
0
 def test_add_in_init(self):
     results = Results(Result(Unknown, 'r1'), Result(Unknown, 'r2'))
     self.assertEqual(2, len(results))
Ejemplo n.º 29
0
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
Ejemplo n.º 30
0
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
Ejemplo n.º 31
0
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]
Ejemplo n.º 32
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])
Ejemplo n.º 33
0
 def test_most_significant_should_return_empty_set_if_empty(self):
     self.assertEqual([], Results().most_significant)
Ejemplo n.º 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])
Ejemplo n.º 35
0
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]
Ejemplo n.º 36
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)
Ejemplo n.º 37
0
 def test_most_significant_state_shoud_raise_valueerror_if_empty(self):
     with self.assertRaises(ValueError):
         Results().most_significant_state
Ejemplo n.º 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)
Ejemplo n.º 39
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)
Ejemplo n.º 40
0
 def test_len(self):
     r = Results()
     r.add(Result(Ok), Result(Ok), Result(Ok))
     self.assertEqual(3, len(r))
Ejemplo n.º 41
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)