Fix to use a new regex for other libs

This commit is contained in:
iliajie
2023-03-03 00:52:56 +02:00
parent 550aa7593b
commit ae805cfdd2
5 changed files with 14 additions and 14 deletions

View File

@@ -323,8 +323,8 @@ if (&get_mounted($_[1], "*") < 0) { return (); }
if ($_[0] eq "proc" || $_[0] eq "swap") { return (); }
my $out;
&execute_command("df -k ".quotemeta($_[1]), undef, \$out, undef, 0, 1);
if ($out =~ /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
return ($1, $2);
if ($out =~ /Mounted on\n\S+\s+(?<total>\S+)\s+(?<used>\S+)\s+(?<free>\S+)\s+(?<percent>\d+)/) {
return ("$+{total}", "$+{free}", "$+{used}", "$+{percent}");
}
else {
return ( );

View File

@@ -107,9 +107,9 @@ sub disk_space
{
if (&get_mounted($_[1], "*") < 0) { return (); }
if ($_[0] eq "proc" || $_[0] eq "swap") { return (); }
if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
/Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
return ($1, $2);
my $out = &backquote_command("df -k ".quotemeta($_[1]), 1);
if ($out =~ /Mounted on\n\S+\s+(?<total>\S+)\s+(?<used>\S+)\s+(?<free>\S+)\s+(?<percent>\d+)/) {
return ("$+{total}", "$+{free}", "$+{used}", "$+{percent}");
}
return ( );
}

View File

@@ -231,9 +231,9 @@ sub disk_space
{
if (&get_mounted($_[1], "*") < 0) { return (); }
if ($_[0] eq "proc" || $_[0] eq "swap") { return (); }
if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
/Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
return ($1, $2);
my $out = &backquote_command("df -k ".quotemeta($_[1]), 1);
if ($out =~ /Mounted on\n\S+\s+(?<total>\S+)\s+(?<used>\S+)\s+(?<free>\S+)\s+(?<percent>\d+)/) {
return ("$+{total}", "$+{free}", "$+{used}", "$+{percent}");
}
return ( );
}

View File

@@ -232,9 +232,9 @@ sub disk_space
{
if (&get_mounted($_[1], "*") < 0) { return (); }
if ($_[0] eq "proc" || $_[0] eq "swap") { return (); }
if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
/Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
return ($1, $2);
my $out = &backquote_command("df -k ".quotemeta($_[1]), 1);
if ($out =~ /Mounted on\n\S+\s+(?<total>\S+)\s+(?<used>\S+)\s+(?<free>\S+)\s+(?<percent>\d+)/) {
return ("$+{total}", "$+{free}", "$+{used}", "$+{percent}");
}
return ( );
}

View File

@@ -262,9 +262,9 @@ if (&get_mounted($_[1], "*") < 0) { return (); }
if ($_[0] eq "fd" || $_[0] eq "proc" || $_[0] eq "swap" || $_[0] eq "autofs") {
return ();
}
if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
/Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
return ($1, $2);
my $out = &backquote_command("df -k ".quotemeta($_[1]), 1);
if ($out =~ /Mounted on\n\S+\s+(?<total>\S+)\s+(?<used>\S+)\s+(?<free>\S+)\s+(?<percent>\d+)/) {
return ("$+{total}", "$+{free}", "$+{used}", "$+{percent}");
}
return ( );
}