Ejemplo n.º 1
0
def uptimes():
    ago = timefunc.hours_ago(config.active_age)
    ahead = timefunc.hours_ahead(config.active_future)
    uptimes = avg_uptime()
    #logger.debug("Writing Uptime HTML file %s", config.uptime_report_name)
    filename = "%s/%s" % (config.reportdir, config.uptime_report_name)
    uptimefile = open(filename, 'w')
    uptimefile.write("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css2" />
<meta name="keywords" content="Mixmaster,Remailer,Banana,Bananasplit">
<title>Bananasplit Website - Failing Remailers</title>
<link rel="StyleSheet" href="stats.css" type="text/css">
</head>

<body>
<h1>Remailer Uptimes</h1>
<p>This report provides an overview of the average uptime for each remailer
based on the results from all currently responding pingers.  Consider that this
report doesn't define a scope for acceptable ping results; all are considered
good.  This means a single pinger can skew the average.</p>
<table border="0" bgcolor="#000000">
<tr bgcolor="#F08080">
<th>Remailer Name</th>
<th>Average Uptime</th>
<th>Average Latency</th>
<th>Pingers Reporting</th></tr>\n""")
    rotate_color = 0
    for uptime in uptimes:
        # Rotate background colours for rows
        if rotate_color:
            bgcolor = "#ADD8E6"
        else:
            bgcolor = "#E0FFFF"
        rotate_color = not rotate_color

        name = uptime[0]
        up = uptime[1]
        count = uptime[3]
        lathrs,latmin = timefunc.hours_mins(uptime[2])
        uptimefile.write('<tr bgcolor="%s">' % bgcolor)
        uptimefile.write('<th class="tableleft">%s</th>' % name)
        uptimefile.write('<td>%3.2f</td>' % up)
        uptimefile.write('<td>%d:%02d</td>' % (lathrs, latmin))
        uptimefile.write('<td>%d</td></tr>\n' % (count, ))

    uptimefile.write('</table>\n')
    uptimefile.write('<br>Last update: %s (UTC)<br>\n' % timefunc.utcnow())
    uptimefile.write('<br><a href="index.html">Index</a>\n')
    uptimefile.write('</body></html>')
    uptimefile.close()
Ejemplo n.º 2
0
def writekeystats():
    global now, ago, ahead
    now = timefunc.utcnow()
    ago = timefunc.hours_ago(config.active_age)
    ahead = timefunc.hours_ahead(config.active_future)
    write_stats()
Ejemplo n.º 3
0
def main():
    init_logging()  # Before anything else, initialise logging.
    logger.info("Beginning process cycle at %s (UTC)", timefunc.utcnow())
    socket.setdefaulttimeout(config.timeout)
    global stat_re, addy_re, chain_re
    stat_re = re.compile("(\w{1,12})\s+([0-9A-H?]{12}\s.*)")
    addy_re = re.compile('\$remailer\{"([0-9a-z]{1,12})"\}\s\=\s"\<(.*)\>\s')
    chain_re = re.compile("\((\S{1,12})\s(\S{1,12})\)")

    # Are we running in testmode?  Testmode implies the script was executed
    # without a --live argument.
    testmode = live_or_test(sys.argv)

    # If not in testmode, fetch url's and process them
    if not testmode:
        pingers = db.pinger_names()
        for row in pingers:
            url = url_fetch(row[1])
            if url:
                url_process(row[0], url)
        # Fetch pubring.mix files and write them to the DB
        getkeystats()
    else:
        logger.debug("Running in testmode, url's will not be retreived")

    # We need to do some periodic housekeeping.  It's not very process
    # intensive so might as well do it every time we run.
    db.housekeeping(timefunc.hours_ago(config.dead_after_hours))

    # For a pinger to be considered active, it must appear in tables mlist2
    # and pingers.  This basically means, don't create empty pinger columns
    # in the index file.
    active_pingers = db.active_pinger_names()

    # A boolean value to rotate row colours within the index
    rotate_color = 0

    # The main loop.  This creates individual remailer text files and
    # indexing data based on database values.
    for name, addy in db.distinct_rem_names():
        logger.debug("Generating statsistics for remailer %s", name)

        # remailer_vitals is a dictionary of standard deviation and average
        # values for a specific remailer.
        remailer_vitals = gen_remailer_vitals(name, addy)

        # remailer_active_pings: Based on the vitals generated above, we now
        # extract stats lines for pingers considered active.  The up_hist
        # part is used by the fail_recover routine.
        remailer_active_pings = db.remailer_active_pings(remailer_vitals)
        # If a remailers is perceived to be dead, timestamp it in the
        # genealogy table.  Likewise, if it's not dead, unstamp it.
        fail_recover(name, addy, remailer_active_pings)

        # Write the remailer text file that contains pinger stats and averages
        logger.debug("Writing stats file for %s %s", name, addy)
        write_remailer_stats(name, addy, remailer_vitals)

        # Rotate the colour used in index generation.
        rotate_color = not rotate_color

    db.gene_find_new()
    index()
    genealogy()
    uptimes()
    chainstats()
    writekeystats()
    logger.info("Processing cycle completed at %s (UTC)", timefunc.utcnow())
Ejemplo n.º 4
0
        # remailer_active_pings: Based on the vitals generated above, we now
        # extract stats lines for pingers considered active.  The up_hist
        # part is used by the fail_recover routine.
        remailer_active_pings = db.remailer_active_pings(remailer_vitals)
        # If a remailers is perceived to be dead, timestamp it in the
        # genealogy table.  Likewise, if it's not dead, unstamp it.
        fail_recover(name, addy, remailer_active_pings)

        # Write the remailer text file that contains pinger stats and averages
        logger.debug("Writing stats file for %s %s", name, addy)
        write_remailer_stats(name, addy, remailer_vitals)

        # Rotate the colour used in index generation.
        rotate_color = not rotate_color

    db.gene_find_new()
    index()
    genealogy()
    uptimes()
    chainstats()
    writekeystats()
    logger.info("Processing cycle completed at %s (UTC)", timefunc.utcnow())


# Call main function.
now = timefunc.utcnow()
ago = timefunc.hours_ago(config.active_age)
ahead = timefunc.hours_ahead(config.active_future)
if __name__ == "__main__":
    main()