mirror of
https://github.com/PurpleI2P/regi2p.git
synced 2025-01-14 12:57:53 +00:00
[checker] print time to logs
Signed-off-by: r4sas <r4sas@i2pmail.org>
This commit is contained in:
parent
09db7abdea
commit
932fca796f
24
checker.php
24
checker.php
@ -21,17 +21,17 @@ if($argc == 2 && $argv[1] == "full") {
|
|||||||
$full = true;
|
$full = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "[CHECKER] Checking lockfile" . PHP_EOL;
|
echo date("H:i:s") . " [CHECKER] Checking lockfile" . PHP_EOL;
|
||||||
$fp = fopen($lockfile, 'c');
|
$fp = fopen($lockfile, 'c');
|
||||||
|
|
||||||
if(!flock($fp, LOCK_EX | LOCK_NB)) {
|
if(!flock($fp, LOCK_EX | LOCK_NB)) {
|
||||||
echo "[CHECKER] Looks like another checker is running, exiting..." . PHP_EOL;
|
echo date("H:i:s") . " [CHECKER] Looks like another checker is running, exiting..." . PHP_EOL;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "[DB] Fetching hosts to check from database" . PHP_EOL;
|
echo date("H:i:s") . " [DB] Fetching hosts to check from database" . PHP_EOL;
|
||||||
if ((($options['fullhour'] >= 0) && ($options['fullhour'] <= 23)) && date('H') == $options['fullhour'] || $full) { // check all hosts at full check hour or when argument 'full' passed
|
if ((($options['fullhour'] >= 0) && ($options['fullhour'] <= 23)) && date('H') == $options['fullhour'] || $full) { // check all hosts at full check hour or when argument 'full' passed
|
||||||
echo "[CHECKER] Starting FULL check" . PHP_EOL;
|
echo date("H:i:s") . " [CHECKER] Starting FULL check" . PHP_EOL;
|
||||||
$STH = $pdo->query("SELECT `host`, `base32` FROM `hosts`");
|
$STH = $pdo->query("SELECT `host`, `base32` FROM `hosts`");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -39,7 +39,7 @@ if ((($options['fullhour'] >= 0) && ($options['fullhour'] <= 23)) && date('H') =
|
|||||||
}
|
}
|
||||||
$hosts = $STH->fetchAll(PDO::FETCH_KEY_PAIR);
|
$hosts = $STH->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||||
|
|
||||||
echo "[BOB] Starting session for checking" . PHP_EOL;
|
echo date("H:i:s") . " [BOB] Starting session for checking" . PHP_EOL;
|
||||||
$bob = new BOB($options);
|
$bob = new BOB($options);
|
||||||
if ($bob->setnick()) {
|
if ($bob->setnick()) {
|
||||||
$bob->options();
|
$bob->options();
|
||||||
@ -48,11 +48,11 @@ if ($bob->setnick()) {
|
|||||||
$bob->start();
|
$bob->start();
|
||||||
|
|
||||||
/* Sleep 10 seconds awaitng tunnels get built */
|
/* Sleep 10 seconds awaitng tunnels get built */
|
||||||
echo "[BOB] Session started, awaiting 10 seconds for tunnels" . PHP_EOL;
|
echo date("H:i:s") . " [BOB] Session started, awaiting 10 seconds for tunnels" . PHP_EOL;
|
||||||
sleep(10);
|
sleep(10);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
echo "[BOB] Stale session is found, using it" . PHP_EOL;
|
echo date("H:i:s") . " [BOB] Stale session is found, using it" . PHP_EOL;
|
||||||
$bob->getnick();
|
$bob->getnick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,17 +75,17 @@ try {
|
|||||||
});
|
});
|
||||||
//} catch (Amp\TimeoutException $ex) {
|
//} catch (Amp\TimeoutException $ex) {
|
||||||
} catch (\Throwable $ex) {
|
} catch (\Throwable $ex) {
|
||||||
echo "[Checker] Exception: " . $ex . PHP_EOL;
|
echo date("H:i:s") . " [Checker] Exception: " . $ex . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "[BOB] Stopping session" . PHP_EOL;
|
echo date("H:i:s") . " [BOB] Stopping session" . PHP_EOL;
|
||||||
$bob->stop();
|
$bob->stop();
|
||||||
$bob->clear();
|
$bob->clear();
|
||||||
$bob = null;
|
$bob = null;
|
||||||
|
|
||||||
|
|
||||||
echo "[DB] Saving check results" . PHP_EOL;
|
echo date("H:i:s") . " [DB] Saving check results" . PHP_EOL;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$pdo->beginTransaction();
|
$pdo->beginTransaction();
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ foreach ($results as $host => $ts) {
|
|||||||
|
|
||||||
$pdo->commit();
|
$pdo->commit();
|
||||||
|
|
||||||
echo "[CHECKER] Unlocking and closing lockfile" . PHP_EOL;
|
echo date("H:i:s") . " [CHECKER] Unlocking and closing lockfile" . PHP_EOL;
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
|
|
||||||
echo "[CHECKER] Result: Total hosts: " . count($results) . ", Alive: " . $i . PHP_EOL;
|
echo date("H:i:s") . " [CHECKER] Result: Total hosts: " . count($results) . ", Alive: " . $i . PHP_EOL;
|
||||||
|
@ -44,7 +44,7 @@ class Checker implements Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$bob = null;
|
$bob = null;
|
||||||
echo "Processed " . $this->base32 . ": " . ($ts ? "online" : "offline") . PHP_EOL;
|
echo date("H:i:s") . " Processed " . $this->base32 . ": " . ($ts ? "online" : "offline") . PHP_EOL;
|
||||||
return $ts;
|
return $ts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user