StatsCollector
- class shell_logger.stats_collector.StatsCollector(interval, _)[source]
Bases:
objectCollect statistics while running command in the shell.
Provides an interface for the
ShellLoggerto run commands while collecting various system statistics.Initialize the
StatsCollectorobject.Set the poling interval, and create the process for collecting the statistics.
- Parameters:
interval (
float) – How long to sleep between collecting statistics.
Note
A
SyncManagerwill be supplied at the second argument for any subclasses.- abstract collect()[source]
Instantaneously collect a statistic.
This is meant to be called repeatedly after some time interval.
- Raises:
AbstractMethod – This must be overridden by subclasses.
- finish()[source]
Stop collecting statistics.
Terminate the infinite loop that’s collecting the statistics, and then return the unproxied statistics.
- loop()[source]
Loop while collecting statistics.
Infinitely loop, collecting statistics, until the subprocess is terminated.
- stat_name = 'undefined'
- static subclass(stats_collector_subclass)[source]
Mark a class as being a supported stats collector.
This is a class decorator that adds to a list of supported
StatsCollectorclasses for thestats_collectors()factory method.
- subclasses = [<class 'shell_logger.stats_collector.DiskStatsCollector'>, <class 'shell_logger.stats_collector.CPUStatsCollector'>, <class 'shell_logger.stats_collector.MemoryStatsCollector'>]
- abstract unproxied_stats()[source]
Convert to standard Python data types.
Convert from Python’s Manager’s data structures to base Python data structures.
- Raises:
AbstractMethod – This must be overridden by subclasses.
- shell_logger.stats_collector.stats_collectors()[source]
Generate stats collectors.
A factory method that returns a list of any subclasses of
StatsCollectorthat have the@StatsCollector.subclassdecorator applied to them.- Parameters:
**kwargs – Any supported arguments of the
StatsCollectorsubclasses.- Return type:
- Returns:
A collection of instances of
StatsCollectorsubclasses.
DiskStatsCollector
- class shell_logger.stats_collector.DiskStatsCollector(interval, manager)[source]
Bases:
StatsCollectorA null disk statistics collector for when data aren’t available.
A phony
DiskStatsCollectorused whenpsutilis unavailable. This collects no disk statistics.Initialize the object via the parent’s constructor.
- Parameters:
interval (
float) – How many seconds to sleep between polling.manager (
SyncManager) – The multiprocessing manager used to control the process used to collect the statistics.
- stat_name = 'disk'
CPUStatsCollector
- class shell_logger.stats_collector.CPUStatsCollector(interval, manager)[source]
Bases:
StatsCollectorA null CPU statistics collector for when data aren’t available.
A phony
CPUStatsCollectorused whenpsutilis unavailable. This collects no CPU statistics.Initialize the object via the parent’s constructor.
- Parameters:
interval (
float) – How many seconds to sleep between polling.manager (
SyncManager) – The multiprocessing manager used to control the process used to collect the statistics.
- stat_name = 'cpu'
MemoryStatsCollector
- class shell_logger.stats_collector.MemoryStatsCollector(interval, manager)[source]
Bases:
StatsCollectorA null memory stats collector for when data aren’t available.
A phony
MemoryStatsCollectorused whenpsutilis unavailable. This collects no memory statistics.Initialize the object via the parent’s constructor.
- Parameters:
interval (
float) – How many seconds to sleep between polling.manager (
SyncManager) – The multiprocessing manager used to control the process used to collect the statistics.
- stat_name = 'memory'