mirror of
https://github.com/YunoHost-Apps/linuxdash_ynh.git
synced 2024-09-03 19:36:07 +02:00
21 lines
505 B
PHP
21 lines
505 B
PHP
<?php
|
|
|
|
// Execute top command on server to get results of ps aux
|
|
// each row (including header) is in csv format
|
|
exec(
|
|
'/bin/ps aux | /usr/bin/awk ' .
|
|
"'NR>1{print ".'$1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11'."}'",
|
|
$result
|
|
);
|
|
|
|
header('Content-Type: application/json; charset=UTF-8');
|
|
echo "[";
|
|
$x = 0;
|
|
$max = count($result)-1;
|
|
foreach ($result as $a) {
|
|
echo json_encode(explode(',', $result[$x]));
|
|
echo ($x==$max)?'':',';
|
|
unset($result[$x],$a);
|
|
$x++;
|
|
}
|
|
echo ']';
|