예제 #1
0
def test_chrony_servers_unreachable():
    assert list(
        chrony.check_chrony({"ntp_levels": (None, None, None)}, {
            "Reference ID": '55DCBEF6 ()',
            "address": "()",
        }, None)) == [
            Result(
                state=state.WARN,
                notice="NTP servers: unreachable\nReference ID: 55DCBEF6 ()",
            )
        ]
예제 #2
0
def test_chrony_stratum_crit():
    assert list(
        chrony.check_chrony({"ntp_levels": (2, None, None)}, {
            "Reference ID": None,
            "Stratum": 3,
            "System time": None,
            "address": "(foo.bar)",
        }, None)) == [
            Result(
                state=state.CRIT,
                summary="Stratum: 3 (warn/crit at 2/2)",
            ),
        ]
예제 #3
0
def test_chrony_servers_unreachable():
    assert list(
        chrony.check_chrony({"ntp_levels": (None, None, None)}, {
            "Reference ID": '55DCBEF6 ()',
            "Stratum": 3,
            "System time": 0.275117,
            "address": "()",
        }, None)) == [
            Result(
                state=state.WARN,
                summary="NTP servers unreachable. Reference ID: 55DCBEF6 ()",
            )
        ]
예제 #4
0
def test_chrony_offet_crit():
    assert list(
        chrony.check_chrony({"ntp_levels": (None, 0.12, 0.42)}, {
            "Reference ID": None,
            "Stratum": None,
            "System time": 0.275117,
            "address": "(moo)",
        }, None)) == [
            Result(
                state=state.WARN,
                summary="Offset: 0.2751 ms (warn/crit at 0.1200 ms/0.4200 ms)",
            ),
            Metric("offset", 0.275117, levels=(0.12, 0.42)),
        ]
예제 #5
0
def test_chrony_negative_sync_time():
    assert list(
        chrony.check_chrony(
            {
                "ntp_levels": (None, 0.12, 0.42),
                "alert_delay": (1800, 3600)
            },
            {
                "last_sync": -200,
                "address": "(moo)",
            },
            None,
        )
    ) == [
        Result(state=state.OK,
               notice="NTP servers: (moo)\nReference ID: None"),
        Result(
            state=state.OK,
            summary=
            "Last synchronization appears to be 3 minutes 20 seconds in the future (check your system time)",
        ),
    ]
예제 #6
0
def test_chrony_last_sync():
    assert list(
        chrony.check_chrony(
            {
                "ntp_levels": (None, 0.12, 0.42),
                "alert_delay": (1800, 3600)
            },
            {
                "last_sync": 1860,
                "address": "(moo)",
            },
            None,
        )
    ) == [
        Result(state=state.OK,
               notice="NTP servers: (moo)\nReference ID: None"),
        Result(
            state=state.WARN,
            summary=
            "Time since last sync: 31 minutes 0 seconds (warn/crit at 30 minutes 0 seconds/1 hour 0 minutes)",
        ),
    ]