Create api.usage.php

This commit is contained in:
Namhyeon Go 2019-01-05 13:13:49 +09:00 committed by GitHub
parent 50bad9debc
commit 67530dc53f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

27
route/api.usage.php Normal file
View File

@ -0,0 +1,27 @@
<?php
loadHelper("exectool");
$result = array(
"success" => true,
"data" => array()
);
$directories = array(
"/home2/hosting_users/easysys/"
);
foreach($directories as $dir) {
$cmd = sprintf("du -Ss %s", $dir);
$output = exec_command($cmd, "shell_exec");
$terms = explode("\t", $output);
$size = intval($terms[0]);
$result['data'] = array(
"directory" => $dir,
"size" => $size
);
}
set_header_content_type("json");
echo json_encode($result);