0

I recently set up a really cheap VPS mainly for backup purposes but I also wanted it to do some small, minor tasks. But because I was too interested I wanted to take a look at CPU and Memory usage, since I only got (probably part of) 1 Core of unknown CPU and 128 MB of RAM, running Ubuntu 16.04 LTS. I created a cronjob calling a PHP Script which checks CPU and Memory usage and if at least one of both is high, it will write the info to a file. I use the PHP systeminfo commands to check CPU and MEM load and then use this to get more info about the processes using up the most CPU.

But for some reason it outputs this:

27.05. 20:05:12 CPU:109% - RAM:72.11%
ps: 1.0 6556 php
ps: 0.5 6518 /usr/sbin/mysqld
ps: 0.0 1 init

28.05. 00:02:43 CPU:288% - RAM:39.45%
ps: 0.1 19968 /usr/sbin/mysqld
ps: 0.0 1 init
ps: 0.0 2 [kthreadd/6457]

28.05. 00:05:01 CPU:158% - RAM:49.24%
ps: 0.1 20046 /usr/bin/python3
ps: 0.0 1 init
ps: 0.0 2 [kthreadd/6457]

So I got the date and time, the CPU and MEM usage by PHP and below the info from ps command: CPU load, PID and command. Would I have to multiply the CPU load numbers by 100 to get % or why are these numbers so low, when obviously the CPU is at 288% load sometimes. Or is this normal behavior for a VPS and PHP is measuring the real CPU load of the whole system while ps is only showing the load of my part of the CPU or the other way around?

Can someone explain please?

fixer1234
  • 27,064
  • 61
  • 75
  • 116
  • First, above all else… It seems like you are over concerned about this. So I would recommend you not worry about this. That said, what happens when you run simply `w`? How about installing `sysstat` and then enabling it and running `car -q`? The issue with that quickie script you are running is it doesn’t seem to factor multiple CPU setups. Meaning, if you have a quad CPU setup and a process is running, it might peg above 100% fairly regularly. But i you were to check the load average via `w` the load would be low. – Giacomo1968 May 28 '18 at 01:16
  • fire up `top` - kernel usage may not show up. And that tool is a bit dodgy. *Standard* tools FTW. htop is neat but in this case... totally go with top – Journeyman Geek May 28 '18 at 02:07

1 Answers1

0

OS might report system-wide CPU usage, at least that's the case for one of my VPSes.

Try installing htop and viewing what's happening inside your VPS to either confirm or deny this.

Gendalph
  • 54
  • 2