SystemRage / py-kms

KMS Server Emulator written in Python
The Unlicense
2.04k stars 618 forks source link

High CPU load on RPI 4b #61

Closed tlc76 closed 4 years ago

tlc76 commented 4 years ago

I installed py-kms on a RPI 4b with 4GB of RAM and I noticed it takes 100% CPU (1 core out of 4).

top - 19:59:08 up 1 day, 17:34,  1 user,  load average: 0.81, 0.64, 0.82
Tasks: 127 total,   1 running, 126 sleeping,   0 stopped,   0 zombie
%Cpu(s): 25.1 us,  0.0 sy,  0.0 ni, 74.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :   3955.6 total,   2359.3 free,    775.7 used,    820.5 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   3166.2 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
30230 nobody    20   0   49128  16620   9716 S 100.0   0.4   0:30.74 python3
11548 openhab   20   0  610984 370832  15064 S   0.3   9.2   5:33.54 java
30235 openhab+  20   0   10668   3052   2608 R   0.3   0.1   0:00.10 top
    1 root      20   0   33844   8288   6440 S   0.0   0.2   0:31.54 systemd
    2 root      20   0       0      0      0 S   0.0   0.0   0:00.08 kthreadd
    3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp
    4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp
  Load average: 1.00 1.06 1.06                                                                                        Tasks: 45, 243 thr; 2 running
  1  [||                                                                                                      1.1%]   Uptime: 1 day, 17:55:22
  2  [|||||||                                                                                                 5.1%]
  3  [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]
  4  [|                                                                                                       0.5%]
  Mem[|||||||||||||||||||||||||||||||||||||||||||||||                                                   787M/3.86G]
  Swp[                                                                                                       0K/0K]

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
30236 nobody     20   0 49128 16620  9716 R 99.5  0.4 21:07.36 /usr/bin/python3 /opt/py-kms/py-kms/pykms_Server.py --logfile /var/log/pykms_logserver.log
30230 nobody     20   0 49128 16620  9716 S 99.5  0.4 21:08.04 /usr/bin/python3 /opt/py-kms/py-kms/pykms_Server.py --logfile /var/log/pykms_logserver.log
11548 openhab    20   0  596M  362M 15064 S  0.5  9.2  5:56.23 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
  848 openhabia  20   0  9656  3880  2328 R  3.1  0.1  0:00.24 htop
11434 influxdb   20   0  964M  177M 29912 S  0.5  4.5 10:38.58 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
  307 avahi      20   0  5904  2524  2272 S  0.0  0.1  0:59.65 avahi-daemon: running [pi4.local]
11445 influxdb   20   0  964M  177M 29912 S  0.0  4.5  1:05.61 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
11469 influxdb   20   0  964M  177M 29912 S  0.0  4.5  0:50.28 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
11704 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:07.26 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
11738 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:15.82 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
11760 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:13.83 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
11958 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:15.54 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
openhabian@pi4:/opt/py-kms/py-kms $ uname -a
Linux pi4 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux

The log file is empty (size zero).

Is there any way to solve this?

Thanks Cristian

tlc76 commented 4 years ago

I re-run "git clone" and updated the local repository to the latest version. Everything works fine now. py-kms is listed on the second to last row:

 Load average: 0.09 0.34 0.70                                                                                        Tasks: 45, 238 thr; 1 running
  1  [||||||                                                                                                  5.2%]   Uptime: 1 day, 18:05:34
  2  [|||||||||||||||||||||||||                                                                              22.6%]
  3  [||||                                                                                                    3.2%]
  4  [                                                                                                        0.0%]
  Mem[|||||||||||||||||||||||||||||||||||||||||||||||                                                   788M/3.86G]
  Swp[                                                                                                       0K/0K]

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
11434 influxdb   20   0  964M  177M 29912 S 27.7  4.5 11:08.06 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
12106 influxdb   20   0  964M  177M 29912 S  0.0  4.5  0:55.68 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
 1830 openhabia  20   0  9656  4008  2452 R  3.2  0.1  0:02.41 htop
11548 openhab    20   0  596M  362M 15064 S  0.6  9.2  6:13.42 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
28822 openhabia  20   0 12236  3556  2784 S  0.0  0.1  0:02.39 sshd: openhabian@pts/0
  307 avahi      20   0  5904  2524  2272 S  0.0  0.1  1:00.66 avahi-daemon: running [pi4.local]
11760 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:15.04 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
  708 root       20   0 27656    80     0 S  0.0  0.0  0:01.53 /usr/sbin/rngd -r /dev/hwrng
11473 influxdb   20   0  964M  177M 29912 S  0.0  4.5  1:10.16 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
11973 influxdb   20   0  964M  177M 29912 S  0.0  4.5  1:04.06 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
11647 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:22.11 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
11471 influxdb   20   0  964M  177M 29912 S 27.1  4.5  0:49.31 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
11444 influxdb   20   0  964M  177M 29912 S  0.0  4.5  0:42.97 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
11437 influxdb   20   0  964M  177M 29912 S  0.0  4.5  0:58.58 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
11958 openhab    20   0  596M  362M 15064 S  0.6  9.2  0:16.47 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
11751 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:00.71 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
11651 openhab    20   0  596M  362M 15064 S  0.0  9.2  1:04.60 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
11738 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:16.77 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
11678 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:03.25 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
 1592 nobody     20   0 49336 16720  9500 S  0.0  0.4  0:00.63 /usr/bin/python3 /opt/py-kms/py-kms/pykms_Server.py --logfile /var/log/pykms_logserver.log
11752 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:00.51 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
11859 openhab    20   0  596M  362M 15064 S  0.0  9.2  0:03.29 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log
 1604 nobody     20   0 49336 16720  9500 S  0.0  0.4  0:00.26 /usr/bin/python3 /opt/py-kms/py-kms/pykms_Server.py --logfile /var/log/pykms_logserver.log
11502 grafana    20   0  925M 39060 24752 S  0.0  1.0  0:07.03 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=deb cfg:default.paths.logs=/var/log/grafana cfg:default.p

Thanks, Cristian

simonmicro commented 4 years ago

It would be nice to know on which commit you had running it before the re-cloning. If this is fixed for you, please consider to close this issue now.

Thank you.

tlc76 commented 4 years ago

Here is the git log output (partial):

commit 19ef51a6db85d9d5d43e91195b479a751cf0c1fa (HEAD -> master, origin/master, origin/HEAD)
Merge: d73d0f8 6edf98b
Author: Matteo ℱan <SystemRage@protonmail.com>
Date:   Tue Mar 3 23:13:52 2020 +0100

    Merge pull request #55 from Simonmicro/master

    Integrate official docker image

commit 6edf98b2a3daf6786ba74bf60923df7fc60f35a2
Author: Simonmicro <simon@simonmicro.de>
Date:   Sun Feb 23 14:15:04 2020 +0100

    Added docker status badges

commit 5d7927a8f19cf2ee85db525b6f9ff5490152dd02
Author: Simon Beginn <simon@simonmicro.de>
Date:   Sun Feb 23 14:07:12 2020 +0100

    Removed double README and minimized older one

commit a408a65d32a8df615523bdede890a9567d5c14c2
Author: Simon Beginn <simon@simonmicro.de>
Date:   Sun Feb 23 13:54:08 2020 +0100

    Updated the README to point to the official image

commit ed96d5424089e80ba1957b0edb12832b7b5077a6
Author: Simon Beginn <simon@simonmicro.de>
Date:   Sun Feb 23 13:43:23 2020 +0100

    Updated READMEs to point to the original repo

commit 65fa7ae2579afb7add2653b1caba93836b6fc370
Author: Simon Beginn <simon@simonmicro.de>
Date:   Thu Feb 13 13:29:57 2020 +0100

    Rereduced image size after I minimized some line out. Ooops

commit a549c4fa4d255f45fb5ee3984b7adf6f93f53f6a
Author: Simon Beginn <simon@simonmicro.de>
Date:   Thu Feb 13 13:22:29 2020 +0100

    Fixed docker files path problem

Thanks, Cristian

simonmicro commented 4 years ago

Well, that not what I meant, but whatever. Please close this issue now, if you don't need further assistance with this.

tlc76 commented 4 years ago

Apologies, I actually attached the git log because I don't know which commit I had installed at that time. Unfortunately I have no backup since that period... This is why I attached the git log, maybe it gives you an idea.

Thanks for your help, Cristian