def test__util_counter(): cpu = cpu_util.CPUInfo("cpu-name", 100, 40, 60, 80, 50, 80, 30, 60, 20, 40) assert cpu_util._util_counter(cpu, {}) == cpu assert cpu_util._util_counter(cpu, { "cpu.util.user": 20, "cpu.util.system": 10, "cpu.util.idle": 5, }) == cpu_util.CPUInfo("cpu-name", 80, 40, 50, 75, 50, 80, 30, 60, 20, 40)
def test_check_cpu_util_unix(): assert list( cpu_util.check_cpu_util_unix( cpu_info=cpu_util.CPUInfo("cpu-name", 10, 4, 6, 8, 5, 8, 3, 6, 2, 4), params={}, this_time=0, value_store={}, cores=[], values_counter=False, )) == [ Result(state=State.OK, notice='User: 10.00%'), Metric("user", 10.), Result(state=State.OK, notice='System: 6.00%'), Metric("system", 6.), Result(state=State.OK, notice='Wait: 5.00%'), Metric("wait", 5.), Result(state=State.OK, notice='Steal: 6.00%'), Metric("steal", 6.), Result(state=State.OK, notice='Guest: 2.00%'), Metric("guest", 2.), Result(state=State.OK, summary='Total CPU: 42.00%'), Metric("util", 42., boundaries=(0.0, None)), ]