diff --git a/neat/locals/collector.py b/neat/locals/collector.py index 3b7233d..96940a3 100644 --- a/neat/locals/collector.py +++ b/neat/locals/collector.py @@ -167,6 +167,8 @@ def init_state(config): 'previous_overload': -1, 'vir_connection': vir_connection, 'hostname': hostname, + 'host_cpu_overload_threshold': + float(config['host_cpu_overload_threshold']), 'physical_cpus': physical_cpus, 'physical_cpu_mhz': host_cpu_mhz, 'physical_core_mhz': host_cpu_mhz / physical_cpus, @@ -261,7 +263,7 @@ def execute(config, state): state['previous_overload'] = log_host_overload( state['db'], - config['host_cpu_overload_threshold'], + state['host_cpu_overload_threshold'], state['hostname'], state['previous_overload'], state['physical_cpu_mhz'], diff --git a/tests/locals/test_collector.py b/tests/locals/test_collector.py index 90fd48d..91c2634 100644 --- a/tests/locals/test_collector.py +++ b/tests/locals/test_collector.py @@ -61,7 +61,8 @@ class Collector(TestCase): physical_cpus = 13 expect(common).physical_cpu_count(vir_connection). \ and_return(physical_cpus).once() - config = {'sql_connection': 'db'} + config = {'sql_connection': 'db', + 'host_cpu_overload_threshold': '0.95'} hostname = 'host1' mhz = 13540 @@ -80,6 +81,7 @@ class Collector(TestCase): assert isinstance(state['previous_cpu_time'], dict) assert state['vir_connection'] == vir_connection assert state['hostname'] == hostname + assert state['host_cpu_overload_threshold'] == 0.95 assert state['physical_cpus'] == physical_cpus assert state['physical_cpu_mhz'] == mhz assert state['physical_core_mhz'] == mhz / physical_cpus