Exemplo n.º 1
0
    def test_NTPPeer3(self):
        # check the parsing done by NTPCheck
        ntp = NTPCheck(testdata[3].split("\n"))
        self.assertEqual(ntp.ntpdata.get('syncpeer'), None)
        self.assertEqual(ntp.ntpdata.get('offsetsyncpeer'), None)
        self.assertEqual(ntp.ntpdata['survivors'], 0)
        self.assertEqual(ntp.ntpdata.get('averageoffsetsurvivors'), None)
        self.assertEqual(ntp.ntpdata['discards'], 1)
        self.assertEqual(ntp.ntpdata['averageoffsetdiscards'], 0.913)
        self.assertEqual(ntp.ntpdata['peers'], 1)
        self.assertEqual(ntp.ntpdata['averageoffset'], 0.913)
        self.assertEqual(ntp.ntpdata['reachability'], 37.5)

        # run checks on the data
        check = CheckNTPMon()
        self.assertEqual(check.offset(ntp.ntpdata['averageoffsetdiscards']), 0, 'Low offset non-OK')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffset']), 0, 'Low offset non-OK')
        self.assertEqual(check.peers(ntp.ntpdata['peers']), 2, 'Low peers non-critical')
        self.assertEqual(check.reachability(ntp.ntpdata['reachability']), 2,
                         'Low reachability non-critical')

        # run overall health checks
        self.assertEqual(ntp.check_sync(), 2, 'Missing sync peer not detected')
        self.assertEqual(ntp.check_offset(), 1, 'Missing sync peer/survivor offset non-warning')
        self.assertEqual(ntp.check_peers(), 2, 'Low peers non-critical')
        self.assertEqual(ntp.check_reachability(), 2, 'Low reachability non-critical')
Exemplo n.º 2
0
    def test_NTPPeer2(self):
        # check the parsing done by NTPCheck
        ntp = NTPCheck(testdata[2].split("\n"))
        self.assertEqual(ntp.ntpdata['syncpeer'], '91.189.94.4')
        self.assertEqual(ntp.ntpdata['offsetsyncpeer'], 194.54)
        self.assertEqual(ntp.ntpdata['survivors'], 1)
        self.assertEqual(ntp.ntpdata['averageoffsetsurvivors'], 194.54)
        self.assertEqual(ntp.ntpdata['discards'], 0)
        self.assertEqual(ntp.ntpdata.get('averageoffsetdiscards'), None)
        self.assertEqual(ntp.ntpdata['peers'], 1)
        self.assertEqual(ntp.ntpdata['averageoffset'], 194.54)
        self.assertEqual(ntp.ntpdata['reachability'], 100)

        # run checks on the data
        check = CheckNTPMon()
        self.assertEqual(check.sync(ntp.ntpdata['syncpeer']), 0, 'Sync peer not detected')
        self.assertEqual(check.offset(ntp.ntpdata['offsetsyncpeer']), 2, 'High offset non-critical')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffsetsurvivors']), 2, 'High offset non-critical')
        self.assertEqual(ntp.ntpdata.get('averageoffsetdiscards'), None)
        self.assertEqual(check.offset(ntp.ntpdata['averageoffset']), 2, 'High offset non-critical')
        self.assertEqual(check.peers(ntp.ntpdata['peers']), 2, 'Low peers non-critical')
        self.assertEqual(check.reachability(ntp.ntpdata['reachability']), 0,
                         'High reachability non-OK')

        # run overall health checks
        self.assertEqual(ntp.check_sync(), 0, 'Sync peer not detected')
        self.assertEqual(ntp.check_offset(), 2, 'High offset non-critical')
        self.assertEqual(ntp.check_peers(), 2, 'Low peers non-critical')
        self.assertEqual(ntp.check_reachability(), 0, 'High reachability non-OK')
Exemplo n.º 3
0
    def test_NTPPeer1(self):
        # check the parsing done by NTPCheck
        ntp = NTPCheck(testdata[1].split("\n"))
        self.assertEqual(ntp.ntpdata['syncpeer'], '202.60.94.11')
        self.assertEqual(ntp.ntpdata['offsetsyncpeer'], 0.259)
        self.assertEqual(ntp.ntpdata['survivors'], 3)
        self.assertEqual(ntp.ntpdata['averageoffsetsurvivors'], 0.21133333333333335)
        self.assertEqual(ntp.ntpdata['discards'], 3)
        self.assertEqual(ntp.ntpdata['averageoffsetdiscards'], 1.024)
        self.assertEqual(ntp.ntpdata['peers'], 6)
        self.assertEqual(ntp.ntpdata['averageoffset'], 0.6176666666666667)
        self.assertEqual(ntp.ntpdata['reachability'], 100)

        # run checks on the data
        check = CheckNTPMon()
        self.assertEqual(check.sync(ntp.ntpdata['syncpeer']), 0, 'Sync peer not detected')
        self.assertEqual(check.offset(ntp.ntpdata['offsetsyncpeer']), 0, 'Low offset non-OK')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffsetsurvivors']), 0, 'Low offset non-OK')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffsetdiscards']), 0, 'Low offset non-OK')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffset']), 0, 'Low offset non-OK')
        self.assertEqual(check.peers(ntp.ntpdata['peers']), 0, 'High peers non-OK')
        self.assertEqual(check.reachability(ntp.ntpdata['reachability']), 0,
                         'High reachability non-OK')

        # run overall health checks
        self.assertEqual(ntp.check_sync(), 0, 'Sync peer not detected')
        self.assertEqual(ntp.check_offset(), 0, 'Low offset non-OK')
        self.assertEqual(ntp.check_peers(), 0, 'High peers non-OK')
        self.assertEqual(ntp.check_reachability(), 0, 'High reachability non-OK')
Exemplo n.º 4
0
    def test_NTPPeer3(self):
        # check the parsing done by NTPCheck
        ntp = NTPCheck(testdata[3].split("\n"))
        self.assertEqual(ntp.ntpdata.get('syncpeer'), None)
        self.assertEqual(ntp.ntpdata.get('offsetsyncpeer'), None)
        self.assertEqual(ntp.ntpdata['survivors'], 0)
        self.assertEqual(ntp.ntpdata.get('averageoffsetsurvivors'), None)
        self.assertEqual(ntp.ntpdata['discards'], 1)
        self.assertEqual(ntp.ntpdata['averageoffsetdiscards'], 0.913)
        self.assertEqual(ntp.ntpdata['peers'], 1)
        self.assertEqual(ntp.ntpdata['averageoffset'], 0.913)
        self.assertEqual(ntp.ntpdata['reachability'], 37.5)

        # run checks on the data
        check = CheckNTPMon()
        self.assertEqual(check.offset(ntp.ntpdata['averageoffsetdiscards']), 0,
                         'Low offset non-OK')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffset']), 0,
                         'Low offset non-OK')
        self.assertEqual(check.peers(ntp.ntpdata['peers']), 2,
                         'Low peers non-critical')
        self.assertEqual(check.reachability(ntp.ntpdata['reachability']), 2,
                         'Low reachability non-critical')

        # run overall health checks
        self.assertEqual(ntp.check_sync(), 2, 'Missing sync peer not detected')
        self.assertEqual(ntp.check_offset(), 1,
                         'Missing sync peer/survivor offset non-warning')
        self.assertEqual(ntp.check_peers(), 2, 'Low peers non-critical')
        self.assertEqual(ntp.check_reachability(), 2,
                         'Low reachability non-critical')
Exemplo n.º 5
0
    def test_NTPPeer2(self):
        # check the parsing done by NTPCheck
        ntp = NTPCheck(testdata[2].split("\n"))
        self.assertEqual(ntp.ntpdata['syncpeer'], '91.189.94.4')
        self.assertEqual(ntp.ntpdata['offsetsyncpeer'], 194.54)
        self.assertEqual(ntp.ntpdata['survivors'], 1)
        self.assertEqual(ntp.ntpdata['averageoffsetsurvivors'], 194.54)
        self.assertEqual(ntp.ntpdata['discards'], 0)
        self.assertEqual(ntp.ntpdata.get('averageoffsetdiscards'), None)
        self.assertEqual(ntp.ntpdata['peers'], 1)
        self.assertEqual(ntp.ntpdata['averageoffset'], 194.54)
        self.assertEqual(ntp.ntpdata['reachability'], 100)

        # run checks on the data
        check = CheckNTPMon()
        self.assertEqual(check.sync(ntp.ntpdata['syncpeer']), 0,
                         'Sync peer not detected')
        self.assertEqual(check.offset(ntp.ntpdata['offsetsyncpeer']), 2,
                         'High offset non-critical')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffsetsurvivors']),
                         2, 'High offset non-critical')
        self.assertEqual(ntp.ntpdata.get('averageoffsetdiscards'), None)
        self.assertEqual(check.offset(ntp.ntpdata['averageoffset']), 2,
                         'High offset non-critical')
        self.assertEqual(check.peers(ntp.ntpdata['peers']), 2,
                         'Low peers non-critical')
        self.assertEqual(check.reachability(ntp.ntpdata['reachability']), 0,
                         'High reachability non-OK')

        # run overall health checks
        self.assertEqual(ntp.check_sync(), 0, 'Sync peer not detected')
        self.assertEqual(ntp.check_offset(), 2, 'High offset non-critical')
        self.assertEqual(ntp.check_peers(), 2, 'Low peers non-critical')
        self.assertEqual(ntp.check_reachability(), 0,
                         'High reachability non-OK')
Exemplo n.º 6
0
    def test_NTPPeer1(self):
        # check the parsing done by NTPCheck
        ntp = NTPCheck(testdata[1].split("\n"))
        self.assertEqual(ntp.ntpdata['syncpeer'], '202.60.94.11')
        self.assertEqual(ntp.ntpdata['offsetsyncpeer'], 0.259)
        self.assertEqual(ntp.ntpdata['survivors'], 3)
        self.assertEqual(ntp.ntpdata['averageoffsetsurvivors'],
                         0.21133333333333335)
        self.assertEqual(ntp.ntpdata['discards'], 3)
        self.assertEqual(ntp.ntpdata['averageoffsetdiscards'], 1.024)
        self.assertEqual(ntp.ntpdata['peers'], 6)
        self.assertEqual(ntp.ntpdata['averageoffset'], 0.6176666666666667)
        self.assertEqual(ntp.ntpdata['reachability'], 100)

        # run checks on the data
        check = CheckNTPMon()
        self.assertEqual(check.sync(ntp.ntpdata['syncpeer']), 0,
                         'Sync peer not detected')
        self.assertEqual(check.offset(ntp.ntpdata['offsetsyncpeer']), 0,
                         'Low offset non-OK')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffsetsurvivors']),
                         0, 'Low offset non-OK')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffsetdiscards']), 0,
                         'Low offset non-OK')
        self.assertEqual(check.offset(ntp.ntpdata['averageoffset']), 0,
                         'Low offset non-OK')
        self.assertEqual(check.peers(ntp.ntpdata['peers']), 0,
                         'High peers non-OK')
        self.assertEqual(check.reachability(ntp.ntpdata['reachability']), 0,
                         'High reachability non-OK')

        # run overall health checks
        self.assertEqual(ntp.check_sync(), 0, 'Sync peer not detected')
        self.assertEqual(ntp.check_offset(), 0, 'Low offset non-OK')
        self.assertEqual(ntp.check_peers(), 0, 'High peers non-OK')
        self.assertEqual(ntp.check_reachability(), 0,
                         'High reachability non-OK')