I am running a small Cassandra cluster on Google Compute Engine. From our CPU graphs (as reported by collectd), I notice that a nontrivial amount of processor time is spent in NICE. How can I find out what process is consuming this? I've tried just start top and staring at it for a while, but the NICE cpu usage is a bit spikey (most of the time, NICE is at 0%; only on occasion will it spike up to 30-40%) so "sit and wait" isn't very effective.
Asked
Active
Viewed 1.4k times
7
-
As a first fast check you could check if there are cron jobs using niced processes. – Paolo P. Oct 02 '14 at 13:02
1 Answers
9
"Nice" generally refers to to the priority of a process. (More positive values are lower priority, more negative values are higher priority.) You can run ps -eo nice,pid,args | grep '^\s*[1-9]'
to get a list of positive nice (low priority) commands.
On a CPU graph NICE time is time spent running processes with positive nice value (ie low priority). This means that it is consuming CPU, but will give up that CPU time for most other processes. Any USER CPU time for one of the processes listed in the above ps command will show up as NICE.

David
- 9,288
- 1
- 20
- 52
-
I don't quite understand your grep. Since negative values are low priority, shouldn't I be grepping for processes with a NICE value < 0? It appears that your command is grepping for commands with a positive NICE (i.e. high priority). Here are my results: << 5 30 [ksmd], 19 31 [khugepaged] >>. I think this is probably want I want to run to get negative NICE-valued processes, right? `ps -eo nice,pid,args | grep '^\s*[1-9]'` edit: ugh, it is hard to format things in comments – Ian Rose Oct 08 '14 at 14:26
-
However, note that if I add pcpu to the output format all of the matching processes (each with NICE = -20) they each show pcpu=0.0 so I don't think any of these could account for the NICE cpu that collectd is reporting. – Ian Rose Oct 08 '14 at 14:30
-
Ian, I miss-wrote the parenthetical about priority, which is especially idiotic as I put it there because it's generally confusing. +20 nice is the LOWEST priority. – David Oct 08 '14 at 18:05
-
For anyone following along at home, the answer (from the Cassandra users list) is that Cassandra's compaction threads run at a lower priority. So although the process itself is at p=0, some of the threads (which do quite a bit of work) are at p=4 and thus their cpu time is counted as NICE time. – Ian Rose Oct 08 '14 at 19:49
-
I find using awk to filter ps's output gives a better picture: `ps -eo nice,pid,args | awk '$1 != 0 && $1 != "-" {print $0}'` Can also pipe this to `sort -k1n` to get a numerically sorted list – kaiwan Apr 26 '19 at 01:20