Merge lp:~dlancer/ubuntu/quantal/g15stats/lp-749834 into lp:ubuntu/quantal/g15stats

Proposed by dlancer
Status: Work in progress
Proposed branch: lp:~dlancer/ubuntu/quantal/g15stats/lp-749834
Merge into: lp:ubuntu/quantal/g15stats
Diff against target: 722 lines (+282/-117)
9 files modified
ChangeLog (+20/-0)
Makefile.am (+2/-2)
README (+3/-0)
configure.in (+2/-2)
debian/changelog (+13/-0)
debian/control (+2/-1)
g15stats.1 (+62/-11)
g15stats.c (+176/-101)
g15stats.h (+2/-0)
To merge this branch: bzr merge lp:~dlancer/ubuntu/quantal/g15stats/lp-749834
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Needs Fixing
Ubuntu branches Pending
Review via email: mp+108794@code.launchpad.net

Description of the change

New upstream version merged (this also fix LP: #749834).
Man page updated, new supported options added.

To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote :

Please forward this to Debian. It'd be nice to get this updated in Debian, and then we can sync it into Ubuntu.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I agree with Stefano, and I would have even sponsored this into Debian but it's frozen now. So I'd be happy to review this and possibly sponsor this into ubuntu delta.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

- If you are packaging a new upstream release ahead of debian the revision number would generally be -0ubuntu1 as the version number should be bigger than anything in ubuntu, but less than something in debian. The -1 is reserved for debian to package the new upstream release for Debian.

- And you should use just one debian/changelog entry with version 1.9.7-0ubuntu1 instead of two changelog entries.

- Maintainer name is usually in the form of "Name Lastname <email address hidden>"
If you want to keep doing anonymous contributions, it is fine and you will find sponsors who will be willing to upload for you. To become a developer you will need become part of the GPG web-of-trust and connect to Debian/Ubuntu Developers. See http://www.debian.org/devel/join/nm-step2 for further details.

- You have correctly done a 'minimal' / least intrusive update.

In general though it would be nice to modernise packaging and fix these lintian warnings:

I: g15stats source: binary-control-field-duplicates-source field "section" in package g15stats
I: g15stats source: missing-debian-source-format
P: g15stats source: direct-changes-in-diff-but-no-patch-system g15stats.1
W: g15stats source: ancient-standards-version 3.8.2 (current is 3.9.3)
W: g15stats: possible-new-upstream-release-without-new-version
P: g15stats: copyright-with-old-dh-make-debian-copyright
W: g15stats: description-synopsis-starts-with-article
I: g15stats: hyphen-used-as-minus-sign usr/share/man/man1/g15stats.1.gz:32
I: g15stats: hyphen-used-as-minus-sign usr/share/man/man1/g15stats.1.gz:38
I: g15stats: hyphen-used-as-minus-sign usr/share/man/man1/g15stats.1.gz:43
I: g15stats: hyphen-used-as-minus-sign usr/share/man/man1/g15stats.1.gz:51
I: g15stats: hyphen-used-as-minus-sign usr/share/man/man1/g15stats.1.gz:59

I will do a MIA ping of the Debian Maintainer.
In the mean time please at least change the version numbers to -0ubuntu1 or potentially do a bit more on the package:
- use 3.0 (quilt) format
- put your manpage diff into a patch under debian/patches/
- update copyright file to use 1.0 copyright format
- correct debian/control as per lintian

Then I can upload this into ubuntu and/or possibly debian if the maintainer is MIA.

Please set this merge proposal back to 'Needs Review' after you have made an update.

review: Needs Fixing
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Also your changelog should mention (LP: #749834) to close that bug automatically upon upload.

Unmerged revisions

6. By dlancer <email address hidden>

New upstream release.
Man page updated.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2009-08-04 13:15:38 +0000
3+++ ChangeLog 2012-06-05 18:03:18 +0000
4@@ -60,3 +60,23 @@
5 SVN 520 (1.9.2)
6 - Disable monitoring CPUs frequencies with the option -df
7 - Improve Summary Screen without CPUs frequencies
8+SVN 530 (1.9.3)
9+- Activate the bottom info bar content rotate with the option -ir
10+- Change bottom info bar content to the component default one
11+- Activate variable CPUs count with the option -vc
12+- Improve Fan bottom info
13+SVN 531 (1.9.4)
14+- Fix time info
15+- Improve Fan / Temperature Screens leading labels position
16+- Improve Fan / Temperature Screens height calculation
17+- Improve Summary Screen multi bar (temperature and network)
18+SVN 532 (1.9.5)
19+- Improve Summary Screen multi bar (temperature and network)
20+- Fix compilation with the newer version of the glibc
21+- Improve refresh interval causing -nan error with the newer kernel on very fast machines due to too often glibtop probing
22+- Fix possible -nan error on the fast screens switch
23+- Change refresh interval with the option -r seconds (The seconds must be between 1 and 300)
24+SVN 534 (1.9.6)
25+- Improve Summary Screen with 3 and 6 core CPU
26+SVN 538 (1.9.7)
27+- Improve Summary Screen Fan / Temperature sensors bar calculation
28
29=== modified file 'Makefile.am'
30--- Makefile.am 2011-03-15 08:04:59 +0000
31+++ Makefile.am 2012-06-05 18:03:18 +0000
32@@ -1,5 +1,5 @@
33
34-AM_CFLAGS = -O3 -Wall @CFLAGS@ -I$(top_builddir) -I$(top_srcdir)
35+AM_CFLAGS = -O3 -Wall @CFLAGS@ -I$(top_builddir) -I$(top_srcdir)
36 METASOURCES = AUTO
37 bin_PROGRAMS = g15stats
38 noinst_HEADERS = g15stats.h
39@@ -7,7 +7,7 @@
40 docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
41 doc_DATA = README ChangeLog AUTHORS NEWS COPYING
42
43-LIBS = -lg15daemon_client -lg15render -lpthread -lm
44+LIBS = -lg15daemon_client -lg15render -lpthread -lm -lrt
45 IMCLUDES = -I
46 g15stats_LDFLAGS = -avoid-version
47 g15stats_SOURCES = g15stats.c g15stats.h
48
49=== modified file 'README'
50--- README 2009-08-04 13:15:38 +0000
51+++ README 2012-06-05 18:03:18 +0000
52@@ -30,6 +30,7 @@
53 -nsa Scale network graphs against highest speed recorded. The
54 default is to scale against the highest peak in the current graph.
55 -h Show help
56+-r seconds Set the refresh interval to seconds The seconds must be between 1 and 300. ie -r 15
57 -u Display unicore graphs only on the CPU screen
58 -t id Force to monitor temperature sensor id on start (ie -t 1)
59 The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input
60@@ -40,6 +41,8 @@
61 -gt id Show temperature [id] in place of the maximal one on the Summary Screen with the option -gt id ie -gt 1
62 The id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input
63 -df Disable monitoring CPUs frequencies.
64+-ir enable the bottom info bar content rotate cycle over all available sensors
65+-vc The cpu cores will be calculated every time (for systems with the cpu hotplug)
66
67 Usage:
68 $> g15stats
69
70=== modified file 'configure.in'
71--- configure.in 2009-08-04 13:15:38 +0000
72+++ configure.in 2012-06-05 18:03:18 +0000
73@@ -1,7 +1,7 @@
74-AC_INIT(g15stats,[1.1], [mlampard@users.sf.net])
75+AC_INIT(g15stats,[1.9.7], [mlampard@users.sf.net])
76
77 PACKAGE=g15stats
78-VERSION=1.9.2
79+VERSION=1.9.7
80 AC_PREFIX_DEFAULT(/usr)
81 AC_CONFIG_AUX_DIR(config)
82 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
83
84=== modified file 'debian/changelog'
85--- debian/changelog 2011-03-15 08:04:59 +0000
86+++ debian/changelog 2012-06-05 18:03:18 +0000
87@@ -1,3 +1,16 @@
88+g15stats (1.9.7-1ubuntu1) quantal; urgency=low
89+
90+ * New upstream release.
91+ * Man page updated.
92+
93+ -- dlancer <dmdpost@gmail.com> Tue, 05 Jun 2012 21:20:17 +0600
94+
95+g15stats (1.9.7-1) UNRELEASED; urgency=low
96+
97+ * New upstream release.
98+
99+ -- dlancer <dmdpost@gmail.com> Tue, 05 Jun 2012 21:19:30 +0600
100+
101 g15stats (1.9.2-2) unstable; urgency=low
102
103 * Supports binutils-gold linker, writing explicitly our library
104
105=== modified file 'debian/control'
106--- debian/control 2011-03-15 08:04:59 +0000
107+++ debian/control 2012-06-05 18:03:18 +0000
108@@ -1,7 +1,8 @@
109 Source: g15stats
110 Section: utils
111 Priority: extra
112-Maintainer: Giacomo Catenazzi <cate@debian.org>
113+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
114+XSBC-Original-Maintainer: Giacomo Catenazzi <cate@debian.org>
115 Build-Depends: cdbs, debhelper (>= 5), autotools-dev,
116 libxtst-dev, libfreetype6-dev, libusb-dev, libgtop2-dev,
117 libg15-dev, libg15render-dev (>= 1.2-3), libg15daemon-client-dev,
118
119=== modified file 'g15stats.1'
120--- g15stats.1 2008-03-18 08:09:06 +0000
121+++ g15stats.1 2012-06-05 18:03:18 +0000
122@@ -1,4 +1,4 @@
123-.TH "g15stats" "1" "14 Feb 2008" "G15Daemon - g15stats" "G15Daemon User Manual"
124+.TH "g15stats" "1" "06 Jun 2012" "G15Daemon - g15stats" "G15Daemon User Manual"
125
126 .SH "NAME"
127 g15stats \- A CPU/Memory/Swap usage meter for G15Daemon
128@@ -23,19 +23,70 @@
129 .br
130 .P
131 .HP
132-\-h,--help show usage information.
133-.P
134-.HP
135-\-d,--daemon run in background.
136-.P
137-.HP
138-\-i,--interface [interface] monitor network interface [interface] ie -i eth0.
139-.P
140-.HP
141-\-nsa,--net-scale-absolute scale net graphs against maximum speed seen.
142+\-h,--help Show usage information.
143+.P
144+.HP
145+\-d,--daemon Run in background.
146+.P
147+.HP
148+\-i,--interface [interface] Monitor network interface [interface] ie -i eth0.
149+.P
150+.HP
151+\-nsa,--net-scale-absolute Scale net graphs against maximum speed seen.
152+.P
153+.HP
154+\-r seconds Set the refresh interval to seconds, the seconds must be between 1 and 300. ie -r 15
155+.P
156+.HP
157+\-u Display unicore graphs only on the CPU screen
158+.HP
159+\-t id Force to monitor temperature sensor id on start (ie -t 1)
160+.br
161+The id should point to sysfs path:
162+.br
163+ /sys/class/hwmon/hwmon[id]/device/temp1_input
164+.br
165+Default the sensor id is auto-detected.
166+.HP
167+\-f id Force to monitor fan speed sensor id on start (ie -f 1)
168+.br
169+The id should point to sysfs path:
170+.br
171+ /sys/class/hwmon/hwmon[id]/device/fan1_input
172+.br
173+Default the sensor id is auto-detected.
174+.HP
175+\-gt id Show temperature [id] in place of the maximal one on the Summary Screen with the option -gt id ie -gt 1
176+.br
177+The id should point to sysfs path:
178+.br
179+/sys/class/hwmon/hwmon../device/temp[id]_input
180+.P
181+.HP
182+\-df Disable monitoring CPUs frequencies.
183+.P
184+.HP
185+\-ir Enable the bottom info bar content rotate cycle over all available sensors
186+.P
187+.HP
188+\-vc The cpu cores will be calculated every time (for systems with the cpu hotplug)
189+
190+.SH "USAGE"
191+.P
192+Once running, the separate screens can be switched to as follows:
193+.br
194+L2: Previous Screen
195+.br
196+L3: Next Screen
197+.br
198+L4: Alternative Screen (Doesn't work on Swap, Memory and Battery Screen)
199+.br
200+L5: Bottom Info bar mode
201
202 .SH "AUTHOR"
203 Mike Lampard
204+.br
205+dlancer <dmdpost@gmail.com>
206 .SH "SEE ALSO"
207 .BR g15daemon (1),
208 .BR libg15 (3),
209
210=== modified file 'g15stats.c'
211--- g15stats.c 2009-08-04 13:15:38 +0000
212+++ g15stats.c 2012-06-05 18:03:18 +0000
213@@ -15,9 +15,9 @@
214 along with g15daemon; if not, write to the Free Software
215 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
216
217-(c) 2008-2009 Mike Lampard
218+(c) 2008-2010 Mike Lampard
219
220-$Revision: 520 $ - $Date: 2009-07-23 00:24:45 +0200 (Thu, 23 Jul 2009) $ $Author: czarnyckm $
221+$Revision: 538 $ - $Date: 2011-04-27 23:23:15 +0200 (Mi, 27 Apr 2011) $ $Author: czarnyckm $
222
223 This daemon listens on localhost port 15550 for client connections,
224 and arbitrates LCD display. Allows for multiple simultaneous clients.
225@@ -39,6 +39,7 @@
226 #include <libg15render.h>
227 #include <sched.h>
228 #include <sys/socket.h>
229+#include <sys/time.h>
230 #include <sys/types.h>
231 #include <sys/stat.h>
232 #include <time.h>
233@@ -62,7 +63,7 @@
234 /** Holds the mode type variable of the application running */
235 int mode[MAX_SCREENS];
236 /** Holds the sub mode type variable of the application running */
237-int submode = 0;
238+int submode = 1;
239
240 int info_cycle_timer = -1;
241
242@@ -70,10 +71,14 @@
243 int summary_rows = 4;
244
245 int have_freq = 2;
246+
247+int wait_seconds = 1;
248+
249 _Bool have_temp = 1;
250 _Bool have_fan = 1;
251 _Bool have_bat = 1;
252 _Bool have_nic = 0;
253+_Bool variable_cpu = 0;
254
255 _Bool sensor_type_temp[MAX_SENSOR];
256 _Bool sensor_type_fan[MAX_SENSOR];
257@@ -305,8 +310,7 @@
258 }
259
260 void init_cpu_count(void) {
261- // initialize cpu count once
262- if (!ncpu) {
263+ if ((variable_cpu) || (!ncpu)) {
264 const glibtop_sysinfo *cpuinfo = glibtop_get_sysinfo();
265
266 if(cpuinfo->ncpu == 0) {
267@@ -548,7 +552,7 @@
268 for (core = 0; (core < ncpu) && (core < 6); core++) {
269 sprintf(proc, "C%d ", core);
270 strcat(tmpstr,proc);
271- if (ncpu < 5) {
272+ if (ncpu < 4) {
273 strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
274 } else {
275 strcat(tmpstr, show_hertz_short(get_cpu_freq_cur(core)));
276@@ -566,6 +570,7 @@
277 time(&now);
278
279 sprintf(tmpstr,"%s",ctime(&now));
280+ tmpstr[(strlen(tmpstr) - 1)] = '\0';
281 g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
282 }
283
284@@ -627,19 +632,28 @@
285
286 if (count) {
287 int j = 0;
288- int rest;
289- int step = (int) (y2 / count);
290+ int rest, step;
291+ step = y2 / count;
292 rest = y2 - (step * count);
293 int y = cur_shift + y1;
294 int last_y;
295 for (j = 0; j < count; j++) {
296 last_y = y;
297+ if( j ) {
298+ last_y++;
299+ if (rest > 0) {
300+ if ((j+1) < count) {
301+ y++;
302+ rest--;
303+ } else {
304+ y += rest;
305+ rest = 0;
306+ }
307+ }
308+ }
309 y += step;
310- if (rest > 0) {
311- rest--;
312- y++;
313- }
314 drawBar_both(canvas, last_y + move, y + move, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max);
315+
316 }
317 drawLine_both(canvas, cur_shift + y1 + move, y + move);
318
319@@ -687,10 +701,9 @@
320 y = y2 / 2;
321
322 drawLine_both(canvas, cur_shift + y1 + move, cur_shift + y2 + move);
323+
324 drawBar_both(canvas, cur_shift + y1 + move, cur_shift + y + move, net_cur_in + 1, net_max_in, net_max_in - net_cur_in, net_max_in);
325-
326-
327- drawBar_both(canvas, cur_shift + y + move, cur_shift + y2 + move, net_cur_out + 1, net_max_out, net_max_out - net_cur_out, net_max_out);
328+ drawBar_both(canvas, cur_shift + y + move + 1, cur_shift + y2 + move, net_cur_out + 1, net_max_out, net_max_out - net_cur_out, net_max_out);
329
330 if (net_cur_in > net_cur_out) {
331 sprintf(tmpstr, "IN %s", show_bytes_short((int) net_cur_in));
332@@ -746,8 +759,8 @@
333 /* draw cpu screen. if drawgraph = 0 then no graph is drawn */
334 void draw_cpu_screen_unicore_logic(g15canvas *canvas, glibtop_cpu cpu, char *tmpstr, int drawgraph, int printlabels, int cpuandmemory) {
335 int total,user,nice,sys,idle;
336- int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
337- static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait,last_irq;
338+ static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait,
339+ last_irq,b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
340
341 g15r_clearScreen (canvas, G15_COLOR_WHITE);
342
343@@ -757,21 +770,26 @@
344 sys = ((unsigned long) cpu.sys) ? ((double) cpu.sys) : 1.0;
345 idle = ((unsigned long) cpu.idle) ? ((double) cpu.idle) : 1.0;
346
347- b_total = total - last_total;
348- b_user = user - last_user;
349- b_nice = nice - last_nice;
350- b_sys = sys - last_sys;
351- b_idle = idle - last_idle;
352- b_irq = cpu.irq - last_irq;
353- b_iowait= cpu.iowait - last_iowait;
354+ if ((total - last_total) > 0) {
355+ b_total = total - last_total;
356+ b_user = user - last_user;
357+ b_nice = nice - last_nice;
358+ b_sys = sys - last_sys;
359+ b_idle = idle - last_idle;
360+ b_irq = cpu.irq - last_irq;
361+ b_iowait= cpu.iowait - last_iowait;
362
363- last_total = total;
364- last_user = user;
365- last_nice = nice;
366- last_sys = sys;
367- last_idle = idle;
368- last_irq = cpu.irq;
369- last_iowait = cpu.iowait;
370+ last_total = total;
371+ last_user = user;
372+ last_nice = nice;
373+ last_sys = sys;
374+ last_idle = idle;
375+ last_irq = cpu.irq;
376+ last_iowait = cpu.iowait;
377+ } else if (b_total == 0) {
378+ b_total = 100;
379+ b_idle = 100;
380+ }
381
382 if(printlabels) {
383 sprintf(tmpstr,"Usr %2.f%%",((float)b_user/(float)b_total)*100);
384@@ -814,10 +832,12 @@
385 int divider = 0;
386
387 int total,user,nice,sys,idle;
388- int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
389 int sub_val;
390 static int last_total[GLIBTOP_NCPU],last_user[GLIBTOP_NCPU],last_nice[GLIBTOP_NCPU],
391- last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],last_irq[GLIBTOP_NCPU];
392+ last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],
393+ last_irq[GLIBTOP_NCPU],b_total[GLIBTOP_NCPU],b_user[GLIBTOP_NCPU],
394+ b_nice[GLIBTOP_NCPU],b_sys[GLIBTOP_NCPU],b_idle[GLIBTOP_NCPU],
395+ b_irq[GLIBTOP_NCPU],b_iowait[GLIBTOP_NCPU];
396
397 init_cpu_count();
398
399@@ -873,12 +893,15 @@
400 switch (ncpu) {
401 case 1 :
402 case 2 :
403- case 3 :
404 case 5 :
405 case 7 :
406 move = 1;
407 height = 6;
408 break;
409+ case 3 :
410+ case 6 :
411+ height = 6;
412+ break;
413 default :
414 height = 8;
415 break;
416@@ -891,9 +914,9 @@
417 move = 1;
418 break;
419 }
420- height = 8;
421- }
422-
423+ height = 8;
424+ }
425+
426 shift = height + 1;
427 shift2 = (2 * shift);
428 break;
429@@ -917,21 +940,26 @@
430 sys = ((unsigned long) cpu.xcpu_sys[core]) ? ((double) cpu.xcpu_sys[core]) : 1.0;
431 idle = ((unsigned long) cpu.xcpu_idle[core]) ? ((double) cpu.xcpu_idle[core]) : 1.0;
432
433- b_total = total - last_total[core];
434- b_user = user - last_user[core];
435- b_nice = nice - last_nice[core];
436- b_sys = sys - last_sys[core];
437- b_idle = idle - last_idle[core];
438- b_irq = cpu.xcpu_irq[core] - last_irq[core];
439- b_iowait = cpu.xcpu_iowait[core] - last_iowait[core];
440+ if ((total - last_total[core]) > 0) {
441+ b_total[core] = total - last_total[core];
442+ b_user[core] = user - last_user[core];
443+ b_nice[core] = nice - last_nice[core];
444+ b_sys[core] = sys - last_sys[core];
445+ b_idle[core] = idle - last_idle[core];
446+ b_irq[core] = cpu.xcpu_irq[core] - last_irq[core];
447+ b_iowait[core] = cpu.xcpu_iowait[core] - last_iowait[core];
448
449- last_total[core] = total;
450- last_user[core] = user;
451- last_nice[core] = nice;
452- last_sys[core] = sys;
453- last_idle[core] = idle;
454- last_irq[core] = cpu.xcpu_irq[core];
455- last_iowait[core] = cpu.xcpu_iowait[core];
456+ last_total[core] = total;
457+ last_user[core] = user;
458+ last_nice[core] = nice;
459+ last_sys[core] = sys;
460+ last_idle[core] = idle;
461+ last_irq[core] = cpu.xcpu_irq[core];
462+ last_iowait[core] = cpu.xcpu_iowait[core];
463+ } else if (b_total[core] == 0){
464+ b_total[core] = 100;
465+ b_idle[core] = 100;
466+ }
467
468 y1 = (core * height) + (core * spacer);
469 y2 = y1 + height - 1;
470@@ -941,7 +969,7 @@
471 if ((mode[SCREEN_FREQ]) && (have_freq)) {
472 freq_cur = get_cpu_freq_cur(core);
473 if (core < 6) {
474- result = ((float) (b_total - b_idle) / (float) b_total)*100;
475+ result = ((float) (b_total[core] - b_idle[core]) / (float) b_total[core])*100;
476 if (result < 100.0) {
477 sprintf(tmpstr, "%2.f%% %s", result, show_hertz_short(freq_cur));
478 } else {
479@@ -960,9 +988,9 @@
480 if (core < 6) {
481 if (have_freq) {
482 freq_cur = get_cpu_freq_cur(core);
483- sprintf(tmpstr, "%s%3.f%%", show_hertz_short(freq_cur), ((float) (b_total - b_idle) / (float) b_total)*100);
484+ sprintf(tmpstr, "%s%3.f%%", show_hertz_short(freq_cur), ((float) (b_total[core] - b_idle[core]) / (float) b_total[core])*100);
485 } else {
486- sprintf(tmpstr, "CPU%.f%3.f%%", (float) core, ((float) (b_total - b_idle) / (float) b_total)*100);
487+ sprintf(tmpstr, "CPU%.f%3.f%%", (float) core, ((float) (b_total[core] - b_idle[core]) / (float) b_total[core])*100);
488 }
489 if (ncpu < 5) {
490 g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, y1 + 1);
491@@ -970,8 +998,8 @@
492 g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, core * 6);
493 }
494 }
495- current_value = b_total - b_idle;
496- drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total);
497+ current_value = b_total[core] - b_idle[core];
498+ drawBar_both(canvas, y1, y2, current_value, b_total[core], b_total[core] - current_value, b_total[core]);
499 y1 = 0;
500 }
501 break;
502@@ -979,29 +1007,29 @@
503 if (mode[SCREEN_CPU]) {
504 divider = 9 / ncpu;
505 sub_val = divider * core;
506- g15r_drawBar(canvas, BAR_START, sub_val, BAR_END, divider + sub_val, G15_COLOR_BLACK, b_user + 1, b_total, 4);
507- g15r_drawBar(canvas, BAR_START, shift + sub_val, BAR_END, shift + divider + sub_val, G15_COLOR_BLACK, b_sys + 1, b_total, 4);
508+ g15r_drawBar(canvas, BAR_START, sub_val, BAR_END, divider + sub_val, G15_COLOR_BLACK, b_user[core] + 1, b_total[core], 4);
509+ g15r_drawBar(canvas, BAR_START, shift + sub_val, BAR_END, shift + divider + sub_val, G15_COLOR_BLACK, b_sys[core] + 1, b_total[core], 4);
510 y1 = 0;
511 y2 = shift2 + divider + sub_val;
512- g15r_drawBar(canvas, BAR_START, shift2 + sub_val, BAR_END, y2, G15_COLOR_BLACK, b_nice + 1, b_total, 4);
513+ g15r_drawBar(canvas, BAR_START, shift2 + sub_val, BAR_END, y2, G15_COLOR_BLACK, b_nice[core] + 1, b_total[core], 4);
514
515 divider = y2 / ncpu;
516- drawBar_reversed(canvas, BAR_START, sub_val, BAR_END, y2, G15_COLOR_BLACK, b_idle + 1, b_total, 5);
517+ drawBar_reversed(canvas, BAR_START, sub_val, BAR_END, y2, G15_COLOR_BLACK, b_idle[core] + 1, b_total[core], 5);
518 } else {
519- current_value = b_total - b_idle;
520- drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total);
521+ current_value = b_total[core] - b_idle[core];
522+ drawBar_both(canvas, y1, y2, current_value, b_total[core], b_total[core] - current_value, b_total[core]);
523
524- drawBar_both(canvas, shift + y1, shift + y2, b_sys + 1, b_total, b_total - b_sys, b_total);
525+ drawBar_both(canvas, shift + y1, shift + y2, b_sys[core] + 1, b_total[core], b_total[core] - b_sys[core], b_total[core]);
526
527 y2 += shift2;
528- drawBar_both(canvas, shift2 + y1, y2, b_nice + 1, b_total, b_total - b_nice, b_total);
529+ drawBar_both(canvas, shift2 + y1, y2, b_nice[core] + 1, b_total[core], b_total[core] - b_nice[core], b_total[core]);
530
531 y1 = 0;
532 }
533 break;
534 case SCREEN_SUMMARY:
535- current_value = b_total - b_idle;
536- drawBar_both(canvas, y1 + move, y2 + move, current_value, b_total, b_total - current_value, b_total);
537+ current_value = b_total[core] - b_idle[core];
538+ drawBar_both(canvas, y1 + move, y2 + move, current_value, b_total[core], b_total[core] - current_value, b_total[core]);
539
540 if (have_freq) {
541 freq_cur = get_cpu_freq_cur(core);
542@@ -1266,36 +1294,56 @@
543
544 int j = 0;
545
546- int shift;
547- shift = 32 / count;
548-
549- if (count) {
550- if (all) {
551- g15r_clearScreen(canvas, G15_COLOR_WHITE);
552- print_vert_label(canvas, vert_label);
553-
554- for (j = 0; j < count; j++) {
555- register int bar_top = (j * shift) + 1 + j;
556- register int bar_bottom = ((j + 1)*shift) + j;
557- sprintf(tmpstr, format_main, j + 1, probes[j].cur);
558- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + 1);
559- drawBar_both(canvas, bar_top, bar_bottom, probes[j].cur + 1, tot_max, tot_max - probes[j].cur, tot_max);
560- }
561- drawLine_both(canvas, 1, ((j*shift) + j-1));
562- }
563-
564- if ((!all) || (info_cycle == screen_type)) {
565- char extension[16];
566- tmpstr[0] = '\0';
567- for (j = 0; j < count; j++) {
568- sprintf(extension, format_bottom, j + 1, probes[j].cur);
569- if (j) {
570- strcat(tmpstr, "| ");
571- }
572- strcat(tmpstr, extension);
573- }
574- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW);
575- }
576+ if (all) {
577+ int shift;
578+ int info_shift;
579+
580+ shift = BAR_BOTTOM / count;
581+
582+ switch (count) {
583+ case 1:
584+ info_shift = 14;
585+ shift = 33;
586+ break;
587+ case 2:
588+ info_shift = 5;
589+ break;
590+ case 3:
591+ info_shift = 2;
592+ shift = 10;
593+ break;
594+ default:
595+ info_shift = 1;
596+ break;
597+ }
598+
599+ g15r_clearScreen(canvas, G15_COLOR_WHITE);
600+ print_vert_label(canvas, vert_label);
601+
602+ int bar_top, bar_bottom;
603+ bar_bottom = BAR_BOTTOM;
604+ for (j = 0; j < count; j++) {
605+ bar_top = (j * shift) + 1 + j;
606+ bar_bottom = ((j + 1)*shift) + j;
607+
608+ sprintf(tmpstr, format_main, j + 1, probes[j].cur);
609+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + info_shift);
610+ drawBar_both(canvas, bar_top, bar_bottom, probes[j].cur + 1, tot_max, tot_max - probes[j].cur, tot_max);
611+ }
612+ drawLine_both(canvas, 1, bar_bottom);
613+ }
614+
615+ if ((!all) || (info_cycle == screen_type)) {
616+ char extension[16];
617+ tmpstr[0] = '\0';
618+ for (j = 0; j < count; j++) {
619+ sprintf(extension, format_bottom, j + 1, probes[j].cur);
620+ if (j) {
621+ strcat(tmpstr, "| ");
622+ }
623+ strcat(tmpstr, extension);
624+ }
625+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW);
626 }
627 }
628
629@@ -1615,18 +1663,24 @@
630 /* wait for a max of <seconds> seconds.. if condition &wake_now is received leave immediately */
631 void g15stats_wait(int seconds) {
632 pthread_mutex_t dummy_mutex;
633+ pthread_mutexattr_t mta;
634 struct timespec timeout;
635 /* Create a dummy mutex which doesn't unlock for sure while waiting. */
636- pthread_mutex_init(&dummy_mutex, NULL);
637+ pthread_mutexattr_init(&mta);
638+
639+ pthread_mutex_init(&dummy_mutex, &mta);
640 pthread_mutex_lock(&dummy_mutex);
641
642- time(&timeout.tv_sec);
643+ if (clock_gettime(CLOCK_REALTIME, &timeout) != 0) {
644+ perror("clock_gettime");
645+ }
646+
647 timeout.tv_sec += seconds;
648- timeout.tv_nsec = 0L;
649
650 pthread_cond_timedwait(&wake_now, &dummy_mutex, &timeout);
651 pthread_mutex_unlock(&dummy_mutex);
652 pthread_mutex_destroy(&dummy_mutex);
653+ pthread_mutexattr_destroy(&mta);
654 }
655
656 int main(int argc, char *argv[]){
657@@ -1656,8 +1710,16 @@
658 have_freq=0;
659 }
660
661+ if(0==strncmp(argv[i],"-rc",3)||0==strncmp(argv[i],"--info-rotate",13)) {
662+ submode = 0;
663+ }
664+
665+ if(0==strncmp(argv[i],"-vc",3)||0==strncmp(argv[i],"--variable-cpu",14)) {
666+ variable_cpu = 1;
667+ }
668+
669 if(0==strncmp(argv[i],"-h",2)||0==strncmp(argv[i],"--help",6)) {
670- printf("%s %s - (c) 2008-2009 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME,VERSION);
671+ printf("%s %s - (c) 2008-2010 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME,VERSION);
672 printf("Usage: %s [Options]\n", PACKAGE_NAME);
673 printf("Options:\n");
674 printf("--daemon (-d) run in background\n");
675@@ -1673,6 +1735,9 @@
676 "\t[id] should point to sysfs path /sys/class/hwmon/hwmon[id]/device/fan1_input\n");
677 printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n"
678 "\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
679+ printf("--info-rotate (-ir) enable the bottom info bar content rotate.\n");
680+ printf("--variable-cpu (-vc) the cpu cores will be calculated every time (for systems with the cpu hotplug).\n");
681+ printf("--refresh [seconds] (-r) set the refresh interval to [seconds] The seconds must be between 1 and 300. ie -r 15\n");
682 printf("--disable-freq (-df) disable monitoring CPUs frequencies.\n\n");
683 return 0;
684 }
685@@ -1709,6 +1774,16 @@
686 }
687 }
688 }
689+
690+ if(0==strncmp(argv[i],"-r",2)||0==strncmp(argv[i],"--refresh",9)) {
691+ if(argv[i+1]!=NULL) {
692+ i++;
693+ wait_seconds = atoi(argv[i]);
694+ if ((wait_seconds < 1) || (wait_seconds > MAX_INTERVAL)) {
695+ wait_seconds = 1;
696+ }
697+ }
698+ }
699 }
700 if((g15screen_fd = new_g15_screen(G15_G15RBUF))<0){
701 printf("Sorry, cant connect to the G15daemon\n");
702@@ -1849,7 +1924,7 @@
703 canvas->mode_xor = 0;
704
705 g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN);
706- g15stats_wait(1);
707+ g15stats_wait(wait_seconds);
708 }
709 glibtop_close();
710
711
712=== modified file 'g15stats.h'
713--- g15stats.h 2009-08-04 13:15:38 +0000
714+++ g15stats.h 2012-06-05 18:03:18 +0000
715@@ -9,6 +9,8 @@
716 #define MAX_MODE 1
717 #define MAX_SUB_MODE 1
718
719+#define MAX_INTERVAL 300
720+
721 #define PAUSE 6
722 #define RETRY_COUNT 10
723

Subscribers

People subscribed via source and target branches

to all changes: