#!/usr/bin/php -q /dev/null|awk '(NR>1){print $1,$2*1024}'",$df); exec("sensors -uA 2>/dev/null|grep -Po 'fan\d_input: \K\d+'",$fans); [$total,$free] = $memory; $used = $total-$free; $names = [_('System'),_('Free')]; $bytes = $echo = []; $hooks = array_filter(glob("/usr/local/emhttp/plugins/*/system/*",GLOB_NOSORT),function($file){return is_executable($file);}); foreach ($hooks as $hook) { $data = @intval(exec(escapeshellarg($hook))); if (!$data || $data>$used) continue; $names[] = _(str_replace('_',' ',basename($hook))); // name of element $bytes[] = $data; // value in bytes } // parse RAM graph $a = 'ram'; $services = $used-array_sum($bytes); $echo[$a][] = round(100*$used/$total)."%"; $echo[$a][] = my_scale($used,$unit,null,-1,1024)." $unit"; $echo[$a][] = round(100*$free/$total); $echo[$a][] = my_scale($free,$unit,null,-1,1024)." $unit"; $echo[$a][] = round(100*$services/$total); $echo[$a][] = my_scale($services,$unit,null,-1,1024)." $unit"; foreach ($bytes as $byte) { // parse hook script information for RAM usage graph $echo[$a][] = round(100*$byte/$total); $echo[$a][] = my_scale($byte,$unit,null,-1,1024)." $unit"; } // add element names $echo['name'] = $names; // parse the graphs for flash, log & docker foreach ($df as $data) { [$pcent,$used] = explode(' ',$data); $echo['sys'][] = [$pcent,my_scale($used,$unit,null,-1,1024)." $unit"]; } // add fans information if (count($fans)) $echo['fan'] = array_map(function($fan){return "$fan RPM";},$fans); // add streams information /* Extract keys from both ini files */ $paths = array_keys($disks); /* Validate and filter accessible mount points */ $valid_paths = array_filter($paths, function($key) { $mnt_path = '/mnt/' . $key; /* Check if the directory exists and is a valid mount point */ return is_dir($mnt_path) && trim((shell_exec("mountpoint -q " . escapeshellarg($mnt_path) . " && echo 1")) ?? '') === '1'; }); /* Construct the list of paths */ $mnt_paths = array_map(function($key) { return '/mnt/'.escapeshellarg($key); }, $valid_paths); /* Combine paths into the command */ $mnt_list = implode(' ', $mnt_paths); /* Build and execute the modified command */ $command = 'LANG="en_US.UTF8" timeout 3 lsof -Fn '.$mnt_list.' 2>/dev/null | awk -F/ \'$1=="n" && $2=="mnt" && $5!="" {print $4"/"$5"/"$6"/"$7}\' | sort -u | awk -F/ \'{print $1}\''; exec($command, $lsof); $share = array_keys($shares); $count = array_count_values($lsof ?? array()); foreach ($share as $name) $echo['stream'][] = $count[$name]??0; $echo = json_encode($echo); $md5_new = md5($echo,true); if ($md5_new !== $md5_old) { $md5_old = publish('update1',$echo)!==false ? $md5_new : -1; } sleep(5); } ?>