mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-02-25 22:38:27 +08:00
add low-on-space notification
Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
parent
27dbeec29d
commit
463a695326
2 changed files with 29 additions and 0 deletions
|
@ -57,6 +57,9 @@ while true; do
|
|||
# Remove dangling images
|
||||
sudo -u www-data docker image prune --force
|
||||
|
||||
# Check for available free space
|
||||
sudo -u www-data php /var/www/docker-aio/php/src/Cron/CheckFreeDiskSpace.php
|
||||
|
||||
# Remove mastercontainer from default bridge network
|
||||
if sudo -u www-data docker inspect nextcloud-aio-mastercontainer --format "{{.NetworkSettings.Networks}}" | grep -q "bridge"; then
|
||||
sudo -u www-data docker network disconnect bridge nextcloud-aio-mastercontainer
|
||||
|
|
26
php/src/Cron/CheckFreeDiskSpace.php
Normal file
26
php/src/Cron/CheckFreeDiskSpace.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
// increase memory limit to 2GB
|
||||
ini_set('memory_limit', '2048M');
|
||||
|
||||
use DI\Container;
|
||||
use AIO\Data\DataConst;
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$container = \AIO\DependencyInjection::GetContainer();
|
||||
|
||||
/** @var \AIO\Docker\DockerActionManager $dockerActionManger */
|
||||
$dockerActionManger = $container->get(\AIO\Docker\DockerActionManager::class);
|
||||
/** @var \AIO\ContainerDefinitionFetcher $containerDefinitionFetcher */
|
||||
$containerDefinitionFetcher = $container->get(\AIO\ContainerDefinitionFetcher::class);
|
||||
|
||||
$id = 'nextcloud-aio-nextcloud';
|
||||
$nextcloudContainer = $containerDefinitionFetcher->GetContainerById($id);
|
||||
|
||||
$df = disk_free_space(DataConst::GetDataDirectory());
|
||||
if ($df !== false && (int)$df < 1024 * 1024 * 1024 * 5) {
|
||||
error_log("The drive that hosts all docker volumes has less than 5 GB free space. Container updates and backups might not succeed due to that!");
|
||||
$dockerActionManger->sendNotification($nextcloudContainer, 'Low on space!', 'The drive that hosts all docker volumes has less than 5 GB free space. Container updates and backups might not succeed due to that!');
|
||||
}
|
Loading…
Reference in a new issue