nextcloud / serverinfo

📊 A monitoring app which creates a server info dashboard for admins
GNU Affero General Public License v3.0
94 stars 61 forks source link

Buggy regular expression for available disks #664

Closed AlvaroAguilera closed 3 weeks ago

AlvaroAguilera commented 3 weeks ago

Hello,

this is the output of "df -TPk" for my machine:

Filesystem Type 1024-blocks Used Available Capacity Mounted on /dev/vda4 ext4 51290592 3560060 45092708 8% / devtmpfs devtmpfs 4096 8 4088 1% /dev tmpfs tmpfs 8189732 0 8189732 0% /dev/shm tmpfs tmpfs 3275896 152068 3123828 5% /run tmpfs tmpfs 1637944 4 1637940 1% /run/user/0 /dev/vda5 ext4 205314024 110088996 84722884 57% /nextcloud/my.cloud.domain.xx

Once the script passes through the line:

preg_match_all($pattern, $meminfo, $matches);

The $matches array contains every line except the last one, which is the most important to me. For some reason, the regular expression is cutting that last line...

I'm using NC 29.0.4 on OpenSUSE 15.6.

Thanks.

kesselb commented 3 weeks ago

Thanks for your report :+1:

The "." in the mounted on column is not supported right now.

Subject: [PATCH] allow dots in the mounted column
---
Index: lib/OperatingSystems/Linux.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/OperatingSystems/Linux.php b/lib/OperatingSystems/Linux.php
--- a/lib/OperatingSystems/Linux.php    (revision d3ce8fc53d36218f3533c7426d23a532cc0cefd6)
+++ b/lib/OperatingSystems/Linux.php    (date 1724186424339)
@@ -200,7 +200,7 @@
        }

        $matches = [];
-       $pattern = '/^(?<Filesystem>[\S]+)\s*(?<Type>[\S]+)\s*(?<Blocks>\d+)\s*(?<Used>\d+)\s*(?<Available>\d+)\s*(?<Capacity>\d+%)\s*(?<Mounted>[\w\/-]+)$/m';
+       $pattern = '/^(?<Filesystem>[\S]+)\s*(?<Type>[\S]+)\s*(?<Blocks>\d+)\s*(?<Used>\d+)\s*(?<Available>\d+)\s*(?<Capacity>\d+%)\s*(?<Mounted>[\w\/\-\.]+)$/m';

        $result = preg_match_all($pattern, $disks, $matches);
        if ($result === 0 || $result === false) {