#!/usr/bin/php
<?php

require __DIR__.'/base/block.php';

$name = $argv[1] ?? 'root';
$mountPoint = $argv[2] ?? '/';
$range1 = $argv[3] ?? 70;
$range2 = $argv[4] ?? 90;

$command = sprintf(
    'df -h %s | tail -n 1',
    escapeshellcmd($mountPoint)
);

$result = trim(shell_exec($command));

if (empty($result)) {
    die;
}

list($dev, $size, $used, $free, $usedP, $point) = explode(' ', preg_replace('/\s+/', ' ', $result));

$percent = intval($usedP);

if ($percent < $range1) {
    $color = color('normal');
} elseif ($percent < $range2) {
    $color = color('warning');
} else {
    $color = color('critical');
}

if (getenv('BLOCK_BUTTON') === '1') {
    $command = 'export DISPLAY=:0; xdg-open '.escapeshellarg('file://'.$mountPoint).'&';
    pclose(popen($command, 'r'));
}

$fullText = pspan($mountPoint, '#ccc', '#222').pspan($percent.'%', $color, '#000');

echo block(
    'mount_point_space_'.$name,
    [
        'full_text' => $fullText,
        'color' => $color,
        'separator' => false,
        'separator_block_width' => 0,
    ]
);
Einfügen
<div%key%id="gist-5c87a4d74514d-a99f74c9f2c5dbb7c3e7459b1e8a332db949b5c8" class="gist-container"></div>
<script src="https://gist.deblan.org/de/embedjs/5c87a4d74514d" async></script>