Unverified Commit 32ba3075 authored by dmorley's avatar dmorley

gather enough stats on our own for longterm use

parent 7f7f8db8
...@@ -40,5 +40,6 @@ CREATE TABLE checks ( ...@@ -40,5 +40,6 @@ CREATE TABLE checks (
domain text, domain text,
online boolean, online boolean,
error text, error text,
ttl numeric(8,6),
date_checked timestamp DEFAULT current_timestamp date_checked timestamp DEFAULT current_timestamp
); );
...@@ -107,26 +107,29 @@ while ($row = pg_fetch_assoc($result)) { ...@@ -107,26 +107,29 @@ while ($row = pg_fetch_assoc($result)) {
$outputssl = curl_exec($chss); $outputssl = curl_exec($chss);
$outputsslerror = curl_error($chss); $outputsslerror = curl_error($chss);
$info = curl_getinfo($chss, CURLINFO_CERTINFO); $info = curl_getinfo($chss, CURLINFO_CERTINFO);
$ttl = curl_getinfo($chss, CURLINFO_CONNECT_TIME);
$sslexpire = $info[0]['Expire date'] ?? null; $sslexpire = $info[0]['Expire date'] ?? null;
curl_close($chss); curl_close($chss);
_debug('Nodeinfo output', $outputssl, true); _debug('Nodeinfo output', $outputssl, true);
_debug('Nodeinfo output error', $outputsslerror, true); _debug('Nodeinfo output error', $outputsslerror, true);
_debug('Cert expire date', $sslexpire);
_debug('TTL', $ttl);
//get new json from nodeinfo //get new json from nodeinfo
$jsonssl = json_decode($outputssl); $jsonssl = json_decode($outputssl);
if (!$jsonssl) { if (!$jsonssl) {
_debug('Connection', 'Can not connect to pod'); _debug('Connection', 'Can not connect to pod');
$sql_errors = 'INSERT INTO checks (domain, online, error) VALUES ($1, $2, $3)'; $sql_errors = 'INSERT INTO checks (domain, online, error, ttl) VALUES ($1, $2, $3, $4)';
$result_errors = pg_query_params($dbh, $sql_errors, [$domain, (int) false, $outputsslerror]); $result_errors = pg_query_params($dbh, $sql_errors, [$domain, (int) false, $outputsslerror, $ttl]);
$result_errors || die('Error in SQL query: ' . pg_last_error()); $result_errors || die('Error in SQL query: ' . pg_last_error());
} }
if ($jsonssl !== null) { if ($jsonssl !== null) {
$sql_checks = 'INSERT INTO checks (domain, online) VALUES ($1, $2)'; $sql_checks = 'INSERT INTO checks (domain, online, ttl) VALUES ($1, $2, $3)';
$result_checks = pg_query_params($dbh, $sql_checks, [$domain, (int) true]); $result_checks = pg_query_params($dbh, $sql_checks, [$domain, (int) true, $ttl]);
$result_checks || die('Error in SQL query: ' . pg_last_error()); $result_checks || die('Error in SQL query: ' . pg_last_error());
(!$jsonssl->software->version) || $score += 1; (!$jsonssl->software->version) || $score += 1;
......
...@@ -76,6 +76,7 @@ CREATE TABLE checks ( ...@@ -76,6 +76,7 @@ CREATE TABLE checks (
domain text, domain text,
online boolean, online boolean,
error text, error text,
ttl numeric(8,6),
date_checked timestamp DEFAULT current_timestamp date_checked timestamp DEFAULT current_timestamp
); );
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