PDA

View Full Version : conky - top, and cpus not making sense



KirkD
11th February 2015, 01:30 AM
I've got a nice .conckyrc file (below) that I very much like, but there are a couple of oddities that I can't seem to figure out.

The machine I'm running on has 4 quad core processors. /proc/cpuinfo has 4 lines of processor : # (# being 0 through 3), and each of those has a line cpu cores: 4.

In my .conkyrc file, I have my processor visualizations set up with these lines:



${color #42AE4A}Frequency (in GHz): $freq_g GHz
${color #42AE4A}Average CPU Usage: $cpu%
${cpugraph cpu0 42AE4A eeeeee}
${color #42AE4A}Core 1 ${cpu cpu1}% ${alignr}Core 2 ${cpu cpu2}%
${color #42AE4A}${cpugraph cpu1 25,140 42AE4A eeeeee} ${color #42AE4A} $alignr${color #42AE4A}${cpugraph cpu2 25,140 42AE4A eeeeee}
${color #42AE4A}Core 3 ${cpu cpu3}% ${alignr}Core 4 ${cpu cpu4}%
${color #42AE4A}${cpugraph cpu3 25,140 42AE4A eeeeee} ${color #42AE4A} $alignr${color #42AE4A}${cpugraph cpu4 25,140 42AE4A eeeeee}


But, this isn't really correct, is it? What I am really looking at is the load on a particular processor that may be distributed across its 4 cores, right? Even when I have just one process, I see 75-80% load on any given cpu. Also, extending this to cpu5 or higher gives me extra cpugraphs that are effectively dead.

The other issue I see is in the Top CPU Processes section:



Top CPU Processes${hr}
${color lightblue}Name PID CPU% MEM%
${color red} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color lightblue} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color lightblue} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color lightblue} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
${color lightblue} ${top name 5} ${top pid 5} ${top cpu 5} ${top mem 5}


Here I almost never see more than 10% load for the CPU% column. When I manually run top in a terminal window, I see 25-30% for a number of processes. If I compare the process IDs in top to what I see in conky, they match, but the cpu % load doesn't match.

Interestingly, the Top MEM Processes section seems to match fine.

Any tips on how to clear up these inconsistencies are greatly appreciated.

-Kirk





alignment top_right
background no
border_width 1
cpu_avg_samples 2
default_color white
default_outline_color white
default_shade_color white
double_buffer yes
draw_borders yes
draw_graph_borders yes
draw_outline no
draw_shades no
use_xft yes
xftfont DejaVu Sans Mono:size=10
gap_x 10
gap_y 35
minimum_size 10 10
net_avg_samples 2
no_buffers yes
out_to_console no
out_to_stderr no
extra_newline no
own_window yes
own_window_class Conky
own_window_type desktop
stippled_borders 0
update_interval 1.0
uppercase no
use_spacer left
show_graph_scale no
show_graph_range no
pad_percents 3

TEXT
$alignc${image ~/WorkingData/Pictures/fedora_logo_3D_3.png -p 50,-22}




${color A5C1E4}Fedora 19${alignr}$kernel
${color grey}$hr
${color A5C1E4}${time %a,} ${time %e %B %G}${alignr}${time %H:%M:%S %Z}
${color A5C1E4}Uptime: $uptime
${color grey}$hr
${color gold}File systems:
/ ${fs_used /}/${fs_size /}${alignr}${fs_free_perc /}% free
${fs_bar 6 /}
/home ${fs_used /home}/${fs_size /home}${alignr}${fs_free_perc /home}% free
${fs_bar 6 /home}
Backup/ ${fs_used /run/media/kdelisle/432efe02-d65d-4e1e-a859-c21290e046e7}/${fs_size /run/media/kdelisle/432efe02-d65d-4e1e-a859-c21290e046e7}${alignr}${fs_free_perc /run/media/kdelisle/432efe02-d65d-4e1e-a859-c21290e046e7}% free
${fs_bar 6 /run/media/kdelisle/432efe02-d65d-4e1e-a859-c21290e046e7}
${color grey}$hr
${color #42AE4A}Frequency (in GHz): $freq_g GHz
${color #42AE4A}Average CPU Usage: $cpu%
${cpugraph cpu0 42AE4A eeeeee}
${color #42AE4A}Core 1 ${cpu cpu1}% ${alignr}Core 2 ${cpu cpu2}%
${color #42AE4A}${cpugraph cpu1 25,140 42AE4A eeeeee} ${color #42AE4A} $alignr${color #42AE4A}${cpugraph cpu2 25,140 42AE4A eeeeee}
${color #42AE4A}Core 3 ${cpu cpu3}% ${alignr}Core 4 ${cpu cpu4}%
${color #42AE4A}${cpugraph cpu3 25,140 42AE4A eeeeee} ${color #42AE4A} $alignr${color #42AE4A}${cpugraph cpu4 25,140 42AE4A eeeeee}
${color lightblue}Processes: $processes ${alignr}Running: $running_processes
${color lightblue}RAM Usage: $mem/$memmax - $memperc% ${membar 4}
${color lightblue}Swap Usage: $swap/$swapmax - $swapperc% ${swapbar 4}
Top CPU Processes${hr}
${color lightblue}Name PID CPU% MEM%
${color red} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color lightblue} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color lightblue} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color lightblue} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
${color lightblue} ${top name 5} ${top pid 5} ${top cpu 5} ${top mem 5}
Top MEM Processes${hr}
${color lightblue}Name PID CPU% MEM%
${color red} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
${color lightblue} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
${color lightblue} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}
${color lightblue} ${top_mem name 4} ${top_mem pid 4} ${top_mem cpu 4} ${top_mem mem 4}
${color lightblue} ${top_mem name 5} ${top_mem pid 5} ${top_mem cpu 5} ${top_mem mem 5}

Inodoro Pereyra
11th February 2015, 08:06 AM
You don't have any inconsistencies. Your code is right.

Even when the cores' numbers are 0 to 3, Conky uses cpu0 as the average reading of all your cores. So cpu1 to cpu4 will give you the activity in each separate core. I have seen before that some apps seem to use only one core/thread at a time, eventually switching among them.
Meanwhile, the ${top cpu "x"} instruction will give you the average cpu usage for a given process.

I would suggest you get a "${cpu cpu0}%" line, and maybe a ${cpugraph cpu0...}line with it, to get the average data. Then you will see your cpu0 readings are consistent with your top cpu readings.

OTOH, you can create as many cpu graphs as you like, and the ones without a corresponding cpu# will just show up as dead graphs. But if you run your conky from the terminal, it will tell you you're trying to use more cpu's than you have.

HTH.:)

KirkD
11th February 2015, 08:02 PM
Regarding the Top CPU Processes section, it seems odd to me that I get such a discrepancy in the CPU usage numbers. for example, right now I'm running two very intensive processes that are both paralellized. Each one is allowed to use 4 processors. As a result, my average CPU usage if ~95%, each CPU show 85-100% usage at any point in time, but in the Top CPU Proceses section, I only see on the order of 1.5% as the max CPU%.

Maybe a screenshot will help - compare the cpu bars to the Top CPU Processes sections.

http://s29.postimg.org/e4d7jvkqv/conkyk.pnghttp://

Inodoro Pereyra
13th February 2015, 01:00 AM
Now I see what you mean.
If you run the conky through the terminal, are you getting any errors?
Have you compared it with htop?
Can you post the whole conky, so we can take a look at it?

KirkD
13th February 2015, 01:27 AM
Now I see what you mean.
If you run the conky through the terminal, are you getting any errors?
Have you compared it with htop?
Can you post the whole conky, so we can take a look at it?


Not sure I understand what you mean by running through the terminal. If I start it from the terminal rather than running automatically on startup, I don't get any errors.

Comparison with htop is much closer. What is htop telling me as opposed to top?

The whole .conkyrc file is in my original message. Also, the figure I posted is the full conky window I'm using.

Inodoro Pereyra
13th February 2015, 01:54 AM
Well, that's weird...:confused:

I ran your conky script on my computer, and it runs fine...

[img=http://s20.postimg.org/g0emmg3ax/12_02_2015_21_46_scrot.jpg] (http://postimg.org/image/g0emmg3ax/)

You mind if I send your script and scrot to a friend of mine on the CB forum? He knows way more than I do about conky, and he may be able to see something I'm missing...

KirkD
13th February 2015, 01:55 AM
Let me clarify - it indeed runs fine. I have no problems running it. The trick is that the %CPU usage in the bottom section seems off compared to the upper section of cpugraphs.

Inodoro Pereyra
13th February 2015, 02:03 AM
Yeah, I understand that. But if you look at my scrot, it looks fine on mine.
Granted, I'm not running at full capacity. Maybe that makes a difference...

Sector11
13th February 2015, 01:42 PM
Let me clarify - it indeed runs fine. I have no problems running it. The trick is that the %CPU usage in the bottom section seems off compared to the upper section of cpugraphs.

Yup, your conky is running just fine I don't have the Fedora image so I faked it.

BTW: that $alignc${image ~/Wo... $alignr does nothing, images are absolute and start at 0,0 unless you use the -p flag which you are doing (-p 50,-22)
Also Backup is using my /media/5 and no 4th core so cpu4 repeats cpu1

Another OOPS! I see which my or may not help is ${color} does not use # marks:

${color 42AE4A}Frequency (in GHz): $freq_g GHz
${color 42AE4A}Average CPU Usage: $cpu%
${cpugraph cpu0 42AE4A eeeeee}
${color 42AE4A}Core 1 ${cpu cpu1}% ${alignr}Core 2 ${cpu cpu2}%
${color 42AE4A}${cpugraph cpu1 25,140 42AE4A eeeeee} ${color 42AE4A} ${alignr}${color 42AE4A}${cpugraph cpu2 25,140 42AE4A eeeeee}
${color 42AE4A}Core 3 ${cpu cpu3}% ${alignr}Core 4 ${cpu cpu4}%
${color 42AE4A}${cpugraph cpu3 25,140 42AE4A eeeeee} ${color 42AE4A} ${alignr}${color 42AE4A}${cpugraph cpu4 25,140 42AE4A eeeeee}

No idea if that will help but ....
http://s20.postimg.org/ohxakh5mx/2015_02_13_09_10_44_1920x1080_Sector11.jpg (http://postimg.org/image/ohxakh5mx/)
direct Link (http://postimg.org/image/ohxakh5mx/)

I think something is pushing your CPU usage up there that you are not seeing.
IP was using Fedora, I'm using Debian.

Inodoro Pereyra
14th February 2015, 03:24 AM
THAT'S RIGHT!!!:D

Hey, KirkD, remember I told you about that very knowledgeable guy on the Crunchbang Forum? Well, he just signed up to help you out.:thumb:
Did I mention he was also a very nice guy?

Welcome Sector11:cool:

KirkD
17th February 2015, 08:33 PM
Thanks to you both for all your help!!

I'm a bit confused by some of the comments, though.



BTW: that $alignc${image ~/Wo... $alignr does nothing, images are absolute and start at 0,0 unless you use the -p flag which you are doing (-p 50,-22)


So what you're saying is that I'm using it correctly and that my image alignment is working? I'm confused by the "does nothing" and the "unless you use -p flag, which you are doing" bit.



Also Backup is using my /media/5


I'm not sure what this means.





and no 4th core so cpu4 repeats cpu1


So cpus are numbered from 0 through 3? I guess I was seeing all 4 cpus, just not in the correct order, right?


I'm not sure where the # marks came from before all my colors. I'm guessing from an example I picked up somewhere. I removed them and everything seems normal.

As for the thumbnails both of you posted, I cannot see any detail as I cannot see the full image. The image is only about 2.5 cm square and I cannot expand to the full image.

Inodoro Pereyra
17th February 2015, 11:11 PM
Ok, I can answer your last questions. The first 2 though, are over my head.



So cpus are numbered from 0 through 3? I guess I was seeing all 4 cpus, just not in the correct order, right?

No, CPU's are numbered 1 through 4 in your case. He repeated CPU3 on your conky on his computer, because he's running a 3 core CPU. Remember: CPU 0 is ALWAYS the CPU average in conky.



I'm not sure where the # marks came from before all my colors. I'm guessing from an example I picked up somewhere. I removed them and everything seems normal.

You may have copy/pasted it either from some list, or from Gimp or the like. Since the RGB values are in HEX, they use the hash tag first, but you don't need it in conky.
Either that, or you got them from another conky, where they were commented out.


As for the thumbnails both of you posted, I cannot see any detail as I cannot see the full image. The image is only about 2.5 cm square and I cannot expand to the full image.

I didn't post a thumbnail.
On Sector11's thumbnail, click on the "direct link" right beneath it. You will get a full screen image. :)

Inodoro Pereyra
17th February 2015, 11:16 PM
Oh, I just figure the backup/media5 sentence. He meant that the "backup/" bar in his version of your conky is displaying his "media5" partition, because he doesn't have a "backup" one.

KirkD
17th February 2015, 11:20 PM
Got it! I now see the full screen images instead of thumbnails. :doh:

One more comment regarding my high processor usage:



I think something is pushing your CPU usage up there that you are not seeing.
[\QUOTE]

Actually, the processor usage is all related to the various rsessions. I have a search algorithm that is parallelized and I run it on 4 cpus. If you look at the TOP Processes, you see a bunch of rsessions. When I start those, my cpu graphs are pegged, but the TOP Processes only show 1% or so.

The take home message is that I can start my search algorithm and see processor usage spike accordingly, but the TOP Processes don't show similar levels as the cpugraphs.

---------- Post added at 03:20 PM ---------- Previous post was at 03:19 PM ----------

[QUOTE=Inodoro Pereyra;1724326]Oh, I just figure the backup/media5 sentence. He meant that the "backup/" bar in his version of your conky is displaying his "media5" partition, because he doesn't have a "backup" one.


Got it. That makes sense now.

Inodoro Pereyra
17th February 2015, 11:55 PM
The take home message is that I can start my search algorithm and see processor usage spike accordingly, but the TOP Processes don't show similar levels as the cpugraphs.

Hmmm... there's no magic in computing. There HAS to be something we're overlooking...:confused: