Last active
January 7, 2022 08:29
-
-
Save joshhartman/18d72f5901ed6e374c5508bf8bdb79b9 to your computer and use it in GitHub Desktop.
Revisions
-
joshhartman revised this gist
Sep 23, 2021 . No changes.There are no files selected for viewing
-
joshhartman revised this gist
Sep 23, 2021 . 1 changed file with 41 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,50 @@ <?php function sys_uptime(){ $uptime = ''; if(is_readable('/proc/uptime')){ $str = @file_get_contents('/proc/uptime'); $num = floatval($str); $secs = $num % 60; $num = (int)($num / 60); $mins = $num % 60; $num = (int)($num / 60); $hours = $num % 24; $num = (int)($num / 24); $days = $num; $uptime = $days.' days, '.$hours.' hours, '.$mins.' minutes, '.$secs.' seconds'; } // /is_readable('/proc/uptime') return $uptime; } $num_cpus=trim(`less /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l`); $cpu_info=trim(`less /proc/cpuinfo`); $num_threads=trim(`nproc`); $mem_info=`free -h`; $disk_info=`df -h`; preg_match_all('/^cpu cores.*?(\d)/m', $cpu_info, $matches); $num_cores = array_sum($matches[1]); $load=sys_getloadavg(); $cpanel_info=json_decode(`uapi ServerInformation get_information --output=json`)->result->data; $cpanel_info_display=''; foreach($cpanel_info as $k=>$obj){ if($obj->type=='service'){ unset($cpanel_info[$k]); }else{ $cpanel_info_display.="{$obj->name}: {$obj->value}".PHP_EOL.PHP_EOL; } } echo '<pre>'; echo "Hostname: ".trim(`hostname`).PHP_EOL.PHP_EOL; echo trim(`less /proc/version`).PHP_EOL.PHP_EOL; echo "Uptime: ".sys_uptime().PHP_EOL.PHP_EOL; echo "Load Averages: {$load[0]} {$load[1]} {$load[2]}".PHP_EOL.PHP_EOL; echo "Number of CPUs: ".$num_cpus.PHP_EOL.PHP_EOL; echo "Total Number of CPU Cores: ".$num_cores.PHP_EOL.PHP_EOL; echo "Total Number of CPU Threads: ".$num_threads.PHP_EOL.PHP_EOL; echo $mem_info.PHP_EOL.PHP_EOL; echo $cpanel_info_display; echo '<textarea style="width:700px; height:500px; max-width:100%;">'.$cpu_info.'</textarea>'.PHP_EOL.PHP_EOL; echo '</pre>'; -
joshhartman created this gist
Sep 23, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ <?php $cpu_info=trim(`less /proc/cpuinfo`); $num_processors=trim(`nproc`); preg_match_all('/^cpu cores.*?(\d)/m', $cpu_info, $matches); $num_cores = array_sum($matches[1]); $load=sys_getloadavg(); echo '<pre>'; echo "Load Averages: {$load[0]} {$load[1]} {$load[2]}".PHP_EOL.PHP_EOL; echo "Number of CPU Cores: ".$num_cores.PHP_EOL.PHP_EOL; echo "Number of CPU Threads: ".$num_processors.PHP_EOL.PHP_EOL; echo '<textarea style="width:600px; height:600px;">'.$cpu_info.'</textarea>'.PHP_EOL.PHP_EOL; echo '</pre>';