vim_perf

vCenter PerfManager (SOAP) — historical performance counter queries.

REST /api/stats/ exists but is limited to monitor/policy management, not raw counter retrieval with sampling intervals. PerfManager is the only path for things like “give me VM CPU usage every 20 seconds for the past hour” or “summarize cluster memory consumption by month”.

saltext.vcf.clients.vim_perf.counters(opts, profile=None)[source]

Return all counters defined on vCenter, as a dict keyed by counter id.

Each entry includes group, name, unit, rollup_type, stats_type. Useful as a discovery step before calling query().

saltext.vcf.clients.vim_perf.available_metrics(opts, entity_mo_id, entity_type=None, profile=None)[source]

List the perf metrics available for a given managed entity.

entity_mo_id is the MoId (e.g. vm-12, host-9). entity_type is the pyVmomi class name (e.g. VirtualMachine); inferred from the MoId prefix when omitted.

saltext.vcf.clients.vim_perf.query(opts, entity_mo_id, counter_ids, *, entity_type=None, interval_id=20, start_time=None, end_time=None, max_samples=None, profile=None)[source]

Query perf counters for entity_mo_id.

counter_ids is a list of counter integer keys (from counters()). interval_id is the historical interval (20 = real-time on most envs, or one of 300/1800/7200/86400 for aggregated rollups). start_time / end_time are datetime.datetime (UTC). If start_time is omitted and max_samples is also omitted, defaults to the last 10 samples.

saltext.vcf.clients.vim_perf.last_n_seconds(opts, entity_mo_id, counter_ids, seconds=300, **kwargs)[source]

Convenience: query the last seconds of perf data.