1 # Copyright 2015 Intel Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 """CollectorController class
17 from core.results.results import IResults
19 class CollectorController(IResults):
20 """Class which defines a collector controller object.
22 Used to set-up and control a collector provider.
25 def __init__(self, collector_class):
26 """Sets up the prerequisites for the Collector.
28 :param collector_class: the Collector class to be used.
30 self._collector = collector_class()
33 def log_mem_stats(self):
36 self._results.append(self._collector.log_mem_stats())
38 def log_cpu_stats(self):
41 self._results.append(self._collector.log_cpu_stats())
43 def get_results(self):
44 """Return collected CPU and memory stats.
46 Implements IResults i/f, see IResults for details.
50 def print_results(self):
51 """Prints collected CPU and memory stats.
53 Implements IResults i/f, see IResults for details.