@ -21,17 +21,17 @@ if($argc == 2 && $argv[1] == "full") {
@@ -21,17 +21,17 @@ if($argc == 2 && $argv[1] == "full") {
$full = true;
}
echo "[CHECKER] Checking lockfile" . PHP_EOL;
echo date( "H:i:s") . " [CHECKER] Checking lockfile" . PHP_EOL;
$fp = fopen($lockfile, 'c');
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);
}
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
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`");
} else {
@ -39,7 +39,7 @@ if ((($options['fullhour'] >= 0) && ($options['fullhour'] <= 23)) && date('H') =
@@ -39,7 +39,7 @@ if ((($options['fullhour'] >= 0) && ($options['fullhour'] <= 23)) && date('H') =
}
$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);
if ($bob->setnick()) {
$bob->options();
@ -48,11 +48,11 @@ if ($bob->setnick()) {
@@ -48,11 +48,11 @@ if ($bob->setnick()) {
$bob->start();
/* 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);
} 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();
}
@ -75,17 +75,17 @@ try {
@@ -75,17 +75,17 @@ try {
});
//} catch (Amp\TimeoutException $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->clear();
$bob = null;
echo "[DB] Saving check results" . PHP_EOL;
echo date( "H:i:s") . " [DB] Saving check results" . PHP_EOL;
$i = 0;
$pdo->beginTransaction();
@ -98,7 +98,7 @@ foreach ($results as $host => $ts) {
@@ -98,7 +98,7 @@ foreach ($results as $host => $ts) {
$pdo->commit();
echo "[CHECKER] Unlocking and closing lockfile" . PHP_EOL;
echo date( "H:i:s") . " [CHECKER] Unlocking and closing lockfile" . PHP_EOL;
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;