add per-host aggregated block
parent
c54d49022a
commit
a0accaf710
|
@ -34,6 +34,7 @@ Just point kumar to your webservice.
|
||||||
The Output looks something like this:
|
The Output looks something like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
BACKUP|HOST|PATH|STATUS
|
||||||
BACKUP|host1|/opt/mailcow|OK
|
BACKUP|host1|/opt/mailcow|OK
|
||||||
BACKUP|host1|/var/lib/docker/volumes|OK
|
BACKUP|host1|/var/lib/docker/volumes|OK
|
||||||
BACKUP|host2|/opt/docker|OK
|
BACKUP|host2|/opt/docker|OK
|
||||||
|
@ -45,6 +46,12 @@ BACKUP|host4|/var/lib/docker/volumes|OK
|
||||||
BACKUP|host5|/opt/docker|TOO_OLD
|
BACKUP|host5|/opt/docker|TOO_OLD
|
||||||
BACKUP|host5|/var/lib/docker/volumes|TOO_OLD
|
BACKUP|host5|/var/lib/docker/volumes|TOO_OLD
|
||||||
|
|
||||||
|
BACKUP|HOST|STATUS
|
||||||
|
BACKUP|host1|OK
|
||||||
|
BACKUP|host2|OK
|
||||||
|
BACKUP|host3|TOO_OLD
|
||||||
|
BACKUP|host4|OK
|
||||||
|
BACKUP|host5|TOO_OLD
|
||||||
```
|
```
|
||||||
|
|
||||||
output is always sorted by host and path. so you might check a whole block of hosts at once.
|
output is always sorted by host and path. so you might check a whole block of hosts at once.
|
||||||
|
|
|
@ -57,6 +57,7 @@ header("Content-Type: text/plain");
|
||||||
$maxAge = isset($_GET["maxage"]) ? intval($_GET["maxage"]) : 28;
|
$maxAge = isset($_GET["maxage"]) ? intval($_GET["maxage"]) : 28;
|
||||||
$maxAge = $maxAge * 60 * 60;
|
$maxAge = $maxAge * 60 * 60;
|
||||||
$backups = json_decode(file_get_contents("/var/www/data/backups.json"), true);
|
$backups = json_decode(file_get_contents("/var/www/data/backups.json"), true);
|
||||||
|
echo "BACKUP|HOST|PATH|STATUS\n";
|
||||||
foreach ($backups as $backupName => $backupTime) {
|
foreach ($backups as $backupName => $backupTime) {
|
||||||
echo "BACKUP|$backupName|";
|
echo "BACKUP|$backupName|";
|
||||||
if ($backupTime + $maxAge < time()) {
|
if ($backupTime + $maxAge < time()) {
|
||||||
|
@ -66,3 +67,25 @@ foreach ($backups as $backupName => $backupTime) {
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$byHost = [];
|
||||||
|
foreach ($backups as $backupName => $backupTime) {
|
||||||
|
$backupName = explode("|", $backupName);
|
||||||
|
$host = $backupName[0];
|
||||||
|
$path = $backupName[1];
|
||||||
|
if (!isset($byHost[$host])) {
|
||||||
|
$byHost[$host] = PHP_INT_MAX;
|
||||||
|
}
|
||||||
|
$byHost[$host] = min($backupTime, $byHost[$host]);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\nBACKUP|HOST|STATUS\n";
|
||||||
|
foreach ($byHost as $host => $latest) {
|
||||||
|
echo "BACKUP|$host|";
|
||||||
|
if ($latest + $maxAge < time()) {
|
||||||
|
echo "TOO_OLD";
|
||||||
|
} else {
|
||||||
|
echo "OK";
|
||||||
|
}
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue