Merge pull request 'feat: add active users script' (#8) from io/helpers:main into main

Reviewed-on: #8
This commit was merged in pull request #8.
This commit is contained in:
2026-06-23 00:51:52 +02:00

12
active-users Executable file
View File

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