2014-06-18 04:11:11 -04:00
|
|
|
<?php
|
2015-07-07 09:57:41 -04:00
|
|
|
require '../autoload.php';
|
2014-06-18 04:15:18 -04:00
|
|
|
$Config = new Config();
|
2014-06-18 04:11:11 -04:00
|
|
|
|
|
|
|
$datas = array();
|
|
|
|
|
2017-03-20 18:19:19 -04:00
|
|
|
# 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
|
2017-03-22 19:26:55 -04:00
|
|
|
if (!(exec('/bin/df -T -P | tail -n +2 | awk \'{ if (NF > 7) { for (i=1; i<NF-6; i++) { printf("%s ", $i); } for (i=NF-6; i<NF; i++) { printf("%s,", $i); } print $NF; } else { print $1","$2","$3","$4","$5","$6","$7; } }\'', $df)))
|
2014-06-18 04:11:11 -04:00
|
|
|
{
|
|
|
|
$datas[] = array(
|
|
|
|
'total' => 'N.A',
|
|
|
|
'used' => 'N.A',
|
|
|
|
'free' => 'N.A',
|
|
|
|
'percent_used' => 0,
|
|
|
|
'mount' => 'N.A',
|
2015-07-13 03:43:34 -04:00
|
|
|
'filesystem' => 'N.A',
|
2014-06-18 04:11:11 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mounted_points = array();
|
2015-07-14 09:16:12 -04:00
|
|
|
$key = 0;
|
2014-06-18 04:11:11 -04:00
|
|
|
|
|
|
|
foreach ($df as $mounted)
|
|
|
|
{
|
2015-07-13 03:43:34 -04:00
|
|
|
list($filesystem, $type, $total, $used, $free, $percent, $mount) = explode(',', $mounted);
|
2014-06-18 04:11:11 -04:00
|
|
|
|
2016-12-24 10:36:20 -05:00
|
|
|
if ($percent > 100)
|
|
|
|
$percent = 100;
|
|
|
|
|
2014-06-18 04:15:18 -04:00
|
|
|
if (strpos($type, 'tmpfs') !== false && $Config->get('disk:show_tmpfs') === false)
|
|
|
|
continue;
|
2014-06-18 04:11:11 -04:00
|
|
|
|
2018-09-02 12:47:03 -04:00
|
|
|
if (strpos($filesystem, '/dev/loop') !== false && $Config->get('disk:show_loop') === false)
|
|
|
|
continue;
|
|
|
|
|
2017-11-01 06:21:01 -04:00
|
|
|
foreach ($Config->get('disk:ignore_mounts') as $to_ignore)
|
|
|
|
{
|
|
|
|
if ($mount === $to_ignore)
|
|
|
|
continue 2;
|
|
|
|
}
|
|
|
|
|
2014-06-18 04:11:11 -04:00
|
|
|
if (!in_array($mount, $mounted_points))
|
|
|
|
{
|
|
|
|
$mounted_points[] = trim($mount);
|
|
|
|
|
2015-07-14 09:16:12 -04:00
|
|
|
$datas[$key] = array(
|
2014-06-18 04:11:11 -04:00
|
|
|
'total' => Misc::getSize($total * 1024),
|
|
|
|
'used' => Misc::getSize($used * 1024),
|
|
|
|
'free' => Misc::getSize($free * 1024),
|
|
|
|
'percent_used' => trim($percent, '%'),
|
|
|
|
'mount' => $mount,
|
|
|
|
);
|
2015-07-14 09:16:12 -04:00
|
|
|
|
|
|
|
if ($Config->get('disk:show_filesystem'))
|
|
|
|
$datas[$key]['filesystem'] = $filesystem;
|
2014-06-18 04:11:11 -04:00
|
|
|
}
|
2015-07-14 09:16:12 -04:00
|
|
|
|
|
|
|
$key++;
|
2014-06-18 04:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-20 12:47:42 -04:00
|
|
|
echo json_encode($datas);
|