if avg:
if host['avg'] and avg['avg'] and avg['attempts']+host['attempts']-avg['loss']-host['loss'] > 0:
host['avg'] = ((avg['attempts']-avg['loss'])*avg['avg']+(host['attempts']-host['loss'])*host['avg'])/(avg['attempts']+host['attempts']-avg['loss']-host['loss'])
+ else:
+ host['avg'] = avg['avg']
if not host['best'] or host['best'] > avg['best']:
host['best'] = avg['best']
html.write("<h1>Aktuální odezva klientských zařízení</h1>");
html.write(table_head % time.ctime());
-for kolikaty, host in enumerate(sorted(smokeping, key = lambda host: -host['loss']*attempts*timeout-host['avg'])):
+for kolikaty, host in enumerate(sorted(smokeping, key = lambda host: -host['loss']*host['attempts']*timeout-host['avg'])):
append_host(html, host, smokeping_url, kolikaty+1, red_treshold, green_treshold)
html.write(table_end)
html.write("<h1>Aktuální odezva páteřních routerů</h1>");
html.write(table_head % time.ctime());
-for kolikaty, host in enumerate(sorted(smpater, key = lambda host: -host['loss']*attempts*timeout-host['avg'])):
+for kolikaty, host in enumerate(sorted(smpater, key = lambda host: -host['loss']*host['attempts']*timeout-host['avg'])):
append_host(html, host, smpater_url, kolikaty+1, red_treshold, green_treshold)
html.write(table_end)
html.write("<h1>Průměrná odezva klientských zařízení</h1>");
html.write(table_head % time.ctime());
-for kolikaty, host in enumerate(sorted(smokeping, key = lambda host: -host['loss']*attempts*timeout-host['avg'])):
+for kolikaty, host in enumerate(sorted(smokeping, key = lambda host: -host['loss']*host['attempts']*timeout-host['avg'])):
append_host(html, host, smokeping_url, kolikaty+1, red_treshold, green_treshold)
html.write(table_end)
html.write("<h1>Průměrná odezva páteřních routerů</h1>");
html.write(table_head % time.ctime());
-for kolikaty, host in enumerate(sorted(smpater, key = lambda host: -host['loss']*attempts*timeout-host['avg'])):
+for kolikaty, host in enumerate(sorted(smpater, key = lambda host: -host['loss']*host['attempts']*timeout-host['avg'])):
append_host(html, host, smpater_url, kolikaty+1, red_treshold, green_treshold)
html.write(table_end)