1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/linuxdash_ynh.git synced 2024-09-03 19:36:07 +02:00
linuxdash_ynh/sources/sh/swap.php
2014-06-02 13:38:03 +02:00

19 lines
383 B
PHP

<?php
exec(
'/bin/cat /proc/swaps | /usr/bin/tail -n +2 | '.
'/usr/bin/awk \'{print $1","$2","$3","$4","$5}\'',
$result
);
header('Content-Type: application/json; charset=UTF-8');
echo "[";
$x = 0;
$max = count($result) - 1;
foreach ($result as $a) {
$x++;
$line = explode(',', $a);
echo json_encode($line);
echo ($x - 1 == $max)? '' : ',';
}
echo ']';