Commit 28678871 authored by dmorley's avatar dmorley Committed by GitHub

cleanup and fix montly stats (#139)

* cleanup and fix montly stats

* year better

* maps key to config, use 1.1.1.1 if nothing else set
parent d021b03a
......@@ -4,16 +4,7 @@ Poduptime is software to get live stats and data on listed Diaspora Pods.
Dependencies:
```
php7.0 php7.0-curl php7.0-pgsql php-geoip php7.0-cli php7.0-common php7.0-json php7.0-readline php-cgi
git
curl
postgresql postgresql-contrib
wget
dnsutils
bind9
npm
nodejs nodejs-legacy
composer
php7.2 php7.2-curl php7.2-pgsql php-geoip php7.2-cli php7.2-common php7.2-json php7.2-readline php-cgi git curl postgresql postgresql-contrib wget dnsutils bind9 npm nodejs nodejs-legacy composer
```
To Install:
......@@ -53,7 +44,7 @@ cd Poduptime
git pull
bower install
composer install
psql -u podupuser podupdb < db/migrationx.sql (see db/version.md for proper migration versions)
psql -U podupuser podupdb < db/migrationXXX.sql (see db/version.md for proper migration versions)
```
============================
......
......@@ -16,7 +16,9 @@ $pgpass = '';
$pgdb = '';
//admin email for forms
$adminemail = '';
//DNS server for dnssec testing
//DNS server for dnssec testing. 1.1.1.1 tests the best
$dnsserver = '';
//CA for curl to use - suggest wget http://curl.haxx.se/ca/cacert.pem as they pull from mozilla if you use a system CA then certs like wosign and startssl will be valid but users will be unable to connect to them
$cafullpath = '';
//Mapbox.com API key. https://www.mapbox.com/help/how-access-tokens-work/
$mapboxkey = '';
......@@ -16,10 +16,10 @@ try {
$monthly_totals = R::getAll("
SELECT
to_char(date_checked, 'yyyy-mm') AS yymm,
sum(total_users) / count(DISTINCT to_char(date_checked, 'HH24 yy')) / count(DISTINCT to_char(date_checked, 'dd yy')) as users,
sum(local_posts) / count(DISTINCT to_char(date_checked, 'HH24 yy')) / count(DISTINCT to_char(date_checked, 'dd yy')) as posts,
sum(comment_counts) / count(DISTINCT to_char(date_checked, 'HH24 yy')) / count(DISTINCT to_char(date_checked, 'dd yy')) as comments,
count(domain) / count(DISTINCT to_char(date_checked, 'HH24 yy')) / count(DISTINCT to_char(date_checked, 'dd yy')) as pods,
sum(total_users) / count(DISTINCT to_char(date_checked, 'HH24 dd')) as users,
sum(local_posts) / count(DISTINCT to_char(date_checked, 'HH24 dd')) as posts,
sum(comment_counts) / count(DISTINCT to_char(date_checked, 'HH24 dd')) as comments,
count(domain) / count(DISTINCT to_char(date_checked, 'HH24 dd')) as pods,
count(nullif(online, false)) as uptime,
count(nullif(online, true)) as downtime
FROM checks
......
......@@ -4,7 +4,7 @@ if (php_sapi_name() == "cli") {
$json = json_decode(file_get_contents('https://the-federation.info/pods.json'));
if ($json) {
foreach ($json->pods ?? [] as $poddata) {
echo exec("php-cgi db/add.php domain={$poddata->host}") . "\r\n";
echo exec("php-cgi add.php domain={$poddata->host}") . "\r\n";
}
}
} else {
......
......@@ -171,6 +171,7 @@ foreach ($pods as $pod) {
_debug('Version code', $shortversion);
_debug('Signup Open', $signup);
$dnsserver = !empty($dnsserver) ? $dnsserver : '1.1.1.1';
$delv = new NPM\Xec\Command("delv @{$dnsserver} {$domain}");
$delv->throwExceptionOnError(false);
......
......@@ -24,16 +24,25 @@ if ! wget -q --spider --tries=2 --timeout=15 https://www.google.com; then
fi
echo "$HAPPY"
if [ "$HOUR" = 01 ]; then
echo "Pulling in master versions...";
php pull-masterversions.php
echo
if [ "$HOUR" = 23 ]; then
printf "%s" "Pulling in master versions..."
if php pull-masterversions.php; then
echo "$HAPPY"
else
echo "$SAD"
fi
printf "%s" "Updating Monthy Stats Table..."
if php monthly_stats.php; then
echo "$HAPPY"
else
echo "$SAD"
fi
printf "%s" "Crawling the federation..."
if php podcrawler.php; then
echo "$HAPPY"
else
echo "$SAD"
fi
printf "%s" "Updating CA..."
if wget -q https://curl.haxx.se/ca/cacert.pem -O ../cacert.pem; then
echo "$HAPPY"
......
......@@ -112,7 +112,7 @@ $navs = [
<?php endforeach; ?>
<p>
<small>Data refreshed: <br><?php echo date('M d y H:i', filemtime($lastfile)); ?> EST</small>
<small>Data refreshed: <br><?php echo date('M d Y H:i', filemtime($lastfile)); ?> EST</small>
</p>
</div>
<div class="main col-md-9 col-lg-10 offset-md-3 offset-lg-2">
......
......@@ -22,7 +22,7 @@ try {
<meta property="og:title" content="<?php echo count($pods); ?> Federated Pods listed, Come see the privacy aware social networks."/>
<div class="hidden-sm-up">Scroll right or rotate device for more</div>
<div class="table-responsive">
<table class="table table-striped table-sm tablesorter-bootstrap table-hover">
<table class="table table-striped table-bordered table-sm tablesorter-bootstrap table-hover">
<thead class="thead-inverse">
<tr>
<th><a data-toggle="tooltip" data-placement="bottom" title="A pod is a site for you to set up your account.">Pod</a></th>
......@@ -40,9 +40,10 @@ try {
$verdiff = str_replace('.', '', $pod['masterversion']) - str_replace('.', '', $pod['shortversion']);
$pod_name = htmlentities($pod['name'], ENT_QUOTES);
$tip = sprintf(
'Uptime %2$s%% over %1$s months.',
'This %3$s pod\'s uptime is %2$s%% over %1$s months.',
$pod['monthsmonitored'],
$pod['uptime_alltime']
$pod['uptime_alltime'],
$pod['softwarename']
);
echo '<tr><td><div title="' . $tip . '" data-toggle="tooltip" data-placement="bottom"><a class="text-success url" target="_self" href="/go.php?domain=' . $pod['domain'] . '">' . $pod['domain'] . '</a></div></td>';
......
......@@ -19,7 +19,7 @@ try {
<meta property="og:title" content="<?php echo count($pods); ?> Federated Pods listed, Come see the privacy aware social networks."/>
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<div class="table-responsive">
<table class="table table-striped table-sm tablesorter-bootstrap table-hover tfont">
<table class="table table-striped table-bordered table-sm tablesorter-bootstrap table-hover tfont">
<thead class="thead-inverse">
<tr>
<th><a data-toggle="tooltip" data-placement="bottom" title="A pod is a site for you to set up your account.">Pod</a></th>
......@@ -28,18 +28,18 @@ try {
<th><a data-toggle="tooltip" data-placement="bottom" title="Percent of the time the pod is online.">Uptime</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Does this pod offer ipv6 connection.">IPv6</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Average connection latency time in ms from Los Angeles.">Latency</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Does this pod allow new users.">Signups</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Number of total users on this pod.">Users</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Does this pod allow new users.">Signup</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Number of total users on this pod.">User</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Number of users active last 6 months on this pod.">6m</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Number of users active last 1 month on this pod.">1m</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Number of total posts on this pod.">Posts</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Number of total comments on this pod.">Comments</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="How many months have we been watching this pod.">Months</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Number of total posts on this pod.">Post</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Number of total comments on this pod.">Comment</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="How many months have we been watching this pod.">Month</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="User rating for this pod.">Rating</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="System Score on a 100 point scale.">Score</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Does this domain use DNSSEC.">DNSSEC</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Pod location, based on IP Geolocation.">Country</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="External Social Networks this pod can post to.">Services</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="External Social Networks this pod can post to.">Service</a></th>
<th><a data-toggle="tooltip" data-placement="bottom" title="Click for more information about this pod from the pod host (podmin).">Info</a></th>
</tr>
</thead>
......@@ -49,7 +49,7 @@ try {
$pod_name = htmlentities($pod['name'], ENT_QUOTES);
$tip = "\n Over {$pod['monthsmonitored']} months uptime is {$pod['uptime_alltime']}% and response time is {$pod['latency']}ms, last check on {$pod['date_updated']}. This site is SSL/TLS encrypted with a cert that expires: " . $pod['sslexpire'];
echo '<tr><td><a title="' . $tip . '" data-toggle="tooltip" data-placement="bottom" target="_self" href="/go.php?domain=' . $pod['domain'] . '">' . $pod['domain'] . '</a></td>';
echo '<tr><td><a title="' . $tip . '" class="text-success url" data-toggle="tooltip" data-placement="bottom" target="_self" href="/go.php?domain=' . $pod['domain'] . '">' . $pod['domain'] . '</a></td>';
if ($pod['shortversion'] > $pod['masterversion']) {
$version = $pod['shortversion'];
......
......@@ -4,6 +4,8 @@ use RedBeanPHP\R;
defined('PODUPTIME') || die();
require_once __DIR__ . '/config.php';
try {
$pods = R::getAll("
SELECT domain, signup, name, lat, long, softwarename, uptime_alltime, active_users_halfyear, service_facebook, service_twitter, service_tumblr, service_wordpress, service_xmpp
......@@ -69,11 +71,11 @@ EOF;
?>
]
};
var tiles = L.tileLayer('https://{s}.tiles.mapbox.com/v4/diasporg.l615e519/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZGlhc3BvcmciLCJhIjoibTVBaldtayJ9.HdGPBIFeZyNKKQqCmU11nA', {
var tiles = L.tileLayer('https://{s}.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.jpg70?access_token=<?php echo $mapboxkey; ?>', {
maxZoom: 18,
attribution: '<a href="https://www.mapbox.com/about/maps/" target="_blank">&copy; Mapbox &copy; OpenStreetMap</a> <a class="mapbox-improve-map" href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a>'
});
var map = L.map('map', {zoom: 3, center: [<?php echo $lat; ?>, <?php echo $long; ?>]}).addLayer(tiles);
var map = L.map('map', {zoom: 4, center: [<?php echo $lat; ?>, <?php echo $long; ?>]}).addLayer(tiles);
var markers = L.markerClusterGroup({
maxClusterRadius: 2, animateAddingMarkers: true, iconCreateFunction: function (cluster) {
return new L.DivIcon({html: '<b class="icon">' + cluster.getChildCount() + '</b>', className: 'mycluster', iconSize: L.point(35, 35)});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment