jrgp / linfo

Linfo PHP Server Health Status
MIT License
361 stars 73 forks source link

Unable to get CPU usage #95

Closed SubrataM3 closed 5 years ago

SubrataM3 commented 6 years ago

Code

$linfo = new \Linfo\Linfo;
$parser = $linfo->getParser();
$cpu = $parser->getCPUUsage();
var_dump($cpu);

Output

/home/www/html/test.php:104:boolean false

RAM usage,Uptime etc works fine though.

System Info PHP => PHP 7.2.8 (cli) (built: Jul 17 2018 09:50:46) ( NTS ) OS => CentOS Linux release 7.5.1804 (Core) Kernel => Linux localhost 3.10.0-862.9.1.el7.x86_64

Its a local virtual machine, so nothing is restricted on PHP side. Please let me know if you need any further information.

Thank you.

jrgp commented 6 years ago

Hey, thanks for reaching out.

Getting CPU usage is a kind of a tricky operation and requires a little bit more in terms of usage. I’ll reply back later with more details (on my phone now and can’t easily look trough things).

Regards

SubrataM3 commented 5 years ago

Hi, any update on this?

jrgp commented 5 years ago

Try

$linfo = new \Linfo\Linfo;
$parser = $linfo->getParser();
$parser->determineCPUPercentage();
$cpu = $parser->getCPUUsage();
var_dump($cpu);
SubrataM3 commented 5 years ago

That works perfectly ! Thank you. :-)