1) { $porta = explode(" ", $explodedLine[1])[0]; if (!in_array($porta, $seenPorts)) { // Check if port is not already seen $svcs = explode(" ", $explodedLine[0])[0]; echo "\033[1;33mServico \033[1;37m$svcs \033[1;33mPorta \033[1;37m$porta\n"; $seenPorts[] = $porta; // Add port to seen ports array } } }*/ } function infoport() { $pt = shell_exec("lsof -V -i tcp -P -n | grep -v 'ESTABLISHED' | grep -v 'COMMAND' | grep 'LISTEN'"); $portas = explode("\n", $pt); $seenPorts = array(); // Array to keep track of seen ports foreach ($portas as $linha) { $explodedLine = explode(":", $linha); if (count($explodedLine) > 1) { $porta = explode(" ", $explodedLine[1])[0]; if (!in_array($porta, $seenPorts)) { // Check if port is not already seen $svcs = explode(" ", $explodedLine[0])[0]; echo "\033[1;33mServico \033[1;37m$svcs \033[1;33mPorta \033[1;37m$porta\n"; $seenPorts[] = $porta; // Add port to seen ports array } } } } function cpu() { $minUsage = PHP_INT_MAX; for ($i = 0; $i < 10; $i++) { $usage = exec("top -bn1 | awk '/Cpu/ { cpu = \"\" 100 - $8 \"%\" }; END { print cpu }'"); $parsedUsage = (float) rtrim($usage, '%'); $minUsage = min($minUsage, $parsedUsage); } return $minUsage . '%'; } function ram() { $usoram = exec("free -m | awk 'NR==2{printf \"%.2f%%\t\t\", $3*100/$2 }'"); return $usoram; } function onlines() { $onlines = shell_exec("ps -x | grep sshd | grep -v root | grep priv | wc -l"); $onelines = str_replace(array("\r", "\n"), '', $onlines); return $onelines; }