def createMonitorChart(self, host, report_dir): """Create monitrored server charts.""" stats = self.monitor[host] times = [] for stat in stats: cycles = self.cycle_boundaries.containing_cycles(stat.time) if cycles: stat.cvus = max([self.cycles[cycle] for cycle in cycles]) else: stat.cvus = 0 date = datetime.fromtimestamp(float(stat.time)) times.append(date.strftime("%H:%M:%S")) Plugins = MonitorPlugins() Plugins.registerPlugins() Plugins.configure(self.getMonitorConfig(host)) charts=[] for plugin in Plugins.MONITORS.values(): image_prefix = gnuplot_scriptpath(report_dir, '%s_%s' % (host, plugin.name)) data_prefix = gnuplot_scriptpath(report_dir, '%s_%s' % (host, plugin.name)) gplot_path = str(os.path.join(report_dir, '%s_%s.gplot' % (host, plugin.name))) results = plugin.gnuplot(times, host, image_prefix, data_prefix, gplot_path, [640, 540], stats) if results != None: gnuplot(gplot_path) charts.extend( (name, path.replace(report_dir, '.')) for (name, path) in results ) return charts
def test_register_default(self): """ Make sure all default plugins are loaded """ p=MonitorPlugins() p.registerPlugins() plugins_loaded=p.MONITORS.keys() for plugin in self.default_plugins: self.assertTrue(plugin in plugins_loaded)
def test_MonitorInfo(self): """ Make sure Monitor.MonitorInfo still works with plugins """ from funkload.Monitor import MonitorInfo p=MonitorPlugins() p.registerPlugins() m=MonitorInfo('somehost', p) self.assertTrue(m.host=='somehost')
def test_getStat(self): """ Make sure getStat does not raise any exception """ p=MonitorPlugins() p.registerPlugins() for plugin in self.default_plugins: p.MONITORS[plugin].getStat()
def test_network(self): """ Make sure self.interface is properly read from config in MonitorNetwork plugin """ conf=ConfigParser() conf.add_section('server') conf.set('server', 'interface', 'eth9') p=MonitorPlugins(conf) p.registerPlugins() self.assertTrue(p.MONITORS['MonitorNetwork'].interface == 'eth9')
def test_MonitorThread(self): """ Make sure Monitor.MonitorThread still works with plugins """ from funkload.Monitor import MonitorThread p=MonitorPlugins() p.registerPlugins() records=[] monitor = MonitorThread(records, p, 'localhost', 1) monitor.start() monitor.startRecord() time.sleep(3) monitor.stopRecord() monitor.stop() self.assertTrue(len(records)>0)