def raw(self, host, limit=10): # raw should contain all data to build up the page dynamically for example hostId, host_ui_name = hosts.ensureHostIdAndUIShortname(host) cpuload = topsprocs.getCpuLoad(hostId) load = topsprocs.getLoad(hostId) walvolumes = topsprocs.getWalVolumes(hostId) blocked_processes = topsprocs.getBlockedProcessesCounts(hostId) sizes = tabledata.getDatabaseSizes(hostId) dbstats = reportdata.getDatabaseStatistics(hostId) result = {'load': load, 'cpuload': cpuload, 'walvolumes': walvolumes, 'blocked_processes': blocked_processes, 'sizes': sizes, 'dbstats': dbstats} return result
def raw( self, host, limit=10 ): # raw should contain all data to build up the page dynamically for example hostId, host_ui_name = hosts.ensureHostIdAndUIShortname(host) cpuload = topsprocs.getCpuLoad(hostId) load = topsprocs.getLoad(hostId) walvolumes = topsprocs.getWalVolumes(hostId) blocked_processes = topsprocs.getBlockedProcessesCounts(hostId) sizes = tabledata.getDatabaseSizes(hostId) dbstats = reportdata.getDatabaseStatistics(hostId) result = { 'load': load, 'cpuload': cpuload, 'walvolumes': walvolumes, 'blocked_processes': blocked_processes, 'sizes': sizes, 'dbstats': dbstats, } return result
def default(self, hostId = None): hostId, hostUiName = hosts.ensureHostIdAndUIShortname(max(hostId, self.hostId)) days = cherrypy.request.cookie['days'].value if 'days' in cherrypy.request.cookie else '8' sprocs_to_show = int(cherrypy.request.cookie['sprocs_to_show'].value) if 'sprocs_to_show' in cherrypy.request.cookie else 10 graph_load = None graph_wal = None graph_size = None graph_dbstats = None top_sprocs = None if tplE._settings['show_load']: graph_load = flotgraph.Graph("graph_load","left",30) graph_load.addSeries('CPU Load 15min avg','acpu_15min_avg','#FF0000') cpuload = topsprocs.getCpuLoad(hostId, days) for p in cpuload['load_15min_avg']: graph_load.addPoint('acpu_15min_avg', int(time.mktime(p[0].timetuple()) * 1000) , p[1]) load = topsprocs.getLoad(hostId, days) graph_load.addSeries('Sproc Load 15 min', 'load_15min') for p in load['load_15min']: graph_load.addPoint('load_15min', int(time.mktime(p[0].timetuple()) * 1000) , p[1]) graph_load = graph_load.render() if tplE._settings['show_wal']: graph_wal = flotgraph.Graph("graph_wal", "left", 30) graph_wal.addSeries('WAL vol. 15 min (in MB)', 'wal_15min') walvolumes = topsprocs.getWalVolumes(hostId, days) for p in walvolumes['wal_15min_growth']: graph_wal.addPoint('wal_15min', int(time.mktime(p[0].timetuple()) * 1000) , p[1]) if hosts.isHostFeatureEnabled(hostId, 'blockingStatsGatherInterval'): blocked_processes = topsprocs.getBlockedProcessesCounts(hostId, days) graph_wal.addSeries('#Blocked processes (> 5s)', 'blocked_processes', '#FF0000', None, 2) for p in blocked_processes: if len(walvolumes['wal_15min_growth']) > 0 \ and p[0].timetuple() >= walvolumes['wal_15min_growth'][0][0].timetuple(): # aligning timeline with WAL data graph_wal.addPoint('blocked_processes', int(time.mktime(p[0].timetuple()) * 1000), p[1]) graph_wal = graph_wal.render() if tplE._settings['show_db_size']: graph_size = flotgraph.SizeGraph("graph_size") sizes = tabledata.getDatabaseSizes(hostId, days) if hostId in sizes: tabledata.fillGraph(graph_size,sizes[hostId]) graph_size = graph_size.render() if tplE._settings['show_db_stats']: dbstats = reportdata.getDatabaseStatistics(hostId, days) if len(dbstats) > 0: graph_dbstats = flotgraph.SizeGraph("graph_dbstats") graph_dbstats.addSeries('Temp bytes written', 'temp_files_bytes') graph_dbstats.addSeries('#Backends / 10', 'numbackends', '#C0C0C0', None, 2) graph_dbstats.addSeries('#Deadlocks', 'deadlocks', '#FF0000', None, 2) graph_dbstats.addSeries('#Rollbacks [incl. exceptions]', 'rollbacks', '#FFFF00', None, 2) for d in dbstats: timestamp = int(time.mktime(d['timestamp'].timetuple()) * 1000) graph_dbstats.addPoint('temp_files_bytes', timestamp, d['temp_files_bytes']) graph_dbstats.addPoint('deadlocks', timestamp, d['deadlocks']) graph_dbstats.addPoint('numbackends', timestamp, d['numbackends'] / 10.0) graph_dbstats.addPoint('rollbacks', timestamp, d['rollbacks']) graph_dbstats = graph_dbstats.render() if tplE._settings['show_top_sprocs']: top_sprocs = {} top_sprocs['hours1avg'] = self.renderTop10LastHours(topsprocs.avgRuntimeOrder,1, hostId, sprocs_to_show) top_sprocs['hours3avg'] = self.renderTop10LastHours(topsprocs.avgRuntimeOrder,3, hostId, sprocs_to_show) top_sprocs['hours1total'] = self.renderTop10LastHours(topsprocs.totalRuntimeOrder,1, hostId,sprocs_to_show) top_sprocs['hours3total'] = self.renderTop10LastHours(topsprocs.totalRuntimeOrder,3, hostId,sprocs_to_show) top_sprocs['hours1calls'] = self.renderTop10LastHours(topsprocs.totalCallsOrder,1, hostId,sprocs_to_show) top_sprocs['hours3calls'] = self.renderTop10LastHours(topsprocs.totalCallsOrder,3, hostId,sprocs_to_show) tmpl = tplE.env.get_template('index.html') return tmpl.render(hostid=hostId, hostname=hosts.getHostnameByHostId(hostId), hostuiname=hostUiName, graph_load=graph_load, graph_wal=graph_wal, graph_size=graph_size, graph_dbstats=graph_dbstats, top_sprocs=top_sprocs, limit=sprocs_to_show, features=hosts.getActiveFeatures(hostId), target='World')
def default(self, hostId = None, limit=10): hostUiName = None if hostId == None: hostId = self.hostId if str(hostId).isdigit(): hostId = int(hostId) hostUiName = hosts.hostIdToUiShortname(hostId) else: hostUiName = hostId hostId = int(hosts.uiShortnameToHostId(hostId)) load = topsprocs.getLoad(hostId) cpuload = topsprocs.getCpuLoad(hostId) walvolumes = topsprocs.getWalVolumes(hostId) graph1 = flotgraph.Graph("graph1","left",30) graph_wal = flotgraph.Graph("graph_wal","left",30) graph1.addSeries('CPU Load 15min avg','acpu_15min_avg','#FF0000') for p in cpuload['load_15min_avg']: graph1.addPoint('acpu_15min_avg', int(time.mktime(p[0].timetuple()) * 1000) , p[1]) graph1.addSeries('Sproc Load 15 min', 'load_15min') for p in load['load_15min']: graph1.addPoint('load_15min', int(time.mktime(p[0].timetuple()) * 1000) , p[1]) graph_wal.addSeries('WAL vol. 15 min (in MB)', 'wal_15min') for p in walvolumes['wal_15min_growth']: graph_wal.addPoint('wal_15min', int(time.mktime(p[0].timetuple()) * 1000) , p[1]) sizes = tabledata.getDatabaseSizes(hostId) graph_size = flotgraph.SizeGraph("graph_size") if hostId in sizes: tabledata.fillGraph(graph_size,sizes[hostId]) taggedload = sprocdata.getSprocDataByTags() graphT = flotgraph.BarGraph("graphtag","left",30) graphT.addSeries('Articles','article','#FF0000') graphT.addSeries('Stock','stock','#0000FF') graphT.addSeries('Export','export','#00FF00') graphT.addSeries('get_catalog_article','get_article','#00FFFF') for p in taggedload[1]: graphT.addPoint('article',int(time.mktime(p[0].timetuple()) * 1000), p[1]) for p in taggedload[2]: graphT.addPoint('stock',int(time.mktime(p[0].timetuple()) * 1000), p[1]) for p in taggedload[3]: graphT.addPoint('export',int(time.mktime(p[0].timetuple()) * 1000), p[1]) for p in taggedload[4]: graphT.addPoint('get_article',int(time.mktime(p[0].timetuple()) * 1000), p[1]) tmpl = tplE.env.get_template('index.html') return tmpl.render(hostid=hostId, hostuiname=hostUiName, graph1=graph1.render(), graph_wal=graph_wal.render(), graph_size=graph_size.render(), graphtag = graphT.render(), limit=limit, #top10alltimesavg = self.renderTop10AllTime(topsprocs.avgRuntimeOrder), top10hours1avg = self.renderTop10LastHours(topsprocs.avgRuntimeOrder,1, hostId,limit), top10hours3avg = self.renderTop10LastHours(topsprocs.avgRuntimeOrder,3, hostId,limit), #top10alltimestotal = self.renderTop10AllTime(topsprocs.totalRuntimeOrder), top10hours1total = self.renderTop10LastHours(topsprocs.totalRuntimeOrder,1, hostId,limit), top10hours3total = self.renderTop10LastHours(topsprocs.totalRuntimeOrder,3, hostId,limit), #top10alltimescalls = self.renderTop10AllTime(topsprocs.totalCallsOrder), top10hours1calls = self.renderTop10LastHours(topsprocs.totalCallsOrder,1, hostId,limit), top10hours3calls = self.renderTop10LastHours(topsprocs.totalCallsOrder,3, hostId,limit), target='World')
def default(self, hostId): hostId, hostUiName = hosts.ensureHostIdAndUIShortname( max(hostId, hostId)) days = (cherrypy.request.cookie['days'].value if 'days' in cherrypy.request.cookie else '8') sprocs_to_show = (int(cherrypy.request.cookie['sprocs_to_show'].value) if 'sprocs_to_show' in cherrypy.request.cookie else 10) graph_load = None graph_wal = None graph_size = None graph_dbstats = None top_sprocs = None top_statements = None graph_checkpoint = None global_announcement = reportdata.getGetActiveFrontendAnnouncementIfAny( ) # fyi - no escaping is performed deliberately if tplE._settings.get('show_load', True): graph_load = flotgraph.Graph('graph_load', 'left', 30) graph_load.addSeries('CPU Load 15min avg', 'acpu_15min_avg', '#FF0000') cpuload = topsprocs.getCpuLoad(hostId, days) for p in cpuload['load_15min_avg']: graph_load.addPoint('acpu_15min_avg', int(time.mktime(p[0].timetuple()) * 1000), p[1]) load = topsprocs.getLoad(hostId, days) graph_load.addSeries('Sproc Load 15 min', 'load_15min') for p in load['load_15min']: graph_load.addPoint('load_15min', int(time.mktime(p[0].timetuple()) * 1000), p[1]) graph_load = graph_load.render() if tplE._settings.get('show_wal', True): graph_wal = flotgraph.Graph('graph_wal', 'left', 30) graph_wal.addSeries('WAL vol. 15 min (in MB)', 'wal_15min') walvolumes = topsprocs.getWalVolumes(hostId, days) for p in walvolumes['wal_15min_growth']: graph_wal.addPoint('wal_15min', int(time.mktime(p[0].timetuple()) * 1000), p[1]) if hosts.isHostFeatureEnabled(hostId, 'blockingStatsGatherInterval'): blocked_processes = topsprocs.getBlockedProcessesCounts( hostId, days) graph_wal.addSeries('#Blocked processes (> 5s)', 'blocked_processes', '#FF0000', None, 2) for p in blocked_processes: if len(walvolumes['wal_15min_growth'] ) > 0 and p[0].timetuple( ) >= walvolumes['wal_15min_growth'][0][0].timetuple( ): # aligning timeline with WAL data graph_wal.addPoint( 'blocked_processes', int(time.mktime(p[0].timetuple()) * 1000), p[1]) graph_wal = graph_wal.render() if tplE._settings.get('show_db_size', True): graph_size = flotgraph.SizeGraph('graph_size') sizes = tabledata.getDatabaseSizes(hostId, days) if hostId in sizes: tabledata.fillGraph(graph_size, sizes[hostId]) graph_size = graph_size.render() if tplE._settings.get('show_db_stats', True): dbstats = reportdata.getDatabaseStatistics(hostId, days) if len(dbstats) > 0: graph_dbstats = flotgraph.SizeGraph('graph_dbstats') graph_dbstats.addSeries('Temp bytes written', 'temp_files_bytes') graph_dbstats.addSeries('#Backends / 10', 'numbackends', '#C0C0C0', None, 2) graph_dbstats.addSeries('#Deadlocks', 'deadlocks', '#FF0000', None, 2) graph_dbstats.addSeries('#Rollbacks [incl. exceptions]', 'rollbacks', '#FFFF00', None, 2) for d in dbstats: timestamp = int( time.mktime(d['timestamp'].timetuple()) * 1000) graph_dbstats.addPoint('temp_files_bytes', timestamp, d['temp_files_bytes']) graph_dbstats.addPoint('deadlocks', timestamp, d['deadlocks']) graph_dbstats.addPoint('numbackends', timestamp, d['numbackends'] / 10.0) graph_dbstats.addPoint('rollbacks', timestamp, d['rollbacks']) graph_dbstats = graph_dbstats.render() if tplE._settings.get('show_top_sprocs', True): top_sprocs = {} top_sprocs['hours1avg'] = self.renderTop10LastHours( topsprocs.avgRuntimeOrder, 1, hostId, sprocs_to_show) top_sprocs['hours3avg'] = self.renderTop10LastHours( topsprocs.avgRuntimeOrder, 3, hostId, sprocs_to_show) top_sprocs['hours1total'] = self.renderTop10LastHours( topsprocs.totalRuntimeOrder, 1, hostId, sprocs_to_show) top_sprocs['hours3total'] = self.renderTop10LastHours( topsprocs.totalRuntimeOrder, 3, hostId, sprocs_to_show) top_sprocs['hours1calls'] = self.renderTop10LastHours( topsprocs.totalCallsOrder, 1, hostId, sprocs_to_show) top_sprocs['hours3calls'] = self.renderTop10LastHours( topsprocs.totalCallsOrder, 3, hostId, sprocs_to_show) if tplE._settings.get('show_top_statements', False): top_statements = {} tsd = topstatements.getTopStatementsData(hostId, interval1='3hours', interval2='1hours', limit=sprocs_to_show) if tsd: top_statements[ 'hours1avg'] = self.renderTop10StatementsLastHours( hostId, tsd.get('avg_int2', [])) top_statements[ 'hours3avg'] = self.renderTop10StatementsLastHours( hostId, tsd.get('avg_int1', [])) top_statements[ 'hours1total'] = self.renderTop10StatementsLastHours( hostId, tsd.get('total_int2', [])) top_statements[ 'hours3total'] = self.renderTop10StatementsLastHours( hostId, tsd.get('total_int1', [])) top_statements[ 'hours1calls'] = self.renderTop10StatementsLastHours( hostId, tsd.get('calls_int2', [])) top_statements[ 'hours3calls'] = self.renderTop10StatementsLastHours( hostId, tsd.get('calls_int1', [])) if tplE._settings.get('show_bgwriter_stats', True): graph_checkpoint = self.get_rendered_bgwriter_graph( hostId, int(days)) tmpl = tplE.env.get_template('index.html') return tmpl.render( hostid=hostId, hostname=hosts.getHostnameByHostId(hostId), hostuiname=hostUiName, graph_load=graph_load, graph_wal=graph_wal, graph_size=graph_size, graph_dbstats=graph_dbstats, graph_checkpoint=graph_checkpoint, top_sprocs=top_sprocs, top_statements=top_statements, limit=sprocs_to_show, features=hosts.getActiveFeatures(hostId), global_announcement=global_announcement, target='World', )
def default(self, hostId): hostId, hostUiName = hosts.ensureHostIdAndUIShortname(max(hostId, hostId)) days = cherrypy.request.cookie["days"].value if "days" in cherrypy.request.cookie else "8" sprocs_to_show = ( int(cherrypy.request.cookie["sprocs_to_show"].value) if "sprocs_to_show" in cherrypy.request.cookie else 10 ) graph_load = None graph_wal = None graph_size = None graph_dbstats = None top_sprocs = None top_statements = None graph_checkpoint = None global_announcement = ( reportdata.getGetActiveFrontendAnnouncementIfAny() ) # fyi - no escaping is performed deliberately if tplE._settings.get("show_load", True): graph_load = flotgraph.Graph("graph_load", "left", 30) graph_load.addSeries("CPU Load 15min avg", "acpu_15min_avg", "#FF0000") cpuload = topsprocs.getCpuLoad(hostId, days) for p in cpuload["load_15min_avg"]: graph_load.addPoint("acpu_15min_avg", int(time.mktime(p[0].timetuple()) * 1000), p[1]) load = topsprocs.getLoad(hostId, days) graph_load.addSeries("Sproc Load 15 min", "load_15min") for p in load["load_15min"]: graph_load.addPoint("load_15min", int(time.mktime(p[0].timetuple()) * 1000), p[1]) graph_load = graph_load.render() if tplE._settings.get("show_wal", True): graph_wal = flotgraph.Graph("graph_wal", "left", 30) graph_wal.addSeries("WAL vol. 15 min (in MB)", "wal_15min") walvolumes = topsprocs.getWalVolumes(hostId, days) for p in walvolumes["wal_15min_growth"]: graph_wal.addPoint("wal_15min", int(time.mktime(p[0].timetuple()) * 1000), p[1]) if hosts.isHostFeatureEnabled(hostId, "blockingStatsGatherInterval"): blocked_processes = topsprocs.getBlockedProcessesCounts(hostId, days) graph_wal.addSeries("#Blocked processes (> 5s)", "blocked_processes", "#FF0000", None, 2) for p in blocked_processes: if ( len(walvolumes["wal_15min_growth"]) > 0 and p[0].timetuple() >= walvolumes["wal_15min_growth"][0][0].timetuple() ): # aligning timeline with WAL data graph_wal.addPoint("blocked_processes", int(time.mktime(p[0].timetuple()) * 1000), p[1]) graph_wal = graph_wal.render() if tplE._settings.get("show_db_size", True): graph_size = flotgraph.SizeGraph("graph_size") sizes = tabledata.getDatabaseSizes(hostId, days) if hostId in sizes: tabledata.fillGraph(graph_size, sizes[hostId]) graph_size = graph_size.render() if tplE._settings.get("show_db_stats", True): dbstats = reportdata.getDatabaseStatistics(hostId, days) if len(dbstats) > 0: graph_dbstats = flotgraph.SizeGraph("graph_dbstats") graph_dbstats.addSeries("Temp bytes written", "temp_files_bytes") graph_dbstats.addSeries("#Backends / 10", "numbackends", "#C0C0C0", None, 2) graph_dbstats.addSeries("#Deadlocks", "deadlocks", "#FF0000", None, 2) graph_dbstats.addSeries("#Rollbacks [incl. exceptions]", "rollbacks", "#FFFF00", None, 2) for d in dbstats: timestamp = int(time.mktime(d["timestamp"].timetuple()) * 1000) graph_dbstats.addPoint("temp_files_bytes", timestamp, d["temp_files_bytes"]) graph_dbstats.addPoint("deadlocks", timestamp, d["deadlocks"]) graph_dbstats.addPoint("numbackends", timestamp, d["numbackends"] / 10.0) graph_dbstats.addPoint("rollbacks", timestamp, d["rollbacks"]) graph_dbstats = graph_dbstats.render() if tplE._settings.get("show_top_sprocs", True): top_sprocs = {} top_sprocs["hours1avg"] = self.renderTop10LastHours(topsprocs.avgRuntimeOrder, 1, hostId, sprocs_to_show) top_sprocs["hours3avg"] = self.renderTop10LastHours(topsprocs.avgRuntimeOrder, 3, hostId, sprocs_to_show) top_sprocs["hours1total"] = self.renderTop10LastHours( topsprocs.totalRuntimeOrder, 1, hostId, sprocs_to_show ) top_sprocs["hours3total"] = self.renderTop10LastHours( topsprocs.totalRuntimeOrder, 3, hostId, sprocs_to_show ) top_sprocs["hours1calls"] = self.renderTop10LastHours(topsprocs.totalCallsOrder, 1, hostId, sprocs_to_show) top_sprocs["hours3calls"] = self.renderTop10LastHours(topsprocs.totalCallsOrder, 3, hostId, sprocs_to_show) if tplE._settings.get("show_top_statements", False): top_statements = {} tsd = topstatements.getTopStatementsData( hostId, interval1="3hours", interval2="1hours", limit=sprocs_to_show ) if tsd: top_statements["hours1avg"] = self.renderTop10StatementsLastHours(hostId, tsd.get("avg_int2", [])) top_statements["hours3avg"] = self.renderTop10StatementsLastHours(hostId, tsd.get("avg_int1", [])) top_statements["hours1total"] = self.renderTop10StatementsLastHours(hostId, tsd.get("total_int2", [])) top_statements["hours3total"] = self.renderTop10StatementsLastHours(hostId, tsd.get("total_int1", [])) top_statements["hours1calls"] = self.renderTop10StatementsLastHours(hostId, tsd.get("calls_int2", [])) top_statements["hours3calls"] = self.renderTop10StatementsLastHours(hostId, tsd.get("calls_int1", [])) if tplE._settings.get("show_bgwriter_stats", True): graph_checkpoint = self.get_rendered_bgwriter_graph(hostId, int(days)) tmpl = tplE.env.get_template("index.html") return tmpl.render( hostid=hostId, hostname=hosts.getHostnameByHostId(hostId), hostuiname=hostUiName, graph_load=graph_load, graph_wal=graph_wal, graph_size=graph_size, graph_dbstats=graph_dbstats, graph_checkpoint=graph_checkpoint, top_sprocs=top_sprocs, top_statements=top_statements, limit=sprocs_to_show, features=hosts.getActiveFeatures(hostId), global_announcement=global_announcement, target="World", )