From a879c6d95fe57ac38a736016715cf146eb7f74af Mon Sep 17 00:00:00 2001 From: Nicolas LLOBERA Date: Mon, 20 Mar 2017 17:47:42 +0100 Subject: [PATCH 1/4] do not remove spaces from the mount point names --- libs/disk.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/disk.php b/libs/disk.php index 80fedc7..0cf9587 100644 --- a/libs/disk.php +++ b/libs/disk.php @@ -4,7 +4,7 @@ $Config = new Config(); $datas = array(); -if (!(exec('/bin/df -T -P | sed -e \'s/[ \t]//\' | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df))) +if (!(exec('/bin/df -T -P | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df))) { $datas[] = array( 'total' => 'N.A', @@ -52,4 +52,4 @@ else } -echo json_encode($datas); \ No newline at end of file +echo json_encode($datas); From 3aa15d98a9e44a9a99217c4957fa0044daf543a9 Mon Sep 17 00:00:00 2001 From: Nicolas LLOBERA Date: Mon, 20 Mar 2017 23:19:19 +0100 Subject: [PATCH 2/4] manages spaces in mount point names --- libs/disk.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/disk.php b/libs/disk.php index 0cf9587..ebab6bc 100644 --- a/libs/disk.php +++ b/libs/disk.php @@ -4,7 +4,9 @@ $Config = new Config(); $datas = array(); -if (!(exec('/bin/df -T -P | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df))) +# if there are more than 7 awk's colums it means the mount point name contains spaces +# so consider the first colums as a unique colum and the last 6 as real colums +if (!(exec('/bin/df -T -P | tail -n +2 | awk \'{ if (NF > 7) { for (i=1; i 'N.A', From 52a34fd25b709ed282b427290424a3a56342983b Mon Sep 17 00:00:00 2001 From: Nicolas LLOBERA Date: Tue, 21 Mar 2017 16:31:13 +0100 Subject: [PATCH 3/4] fix the awk command --- libs/disk.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/disk.php b/libs/disk.php index ebab6bc..b5ecfb4 100644 --- a/libs/disk.php +++ b/libs/disk.php @@ -6,7 +6,7 @@ $datas = array(); # if there are more than 7 awk's colums it means the mount point name contains spaces # so consider the first colums as a unique colum and the last 6 as real colums -if (!(exec('/bin/df -T -P | tail -n +2 | awk \'{ if (NF > 7) { for (i=1; i 7) { for (i=1; i 'N.A', From 5ebb86e446b4cd858395b54f15028ab592e223a7 Mon Sep 17 00:00:00 2001 From: Nicolas LLOBERA Date: Thu, 23 Mar 2017 00:26:55 +0100 Subject: [PATCH 4/4] fix printf to allow to print % with mawk --- libs/disk.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/disk.php b/libs/disk.php index b5ecfb4..6367114 100644 --- a/libs/disk.php +++ b/libs/disk.php @@ -6,7 +6,7 @@ $datas = array(); # if there are more than 7 awk's colums it means the mount point name contains spaces # so consider the first colums as a unique colum and the last 6 as real colums -if (!(exec('/bin/df -T -P | tail -n +2 | awk \'{ if (NF > 7) { for (i=1; i 7) { for (i=1; i 'N.A',