Files
helpers/active-users
2026-06-23 00:54:31 +02:00

13 lines
351 B
PHP
Executable File

#!/usr/bin/php
<?php
$jsonFile = '/opt/html/online.json';
$activeUsers = shell_exec("ps -eo user=,comm= | awk '$2 ~ /sshd/ {print $1}' | grep -v sshd | sort -u");
$activeUsersArray = array_filter(explode("\n", $activeUsers));
$activeUsersJson = json_encode($activeUsersArray, JSON_PRETTY_PRINT);
file_put_contents($jsonFile, $activeUsersJson);
?>