def test_filesystems_fstype_filter(): expected_metrics = [ "df_complex.free", "df_complex.used", "percent_bytes.free", "percent_bytes.used", "disk.utilization", ] if sys.platform == "linux": expected_metrics.extend(["df_inodes.free", "df_inodes.used", "percent_inodes.free", "percent_inodes.used"]) with Agent.run( """ procPath: /proc monitors: - type: filesystems fsTypes: - "!*" """ ) as agent: assert wait_for( p(has_any_metric_or_dim, agent.fake_services, ["disk.summary_utilization"], []), timeout_seconds=60 ), "timed out waiting for metrics and/or dimensions!" assert ensure_never(lambda: has_any_metric_or_dim(agent.fake_services, expected_metrics, [])) assert not has_log_message(agent.output.lower(), "error"), "error found in agent output!"
def test_load(): expected_metrics = get_monitor_metrics_from_selfdescribe("collectd/load") expected_dims = get_monitor_dims_from_selfdescribe("collectd/load") with run_agent(""" monitors: - type: collectd/load """) as [backend, get_output, _]: assert has_any_metric_or_dim(backend, expected_metrics, expected_dims, timeout=60), \ "timed out waiting for metrics and/or dimensions!" assert not has_log_message(get_output().lower(), "error"), "error found in agent output!"
def test_signalfx_metadata(): expected_metrics = get_monitor_metrics_from_selfdescribe( "collectd/signalfx-metadata") expected_dims = get_monitor_dims_from_selfdescribe( "collectd/signalfx-metadata") with run_agent(""" monitors: - type: collectd/signalfx-metadata procFSPath: /proc etcPath: /etc persistencePath: /var/run/signalfx-agent - type: collectd/cpu """) as [backend, get_output, _]: assert has_any_metric_or_dim(backend, expected_metrics, expected_dims, timeout=60), \ "timed out waiting for metrics and/or dimensions!" assert not has_log_message(get_output().lower(), "error"), "error found in agent output!"
def test_processes(): with open( os.path.join(os.path.dirname(os.path.realpath(__file__)), "metrics.txt"), "r") as fd: expected_metrics = { m.strip() for m in fd.readlines() if len(m.strip()) > 0 } with run_agent(""" monitors: - type: collectd/processes procFSPath: /proc collectContextSwitch: true processMatch: collectd: ".*collectd.*" """) as [backend, get_output, _]: assert has_any_metric_or_dim(backend, expected_metrics, None, timeout=60), \ "timed out waiting for metrics and/or dimensions!" assert not has_log_message(get_output().lower(), "error"), "error found in agent output!"
def test_netio_filter(): expected_metrics = get_monitor_metrics_from_selfdescribe("net-io") try: expected_metrics.remove("network.total") except KeyError: pass with run_agent(""" procPath: /proc monitors: - type: net-io interfaces: - "!*" """) as [backend, get_output, _]: assert wait_for(p(has_any_metric_or_dim, backend, ["network.total"], []), timeout_seconds=60 ), "timed out waiting for metrics and/or dimensions!" assert ensure_never( lambda: has_any_metric_or_dim(backend, expected_metrics, [])) assert not has_log_message(get_output().lower(), "error"), "error found in agent output!"