Skip to content

Commit

Permalink
Merge pull request #14 from daniel-de-wit/daniel-de-wit-patch-1
Browse files Browse the repository at this point in the history
Replaced Linux CPU calculation with 'top' variant
  • Loading branch information
GijsGoudzwaard authored Aug 10, 2019
2 parents bcbb700 + 3ea1cfe commit 60fe321
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Adapters/LinuxSystemResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct()
*/
public function cpuResources()
{
return floatval(shell_exec("grep 'cpu ' /proc/stat | awk '{printf ($2+$4)*100/($2+$4+$5)}'"));
return floatval(shell_exec('echo "`LC_ALL=C top -bn2 | grep "Cpu(s)" | tail -n1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk \'{print 100 - $1}\'`"'));
}

/**
Expand Down

0 comments on commit 60fe321

Please sign in to comment.