def main(): with open(rrdlib.get_filename("index.html", directory=config.graph_directory), "w") as f: f.write(generate_index_html("1d")) for section in rrdlib.KEYINDEX: filename = rrdlib.get_filename(section, directory=config.graph_directory, extension="html") with open(filename, "w") as f: f.write(generate_section_html(section))
def generate_index_html(duration="6h"): sectionnames = [] Sectionname = namedtuple("Sectionname", ["name", "filename", "graph"]) for sectionname in config.sectionorder: name = sectionname filename = rrdlib.get_filename(sectionname, extension="html") graph = rrdlib.get_filename("{}-{}.png".format(sectionname, duration)) sectionnames.append(Sectionname(name=name, filename=filename, graph=graph)) templ = jinja2.Template(indexhtmltemplate) return templ.render(servername=config.servername, sectionnames=sectionnames)
def generate_section_html(section): sectionnames = [] Sectionname = namedtuple("Sectionname", ["name", "filename"]) for sectionname in config.sectionorder: sectionnames.append(Sectionname(sectionname, rrdlib.get_filename(sectionname, extension="html"))) graphs = [] Graph = namedtuple("Graph", ["duration", "file"]) for duration in config.timespans \ + config.timespans_hourly \ + config.timespans_daily: graphs.append(Graph(duration, rrdlib.get_filename("{}-{}.png".format(section, duration)))) templ = jinja2.Template(sectionhtmltemplate) return templ.render(servername=config.servername, section=section, sectionnames=sectionnames, graphs=graphs)