diff --git a/httpd.py b/httpd.py index 89c1de7..330bb73 100644 --- a/httpd.py +++ b/httpd.py @@ -598,9 +598,30 @@ function update(d) { $('failLegend').innerHTML = fhtml; // Leaderboards (session data) - renderLeaderboard('topCountries', d.top_countries_session, 'code', 'count'); renderLeaderboard('topAsns', d.top_asns_session, 'asn', 'count'); + // Country pie chart (database data) + var countryColors = ['#58a6ff','#3fb950','#d29922','#f85149','#a371f7','#39c5cf','#db61a2','#db6d28','#7ee787','#7d8590']; + if (d.db && d.db.top_countries && d.db.top_countries.length > 0) { + var countries = d.db.top_countries.slice(0, 8); + var countryTotal = countries.reduce(function(s, c) { return s + (c.count || c[1] || 0); }, 0); + var segs = [], chtml = ''; + countries.forEach(function(c, i) { + var code = c.code || c[0], cnt = c.count || c[1] || 0; + var col = countryColors[i % countryColors.length]; + var pctVal = countryTotal > 0 ? ((cnt / countryTotal) * 100).toFixed(1) : '0'; + segs.push({c: col, d: (cnt / countryTotal) * 360}); + chtml += '
'; + chtml += '' + code + '' + fmt(cnt) + ''; + chtml += '' + pctVal + '%
'; + }); + $('countryPie').style.background = conicGrad(segs); + $('countryLegend').innerHTML = chtml; + } else { + $('countryPie').style.background = 'var(--border)'; + $('countryLegend').innerHTML = '
No data
'; + } + // Tor pool var thtml = ''; if (d.tor_pool && d.tor_pool.hosts) { @@ -639,15 +660,6 @@ function update(d) { return '
' + p.toUpperCase() + '' + fmt(c) + '
'; }).join(''); - var chtml = ''; - if (dbs.top_countries) { - dbs.top_countries.slice(0, 5).forEach(function(c, i) { - var name = c.code || c[0], cnt = c.count || c[1]; - chtml += '
' + (i + 1) + '
'; - chtml += '' + name + '' + fmt(cnt) + '
'; - }); - } - $('dbCountries').innerHTML = chtml || '
No data
'; } // Scraper/Engine stats @@ -705,6 +717,11 @@ function update(d) { $('dbTestedHour').textContent = fmt(dbh.tested_last_hour); $('dbAddedDay').textContent = fmt(dbh.added_last_day); $('dbDead').textContent = fmt(dbh.dead_count); + $('dbFailing').textContent = fmt(dbh.failing_count); + $('dbFreelist').textContent = fmt(dbh.freelist_count); + $('dbAvgLat').textContent = fmtMs(dbh.db_avg_latency); + $('dbMinLat').textContent = fmtMs(dbh.db_min_latency); + $('dbMaxLat').textContent = fmtMs(dbh.db_max_latency); } // Tor pool enhanced stats @@ -933,14 +950,17 @@ DASHBOARD_HTML = '''
-
Geographic Distribution (Session)
+
Geographic Distribution View Map →
-
Top Countries
-
+
Proxies by Country (Database)
+
+
+
+
-
Top ASNs
+
Top ASNs (Session)
@@ -1023,14 +1043,21 @@ DASHBOARD_HTML = '''
-
-
+
Working by Protocol
-
Top Countries (All Time)
-
+
Latency Stats
+
Average-
+
Min-
+
Max-
+
+
+
Activity
+
Failing-
+
Freelist-