Question

Why is my droplet 100% busy in user space?

Posted April 1, 2021 119 views
Linux Commands

The dashboard and a simple ‘top’ show 100% cpu usage with almost all of it in user space. However in top’s program list there are fewer than 10 user programs, most with less than 1% user/system/etc usage. In contrast 'top -n 1’ shows lots of global idle time.

Can anyone suggest how I can find the CPU hog(s)? These results suggest that some quick to run user space program are running and terminating before a normal 'top’ can display them.

=============

top - 15:51:49 up 110 days, 23:23, 1 user, load average: 1.30, 1.36, 1.33
Tasks: 126 total, 2 running, 85 sleeping, 0 stopped, 0 zombie
%Cpu(s): 83.7 us, 16.3 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1008828 total, 137280 free, 291796 used, 579752 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 410896 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
18643 root 20 0 13732 2036 1292 S 0.7 0.2 531:27.70 /bin/bash /home/noisegraphs/bin/noisegraphsdaemon.sh -a
7 root 20 0 0 0 0 S 0.3 0.0 102:40.03 [ksoftirqd/0]
8 root 20 0 0 0 0 I 0.3 0.0 167:17.85 [rcu_sched]
21067 root 20 0 0 0 0 I 0.3 0.0 0:00.16 [kworker/u2:0]
1 root 20 0 225692 5684 2968 S 0.0 0.6 24:04.54 /lib/systemd/systemd –system –deserialize 35
2 root 20 0 0 0 0 S 0.0 0.0 0:00.61 [kthreadd]
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [kworker/0:0H]

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hello @mystical ,

I would recommend you to try htop as well. It is basically the same as top but the graphs are colourful, more interactive and it’s easier to see the memory and CPU spikes.

If you’re not familiar with the use of both utilities I will highly recommend you to check this tutorial:

https://www.digitalocean.com/community/tutorials/how-to-use-top-netstat-du-other-tools-to-monitor-server-resources

You can also check our existing tutorial on how to monitor CPU usage on your DigitalOcean droplet:

https://www.digitalocean.com/community/tutorials/how-to-monitor-cpu-use-on-digitalocean-droplets

You can also use sar to check what’s going on in your droplet. With sar, you can monitor the performance of various Linux subsystems (CPU, Memory, I/O..) in real-time.

You can use it like this:

To check the memory usage (Free and Used ):

  • sar -r

To check the CPU usage:

  • sar -u

Regards,
Alex

by Justin Ellingwood
Monitoring a server's resources is an important task for every administrator. There are many command line tools made for this purpose. This guide will cover some of the more popular utilities for monitoring your VPS.
  • Hi Alex,

    Thanks for your attention and the links to those very useful articles.

    I find that ‘sar’ doesn’t run on my droplet, and it isn’t clear to me why not:

    rob@wsprdaemon:~$ sar
    Cannot open /var/log/sysstat/sa02: No such file or directory
    Please check if data collecting is enabled
    rob@wsprdaemon:~$

    The results from htop, top and 'vmstat 3’ and the DO droptlet status pages are the same: 100% user space CPU utilization on the summary lines, but only 1 or 2 user programs each using less than 10% cpu.

    Rob

    • Hello there,

      I believe that sar might not be enabled. You can open the config file and enable it and then also start the sysstat service

      Open the file with your favourite text editor, e.g vi, vim or nano:

      • vim /etc/default/sysstat

      and then set enabled from false to true

      ENABLED="true"
      

      Then you need to start/restart the sysstat service

      • service sysstat restart

      Then sar should start collecting data from the logs. However keep in mind that there will be no previous logs to check, so you’ll need to wait a bit before using sar to check the resource usage.

      As for the CPU usage can you confirm if you run the following bash script at all times - /home/noisegraphs/bin/noisegraphsdaemon.sh

      Looking at the information that you’ve provided the CPU usage appears to be not constant at 100%. Keep in mind that if your droplet has only one CPU it’s not uncommon to get CPU spikes from time to time if there are multiple processes running at the same time. As long as the performance is stable, the load is not more than 4 at all times and you’re not experiencing issues this should be fine.

      Regards,
      Alex

      • Hi Alex,

        Your suggestions led me to discover that some corrupted data files were leading /home/noisegraphs/bin/noisegraphsdaemon.sh to repeatedly execute the linux program ‘pngtopnm’ . Since no instance of pngtopnm ran for very long, they rarely showed up on the top or htop lists.

        I have fixed that bug in noisegraphsdaemon.sh and removed the corrupt data files, so now my little droplet is once again 90% idle.

        Thanks for your guidance.

        Rob

        • Hello @mystical / Rob

          I’m glad that you’ve sorted this! Also thanks for sharing what the issue was and how you were able to solve it, because other users can find it useful.

          Regards,
          Alex