5 from teuthology.task import Task
6 from teuthology import misc
9 log = logging.getLogger(__name__)
12 class CheckCounter(Task):
14 Use this task to validate that some daemon perf counters were
15 incremented by the nested tasks.
18 'cluster_name': optional, specify which cluster
19 'target': dictionary of daemon type to list of performance counters.
20 'dry_run': just log the value of the counters, don't fail if they
23 Success condition is that for all of the named counters, at least
24 one of the daemons of that type has the counter nonzero.
26 Example to check cephfs dirfrag splits are happening:
41 cluster_name = self.config.get('cluster_name', None)
42 dry_run = self.config.get('dry_run', False)
43 targets = self.config.get('counters', {})
45 if cluster_name is None:
46 cluster_name = self.ctx.managers.keys()[0]
48 for daemon_type, counters in targets.items():
49 # List of 'a', 'b', 'c'...
50 daemon_ids = list(misc.all_roles_of_type(self.ctx.cluster, daemon_type))
51 daemons = dict([(daemon_id,
52 self.ctx.daemons.get_daemon(daemon_type, daemon_id))
53 for daemon_id in daemon_ids])
57 for daemon_id, daemon in daemons.items():
58 if not daemon.running():
59 log.info("Ignoring daemon {0}, it isn't running".format(daemon_id))
62 log.debug("Getting stats from {0}".format(daemon_id))
64 manager = self.ctx.managers[cluster_name]
65 proc = manager.admin_socket(daemon_type, daemon_id, ["perf", "dump"])
66 response_data = proc.stdout.getvalue().strip()
68 perf_dump = json.loads(response_data)
70 log.warning("No admin socket response from {0}, skipping".format(daemon_id))
73 for counter in counters:
74 subsys, counter_id = counter.split(".")
75 if subsys not in perf_dump or counter_id not in perf_dump[subsys]:
76 log.warning("Counter '{0}' not found on daemon {1}.{2}".format(
77 counter, daemon_type, daemon_id))
79 value = perf_dump[subsys][counter_id]
81 log.info("Daemon {0}.{1} {2}={3}".format(
82 daemon_type, daemon_id, counter, value
89 unseen = set(counters) - set(seen)
91 raise RuntimeError("The following counters failed to be set "
92 "on {0} daemons: {1}".format(