|
From: <ane...@us...> - 2009-01-03 05:34:57
|
Revision: 464
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=464&view=rev
Author: aneurysm9
Date: 2009-01-03 05:34:51 +0000 (Sat, 03 Jan 2009)
Log Message:
-----------
Battery status monitoring courtesy of Pieter De Wit <pi...@in...>
New #defines and magic number cleanups as well
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/Makefile.am
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
Added Paths:
-----------
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/Makefile.am
===================================================================
--- trunk/g15daemon-clients/g15stats/Makefile.am 2008-07-26 23:43:34 UTC (rev 463)
+++ trunk/g15daemon-clients/g15stats/Makefile.am 2009-01-03 05:34:51 UTC (rev 464)
@@ -2,6 +2,7 @@
AM_CFLAGS = -O3 -Wall @CFLAGS@ -I$(top_builddir) -I$(top_srcdir)
METASOURCES = AUTO
bin_PROGRAMS = g15stats
+noinst_HEADERS = g15stats.h
docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
doc_DATA = README ChangeLog AUTHORS NEWS COPYING
@@ -9,6 +10,6 @@
LIBS = -lg15daemon_client -lg15render
IMCLUDES = -I
g15stats_LDFLAGS = -avoid-version
-g15stats_SOURCES = g15stats.c
+g15stats_SOURCES = g15stats.c g15stats.h
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2008-07-26 23:43:34 UTC (rev 463)
+++ trunk/g15daemon-clients/g15stats/configure.in 2009-01-03 05:34:51 UTC (rev 464)
@@ -1,7 +1,7 @@
-AC_INIT(g15stats,[1.0], [mla...@us...])
+AC_INIT(g15stats,[1.1], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.0
+VERSION=1.1
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2008-07-26 23:43:34 UTC (rev 463)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-01-03 05:34:51 UTC (rev 464)
@@ -26,7 +26,7 @@
This is a cpu and memory stats client
*/
-
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -51,10 +51,10 @@
#include <glibtop/swap.h>
#include <glibtop/loadavg.h>
#include <glibtop/uptime.h>
+#include "g15stats.h"
int g15screen_fd;
int cycle = 0;
-#define MAX_NET_HIST 107
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -156,24 +156,24 @@
glibtop_get_mem(&mem);
sprintf(tmpstr,"Usr %2.f%%",((float)mem.user/(float)mem.total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 2);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 2);
sprintf(tmpstr,"Buf %2.f%%",((float)mem.buffer/(float)mem.total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 14);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 14);
sprintf(tmpstr,"Che %2.f%%",((float)mem.cached/(float)mem.total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 26);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 26);
- g15r_drawBar(canvas,43,1,150,10,1,mem.user,mem.total,4);
- g15r_drawBar(canvas,43,12,150,21,1,mem.buffer,mem.total,4);
- g15r_drawBar(canvas,43,23,150,32,1,mem.cached,mem.total,4);
- drawBar_reversed(canvas,43,1,150,32,1,mem.free,mem.total,5);
+ g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,(mem.user/1024),(mem.total/1024),4);
+ g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,(mem.buffer/1024),(mem.total/1024),4);
+ g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,(mem.cached/1024),(mem.total/1024),4);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,(mem.free/1024),(mem.total/1024),5);
- g15r_drawLine (canvas, 40, 1, 40, 32, 1);
- g15r_drawLine (canvas, 41, 1, 41, 32, 1);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, 152, 4);
- g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, 152, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, 152, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, 152, 4);
+ g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
sprintf(tmpstr,"Memory Used %dMb | Memory Total %dMb",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
@@ -188,21 +188,21 @@
glibtop_get_swap(&swap);
- g15r_renderString (canvas, (unsigned char*)"Swap", 0, G15_TEXT_MED, 1, 9);
+ g15r_renderString (canvas, (unsigned char*)"Swap", 0, G15_TEXT_MED, TEXT_LEFT, 9);
sprintf(tmpstr,"Used %i%%",(unsigned int)(((float)swap.used/(float)swap.total)*100));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 19);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 19);
- g15r_drawBar(canvas,43,1,150,32,1,(swap.used/1024),swap.total/1024,4);
+ g15r_drawBar(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,(swap.used/1024),swap.total/1024,4);
- drawBar_reversed(canvas,43,1,150,32,1,(swap.total/1024)-(swap.used/1024),swap.total/1024,5);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,(swap.total/1024)-(swap.used/1024),swap.total/1024,5);
- g15r_drawLine (canvas, 40, 1, 40, 32, 1);
- g15r_drawLine (canvas, 41, 1, 41, 32, 1);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, 152, 4);
- g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, 152, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, 152, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, 152, 4);
+ g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
sprintf(tmpstr,"Swap Used %dMb | Swap Avail. %dMb",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
@@ -255,18 +255,18 @@
sprintf(tmpstr,"Nce %2.f%%",((float)b_nice/(float)b_total)*100);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 26);
- g15r_drawBar(canvas,43,1,150,10,1,b_user+1,b_total,4);
- g15r_drawBar(canvas,43,12,150,21,1,b_sys+1,b_total,4);
- g15r_drawBar(canvas,43,23,150,32,1,b_nice+1,b_total,4);
- drawBar_reversed(canvas,43,1,150,32,1,b_idle+1,b_total,5);
+ g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,b_user+1,b_total,4);
+ g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,b_sys+1,b_total,4);
+ g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,b_nice+1,b_total,4);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,b_idle+1,b_total,5);
- g15r_drawLine (canvas, 40, 1, 40, 32, 1);
- g15r_drawLine (canvas, 41, 1, 41, 32, 1);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
- g15r_renderString (canvas, (unsigned char*)"I", 0, G15_TEXT_MED, 152, 4);
- g15r_renderString (canvas, (unsigned char*)"d", 1, G15_TEXT_MED, 152, 4);
- g15r_renderString (canvas, (unsigned char*)"l", 2, G15_TEXT_MED, 152, 4);
- g15r_renderString (canvas, (unsigned char*)"e", 3, G15_TEXT_MED, 152, 4);
+ g15r_renderString (canvas, (unsigned char*)"I", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"d", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"l", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"e", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
// sprintf(tmpstr,"IOWait %u, Interrupts/s %u",b_iowait, b_irq);
float minutes = uptime.uptime/60;
@@ -316,15 +316,15 @@
for(i=net_rr_index+1;i<MAX_NET_HIST;i++) {
diff = (float) net_max_in / (float) net_hist[i][0];
height = 16-(16/diff);
- g15r_setPixel(canvas,x,height,1);
- g15r_drawLine(canvas,x,height,x-1,last,1);
+ g15r_setPixel(canvas,x,height,G15_COLOR_BLACK);
+ g15r_drawLine(canvas,x,height,x-1,last,G15_COLOR_BLACK);
last=height;
x++;
}
for(i=0;i<net_rr_index;i++) {
diff = (float) net_max_in / (float) net_hist[i][0];
height = 16-(16 / diff);
- g15r_drawLine(canvas,x,height,x-1,last,1);
+ g15r_drawLine(canvas,x,height,x-1,last,G15_COLOR_BLACK);
last=height;
x++;
}
@@ -333,21 +333,21 @@
for(i=net_rr_index+1;i<MAX_NET_HIST;i++) {
diff = (float) net_max_out / (float) net_hist[i][1];
height = 34-(16/diff);
- g15r_setPixel(canvas,x,height,1);
- g15r_drawLine(canvas,x,height,x-1,last,1);
+ g15r_setPixel(canvas,x,height,G15_COLOR_BLACK);
+ g15r_drawLine(canvas,x,height,x-1,last,G15_COLOR_BLACK);
last=height;
x++;
}
for(i=0;i<net_rr_index;i++) {
diff = (float) net_max_out / (float) net_hist[i][1];
height = 34-(16 / diff);
- g15r_drawLine(canvas,x,height,x-1,last,1);
+ g15r_drawLine(canvas,x,height,x-1,last,G15_COLOR_BLACK);
last=height;
x++;
}
- g15r_drawLine (canvas, 52, 0, 52, 34, 1);
- g15r_drawLine (canvas, 53, 0, 53, 34, 1);
- g15r_drawLine (canvas, 54, 0, 54, 34, 1);
+ g15r_drawLine (canvas, 52, 0, 52, 34, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, 53, 0, 53, 34, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, 54, 0, 54, 34, G15_COLOR_BLACK);
sprintf(tmpstr,"IN %s",show_bytes(netload.bytes_in));
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 2);
@@ -365,6 +365,147 @@
}
+void draw_bat_screen(g15canvas *canvas) {
+
+ g15_stats_bat_info bats[NUM_BATS];
+ long tot_max_charge = 0;
+ long tot_cur_charge = 0;
+
+ FILE *fd_state;
+ FILE *fd_info;
+ char line [MAX_LINES];
+ char value [MAX_LINES];
+ char tmpstr [MAX_LINES];
+
+ int i = 0;
+ for (i = 0; i < NUM_BATS; i++)
+ {
+ char filename[30];
+
+ // Initialize battery state
+ bats[i].max_charge = 0;
+ bats[i].cur_charge = 0;
+ bats[i].status = -1;
+
+ sprintf(filename, "/proc/acpi/battery/BAT%d/state", i);
+ fd_state=fopen (filename,"r");
+ if (fd_state!=NULL)
+ {
+ while (fgets (line,MAX_LINES,fd_state)!=NULL)
+ {
+ // Parse the state file for battery info
+ if (strcasestr (line,"remaining capacity")!=0)
+ {
+ strncpy ((char *)value,((char *)line)+25,5);
+ bats[i].cur_charge=atoi (value);
+ }
+ if (strcasestr (line,"charging state")!=0)
+ {
+ if (strcasestr (line,"charged")!=0)
+ {
+ bats[i].status=0;
+ }
+ if (strcasestr (line," charging")!=0)
+ {
+ bats[i].status=1;
+ }
+ if (strcasestr (line,"discharging")!=0)
+ {
+ bats[i].status=2;
+ }
+ }
+ }
+ fclose (fd_state);
+ sprintf(filename, "/proc/acpi/battery/bat%d/info", i);
+ fd_info=fopen (filename,"r");
+
+ if (fd_info!=NULL)
+ {
+ while (fgets (line,MAX_LINES,fd_info)!=NULL)
+ {
+ // Parse the info file for battery info
+ if (strcasestr (line,"last full capacity")!=0)
+ {
+ strncpy ((char *)value,((char *)line)+25,5);
+ bats[i].max_charge=atoi (value);
+ }
+ }
+ fclose (fd_info);
+ }
+
+ tot_cur_charge += bats[i].cur_charge;
+ tot_max_charge += bats[i].max_charge;
+
+ }
+ }
+
+ g15r_clearScreen (canvas, G15_COLOR_WHITE);
+
+ g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, 155, 4);
+ g15r_renderString (canvas, (unsigned char*)"U", 1, G15_TEXT_MED, 155, 4);
+ g15r_renderString (canvas, (unsigned char*)"L", 2, G15_TEXT_MED, 155, 4);
+ g15r_renderString (canvas, (unsigned char*)"L", 3, G15_TEXT_MED, 155, 4);
+
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+
+ for (i = 0; i < NUM_BATS; i++)
+ {
+ register float charge = 0;
+ register int bar_top = (i*10) + 1 + i;
+ register int bar_bottom = ((i+1)*10) + i;
+ if (bats[i].max_charge > 0)
+ {
+ charge = ((float)bats[i].cur_charge/(float)bats[i].max_charge)*100;
+ }
+ sprintf(tmpstr,"Bt%d %2.f%%", i, charge);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (i*12) + 2);
+ g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, bats[i].cur_charge, bats[i].max_charge, 4);
+ }
+
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
+
+ float total_charge = 0;
+ if (tot_max_charge > 0)
+ {
+ total_charge = ((float)tot_cur_charge/(float)tot_max_charge)*100;
+ }
+ sprintf (tmpstr,"Total %2.f%% | ", total_charge);
+
+ for (i = 0; i < NUM_BATS; i++)
+ {
+ char extension[11];
+ switch (bats[i].status)
+ {
+ case -1:
+ {
+ sprintf(extension, "Bt%d - | ", i);
+ break;
+ }
+ case 0:
+ {
+ sprintf(extension, "Bt%d F | ", i);
+ break;
+ }
+ case 1:
+ {
+ sprintf(extension, "Bt%d C | ", i);
+ break;
+ }
+ case 2:
+ {
+ sprintf(extension, "Bt%d D | ", i);
+ break;
+ }
+ }
+
+ strcat (tmpstr, extension);
+ }
+
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
+
void keyboard_watch(void) {
unsigned int keystate;
@@ -374,17 +515,27 @@
if(keystate & G15_KEY_L1) {
}
else if(keystate & G15_KEY_L2) {
- cycle=0;
+ cycle--;
}
else if(keystate & G15_KEY_L3) {
- cycle=1;
+ cycle++;
}
else if(keystate & G15_KEY_L4) {
- cycle=2;
+ // These can now be passed to the "app" running
}
else if(keystate & G15_KEY_L5) {
- cycle=3;
+ // These can now be passed to the "app" running
}
+ if (cycle<0)
+ {
+ // Wrap around the apps
+ cycle=MAX_SCREENS;
+ }
+ if (cycle>MAX_SCREENS)
+ {
+ //Wrap around the apps
+ cycle=0;
+ }
usleep(100*900);
}
@@ -508,6 +659,9 @@
cycle=0;
}
break;
+ case 4:
+ draw_bat_screen(canvas);
+ break;
default:
printf("cycle reched %i\n",cycle);
}
Added: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h (rev 0)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-01-03 05:34:51 UTC (rev 464)
@@ -0,0 +1,17 @@
+#define TEXT_LEFT 1
+#define NUM_BATS 3
+#define MAX_SCREENS 4
+#define VL_LEFT 42
+#define BAR_START 45
+#define MAX_NET_HIST 107
+#define BAR_END 153
+#define TEXT_RIGHT 155
+#define MAX_LINES 1024
+
+typedef struct g15_stats_bat_info
+{
+ long max_charge;
+ long cur_charge;
+ long status;
+} g15_stats_bat_info;
+
Property changes on: trunk/g15daemon-clients/g15stats/g15stats.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-27 04:26:27
|
Revision: 502
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=502&view=rev
Author: mlampard
Date: 2009-04-27 04:26:18 +0000 (Mon, 27 Apr 2009)
Log Message:
-----------
g15stats: Detect bad network interface. Resolve issue causing 100% cpu usage.
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-27 04:02:26 UTC (rev 501)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-27 04:26:18 UTC (rev 502)
@@ -5,3 +5,4 @@
SVN:
- Improve response time when switching screens.
- Battery status monitoring courtesy of Pieter De Wit
+- Detect if Network interface is incorrect and disable netscreen. Resolves 100% cpu issue reported by Guy Dierx.
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-27 04:02:26 UTC (rev 501)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-27 04:26:18 UTC (rev 502)
@@ -57,6 +57,7 @@
int g15screen_fd;
int cycle = 0;
+int have_nic=0;
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -617,10 +618,19 @@
glibtop_netload netload;
static unsigned long previous_in;
static unsigned long previous_out;
+ int mac=0;
+ glibtop_get_netload(&netload,interface);
+ for(i=0;i<8;i++)
+ mac+=netload.hwaddress[i];
+ if(!mac) {
+ printf("Interface %s does not appear to exist. Net screen will be disabled.\n",interface);
+ have_nic = 0;
+ return; // interface probably doesn't exist - no mac address
+ }
+
while(1) {
int j=0, max_in=0, max_out=0;
- glibtop_get_netload(&netload,interface);
if(previous_in+previous_out==0)
goto last;
@@ -644,11 +654,13 @@
}
net_rr_index=i;
i++; if(i>MAX_NET_HIST) i=0;
-
- sleep (1);
+
last:
previous_in = netload.bytes_in;
previous_out = netload.bytes_out;
+ sleep (1);
+ glibtop_get_netload(&netload,interface);
+
}
}
@@ -677,7 +689,6 @@
int i;
int go_daemon=0;
- int have_nic=0;
unsigned char interface[128];
int multicore = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-05-27 21:52:22
|
Revision: 503
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=503&view=rev
Author: czarnyckm
Date: 2009-05-27 21:52:20 +0000 (Wed, 27 May 2009)
Log Message:
-----------
- Bottom row information rotation switched with the L5 key
- 3 additional CPU graph variants switched with the L4 key (at this moment for multi core processors only)
- New default CPU Screen (at this moment for multi core processors only)
- Display unicore graphs only on the CPU screen with the option -u (--unicore)
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-27 04:26:18 UTC (rev 502)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-27 21:52:20 UTC (rev 503)
@@ -6,3 +6,8 @@
- Improve response time when switching screens.
- Battery status monitoring courtesy of Pieter De Wit
- Detect if Network interface is incorrect and disable netscreen. Resolves 100% cpu issue reported by Guy Dierx.
+SVN:
+- Bottom row information rotation switched with the L5 key
+- 3 additional CPU graph variants switched with the L4 key (at this moment for multi core processors only)
+- New default CPU Screen (at this moment for multi core processors only)
+- Display unicore graphs only on the CPU screen with the option -u (--unicore)
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-04-27 04:26:18 UTC (rev 502)
+++ trunk/g15daemon-clients/g15stats/README 2009-05-27 21:52:20 UTC (rev 503)
@@ -23,6 +23,7 @@
-nsa Scale network graphs against highest speed recorded. The
default is to scale against the highest peak in the current graph.
-h Show help
+-u Display unicore graphs only on the CPU screen
Usage:
$> g15stats
@@ -31,6 +32,8 @@
L2: Previous Screen
L3: Next Screen
+L4: Alternative Screen (Work at this moment with the CPU Screen only)
+L5: Bottom Info bar mode
BUGS:
none currently known.
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-27 04:26:18 UTC (rev 502)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-27 21:52:20 UTC (rev 503)
@@ -15,7 +15,8 @@
along with g15daemon; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-(c) 2008-2009 Mike Lampard
+(c) 2008-2009 Mike Lampard
+(c) 2009 Piotr Czarnecki
$Revision$ - $Date$ $Author$
@@ -56,14 +57,24 @@
#include "g15stats.h"
int g15screen_fd;
+
int cycle = 0;
+/** Holds the mode type variable of the application running */
+int mode = 0;
+/** Holds the sub mode type variable of the application running */
+int submode = 0;
+
int have_nic=0;
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
+
unsigned long net_max_in=0;
unsigned long net_max_out=0;
+unsigned long previous_in;
+unsigned long previous_out;
+
_Bool net_scale_absolute=0;
pthread_cond_t wake_now = PTHREAD_COND_INITIALIZER;
@@ -74,6 +85,22 @@
return b;
}
+char * show_bytes(unsigned long bytes) {
+ static char tmpstr[128];
+ if(bytes>1024*1024) {
+ bytes = bytes / (1024*1024);
+ sprintf(tmpstr,"%liMb",bytes);
+ }
+ else if(bytes<1024*1024 && bytes > 1024) {
+ bytes = bytes / 1024;
+ sprintf(tmpstr,"%likb",bytes);
+ }
+ else if(bytes<1024) {
+ sprintf(tmpstr,"%lib",bytes);
+ }
+ return tmpstr;
+}
+
void drawBar_reversed (g15canvas * canvas, int x1, int y1, int x2, int y2, int color,
int num, int max, int type)
{
@@ -152,9 +179,66 @@
return 0;
}
+void print_sys_load_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ glibtop_loadavg loadavg;
+ glibtop_uptime uptime;
+
+ glibtop_get_loadavg(&loadavg);
+ glibtop_get_uptime(&uptime);
+
+ float minutes = uptime.uptime/60;
+ float hours = minutes/60;
+ float days = 0.0;
+
+ if(hours>24)
+ days=(int)(hours/24);
+ if(days)
+ hours=(int)hours-(days*24);
+
+ sprintf(tmpstr,"LoadAVG %.2f %.2f %.2f | Uptime %.fd%.fh",loadavg.loadavg[0],loadavg.loadavg[1],loadavg.loadavg[2],days,hours);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
+void print_mem_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ glibtop_mem mem;
+ glibtop_get_mem(&mem);
+
+ sprintf(tmpstr,"Memory Used %dMb | Memory Total %dMb",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
+void print_swap_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ glibtop_swap swap;
+ glibtop_get_swap(&swap);
+
+ sprintf(tmpstr,"Swap Used %dMb | Swap Avail. %dMb",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
+void print_net_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ sprintf(tmpstr,"Peak IN %s/s|",show_bytes(net_max_in));
+ strcat(tmpstr,"Peak OUT ");
+ strcat(tmpstr,show_bytes(net_max_out));
+ strcat(tmpstr,"/s");
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
+void print_time_info(g15canvas *canvas){
+ char tmpstr[MAX_LINES];
+ time_t now;
+ time(&now);
+
+ sprintf(tmpstr,"%s",ctime(&now));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
void draw_mem_screen(g15canvas *canvas) {
glibtop_mem mem;
- char tmpstr[1024];
+ char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -187,7 +271,7 @@
void draw_swap_screen(g15canvas *canvas) {
glibtop_swap swap;
- char tmpstr[1024];
+ char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -209,28 +293,18 @@
g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
- sprintf(tmpstr,"Swap Used %dMb | Swap Avail. %dMb",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
-
+ print_swap_info(canvas);
}
/* draw cpu screen. if drawgraph = 0 then no graph is drawn */
-void draw_cpu_screen_unicore(g15canvas *canvas, int drawgraph) {
- glibtop_cpu cpu;
- glibtop_loadavg loadavg;
- glibtop_uptime uptime;
-
+void draw_cpu_screen_unicore_logic(g15canvas *canvas, glibtop_cpu cpu, int drawgraph, int printlabels, int cpuandmemory) {
int total,user,nice,sys,idle;
int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait,last_irq;
- char tmpstr[1024];
+ char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
- glibtop_get_cpu(&cpu);
- glibtop_get_loadavg(&loadavg);
- glibtop_get_uptime(&uptime);
-
total = ((unsigned long) cpu.total) ? ((double) cpu.total) : 1.0;
user = ((unsigned long) cpu.user) ? ((double) cpu.user) : 1.0;
nice = ((unsigned long) cpu.nice) ? ((double) cpu.nice) : 1.0;
@@ -245,60 +319,65 @@
b_irq = cpu.irq - last_irq;
b_iowait= cpu.iowait - last_iowait;
- last_total = total;
- last_user = user;
- last_nice = nice;
- last_sys = sys;
- last_idle = idle;
- last_irq = cpu.irq;
+ last_total = total;
+ last_user = user;
+ last_nice = nice;
+ last_sys = sys;
+ last_idle = idle;
+ last_irq = cpu.irq;
last_iowait = cpu.iowait;
-
- sprintf(tmpstr,"Usr %2.f%%",((float)b_user/(float)b_total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 2);
- sprintf(tmpstr,"Sys %2.f%%",((float)b_sys/(float)b_total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 14);
- sprintf(tmpstr,"Nce %2.f%%",((float)b_nice/(float)b_total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 26);
+
+ if(printlabels) {
+ sprintf(tmpstr,"Usr %2.f%%",((float)b_user/(float)b_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 2);
+ sprintf(tmpstr,"Sys %2.f%%",((float)b_sys/(float)b_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 14);
+ sprintf(tmpstr,"Nce %2.f%%",((float)b_nice/(float)b_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 26);
+ }
if(drawgraph) {
g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,b_user+1,b_total,4);
g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,b_sys+1,b_total,4);
g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,b_nice+1,b_total,4);
drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,b_idle+1,b_total,5);
+
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
}
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ if (cpuandmemory) {
+ g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 3);
+ g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 3);
+ g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 3);
+ g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 3);
- g15r_renderString (canvas, (unsigned char*)"I", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"d", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"l", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"e", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
+ sprintf(tmpstr,"CPU %3.f%%",((float)(b_total-b_idle)/(float)b_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 5);
+ } else {
+ g15r_renderString (canvas, (unsigned char*)"I", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"d", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"l", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"e", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
+ }
+}
-// sprintf(tmpstr,"IOWait %u, Interrupts/s %u",b_iowait, b_irq);
- float minutes = uptime.uptime/60;
- float hours = minutes/60;
- float days = 0.0;
+void draw_cpu_screen_unicore(g15canvas *canvas, int drawgraph, int printlabels) {
+ glibtop_cpu cpu;
+ glibtop_get_cpu(&cpu);
- if(hours>24)
- days=(int)(hours/24);
- if(days)
- hours=(int)hours-(days*24);
-
- sprintf(tmpstr,"LoadAVG %.2f %.2f %.2f | Uptime %.fd%.fh",loadavg.loadavg[0],loadavg.loadavg[1],loadavg.loadavg[2],days,hours);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
-
+ draw_cpu_screen_unicore_logic(canvas, cpu, drawgraph, printlabels, 0);
}
-void draw_cpu_screen_multicore(g15canvas *canvas, int multicore) {
+void draw_cpu_screen_multicore(g15canvas *canvas, int unicore) {
glibtop_cpu cpu;
- glibtop_loadavg loadavg;
- glibtop_uptime uptime;
+ char tmpstr[MAX_LINES];
const glibtop_sysinfo *cpuinfo;
- int core,ncpu;
+ int core,ncpu,ncpumax;
int divider = 0;
- int total[16],user[16],nice[16],sys[16],idle[16];
- int b_total[16],b_user[16],b_nice[16],b_sys[16],b_idle[16],b_irq[16],b_iowait[16];
- static int last_total[16],last_user[16],last_nice[16],last_sys[16],last_idle[16],last_iowait[16],last_irq[16];
+ int total,user,nice,sys,idle;
+ int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
+ static int last_total[GLIBTOP_NCPU],last_user[GLIBTOP_NCPU],last_nice[GLIBTOP_NCPU],
+ last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],last_irq[GLIBTOP_NCPU];
cpuinfo = glibtop_get_sysinfo();
@@ -307,64 +386,160 @@
else
ncpu = cpuinfo->ncpu;
- if(ncpu==1 || multicore==0) {
- draw_cpu_screen_unicore(canvas,1);
- return;
- }else
- draw_cpu_screen_unicore(canvas,0);
+ ncpumax = ncpu;
glibtop_get_cpu(&cpu);
- glibtop_get_loadavg(&loadavg);
- glibtop_get_uptime(&uptime);
- for(core=0;core<ncpu;core++) {
- total[core] = ((unsigned long) cpu.xcpu_total[core]) ? ((double) cpu.xcpu_total[core]) : 1.0;
- user[core] = ((unsigned long) cpu.xcpu_user[core]) ? ((double) cpu.xcpu_user[core]) : 1.0;
- nice[core] = ((unsigned long) cpu.xcpu_nice[core]) ? ((double) cpu.xcpu_nice[core]) : 1.0;
- sys[core] = ((unsigned long) cpu.xcpu_sys[core]) ? ((double) cpu.xcpu_sys[core]) : 1.0;
- idle[core] = ((unsigned long) cpu.xcpu_idle[core]) ? ((double) cpu.xcpu_idle[core]) : 1.0;
- b_total[core] = total[core] - last_total[core];
- b_user[core] = user[core] - last_user[core];
- b_nice[core] = nice[core] - last_nice[core];
- b_sys[core] = sys[core] - last_sys[core];
- b_idle[core] = idle[core] - last_idle[core];
- b_irq[core] = cpu.xcpu_irq[core] - last_irq[core];
- b_iowait[core] = cpu.xcpu_iowait[core] - last_iowait[core];
+ if (ncpu==1 || unicore) {
+ draw_cpu_screen_unicore_logic(canvas, cpu, 1, 1, 0);
+ return;
+ } else if (((ncpu > 5) && (mode != MODE_CPU_SUMARY))
+ || (mode == MODE_CPU_USR_SYS_NCE_1)
+ || (mode == MODE_CPU_USR_SYS_NCE_2)) {
+ draw_cpu_screen_unicore_logic(canvas, cpu, 0, 1, 0);
+ } else if (mode != MODE_CPU_SUMARY){
+ draw_cpu_screen_unicore_logic(canvas, cpu, 0, 0, 0);
+ } else {
+ draw_cpu_screen_unicore_logic(canvas, cpu, 0, 0, 1);
+ }
- last_total[core] = total[core];
- last_user[core] = user[core];
- last_nice[core] = nice[core];
- last_sys[core] = sys[core];
- last_idle[core] = idle[core];
+ int y1=0, y2=32, currentValue, mem_used=1, mem_total=1;
+
+ int spacer = 1;
+ int height = 8;
+ if (mode) {
+ switch (mode) {
+ case MODE_CPU_TOTAL :
+ if(ncpu > 11){
+ spacer = 0;
+ }
+ height = 37;
+ break;
+ case MODE_CPU_USR_SYS_NCE_2 :
+ if(ncpu > 4){
+ spacer = 0;
+ }
+ height = 12;
+
+ //FIXME : It should be tested
+ ncpumax = height;
+ break;
+ case MODE_CPU_SUMARY :
+ if(ncpu>6){
+ spacer = 0;
+ }
+ height = 16;
+
+ //FIXME : It should be tested
+ ncpumax = height;
+ glibtop_mem mem;
+ glibtop_get_mem(&mem);
+ mem_used = ((mem.total - mem.free) / 1024);
+ mem_total = (mem.total / 1024);
+
+ sprintf(tmpstr,"MEM %3.f%%",((float)(mem_used)/(float)mem_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 24);
+ break;
+ }
+
+ if (ncpumax < ncpu) {
+ height = (height - ((ncpumax - 1) * spacer)) / (ncpumax);
+ } else {
+ height = (height - ((ncpu - 1) * spacer)) / (ncpu);
+ }
+
+ if(height < 1){
+ height = 1;
+ }
+ }
+
+ for(core=0;core<ncpu && core<ncpumax;core++) {
+ total = ((unsigned long) cpu.xcpu_total[core]) ? ((double) cpu.xcpu_total[core]) : 1.0;
+ user = ((unsigned long) cpu.xcpu_user[core]) ? ((double) cpu.xcpu_user[core]) : 1.0;
+ nice = ((unsigned long) cpu.xcpu_nice[core]) ? ((double) cpu.xcpu_nice[core]) : 1.0;
+ sys = ((unsigned long) cpu.xcpu_sys[core]) ? ((double) cpu.xcpu_sys[core]) : 1.0;
+ idle = ((unsigned long) cpu.xcpu_idle[core]) ? ((double) cpu.xcpu_idle[core]) : 1.0;
+
+ b_total = total - last_total[core];
+ b_user = user - last_user[core];
+ b_nice = nice - last_nice[core];
+ b_sys = sys - last_sys[core];
+ b_idle = idle - last_idle[core];
+ b_irq = cpu.xcpu_irq[core] - last_irq[core];
+ b_iowait = cpu.xcpu_iowait[core] - last_iowait[core];
+
+ last_total[core] = total;
+ last_user[core] = user;
+ last_nice[core] = nice;
+ last_sys[core] = sys;
+ last_idle[core] = idle;
last_irq[core] = cpu.xcpu_irq[core];
last_iowait[core] = cpu.xcpu_iowait[core];
- divider = 9/ncpu;
- g15r_drawBar(canvas,BAR_START,1+(divider*core),BAR_END,1+(divider+(divider*(core))),G15_COLOR_BLACK,b_user[core]+1,b_total[core],4);
- g15r_drawBar(canvas,BAR_START,13+(divider*(core)),BAR_END,13+(divider+(divider*(core))),G15_COLOR_BLACK,b_sys[core]+1,b_total[core],4);
- g15r_drawBar(canvas,BAR_START,24+(divider*(core)),BAR_END,24+(divider+(divider*(core))),G15_COLOR_BLACK,b_nice[core]+1,b_total[core],4);
- divider = 32/ncpu;
- drawBar_reversed(canvas,BAR_START,1+(divider*core),BAR_END,1+(divider+(divider*(core))),G15_COLOR_BLACK,b_idle[core]+1,b_total[core],5);
+ if (mode) {
+ y1 = (core * height) + (core * spacer);
+ y2 = y1 + height-1;
+ currentValue = b_total-b_idle;
+ }
+
+ switch (mode) {
+ case MODE_CPU_USR_SYS_NCE_1 :
+ divider = 9/ncpu;
+ g15r_drawBar(canvas,BAR_START,(divider*core),BAR_END,(divider+(divider*(core))),G15_COLOR_BLACK,b_user+1,b_total,4);
+ g15r_drawBar(canvas,BAR_START,12+(divider*(core)),BAR_END,12+(divider+(divider*(core))),G15_COLOR_BLACK,b_sys+1,b_total,4);
+ y1 = 0;
+ y2 = 24+(divider+(divider*(core)));
+ g15r_drawBar(canvas,BAR_START,24+(divider*(core)),BAR_END,y2,G15_COLOR_BLACK,b_nice+1,b_total,4);
+
+ divider = y2/ncpu;
+ drawBar_reversed(canvas,BAR_START,(divider*core),BAR_END,y2,G15_COLOR_BLACK,b_idle+1,b_total,5);
+ break;
+ case MODE_CPU_TOTAL :
+ if (ncpu < 6) {
+ sprintf(tmpstr,"CPU%.f%3.f%%",(float)core,((float)(b_total-b_idle)/(float)b_total)*100);
+ if (ncpu < 5) {
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, y1+1);
+ } else {
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 1, y1+1);
+ }
+ }
+
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ y1 = 0;
+ break;
+ case MODE_CPU_USR_SYS_NCE_2 :
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ g15r_drawBar(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_sys+1,b_total,4);
+ g15r_drawBar(canvas, BAR_START,24+y1,BAR_END,24+y2,G15_COLOR_BLACK,b_nice+1,b_total,4);
+
+
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ drawBar_reversed(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_total-b_sys,b_total,5);
+
+ y2 += 24;
+ drawBar_reversed(canvas, BAR_START,24+y1,BAR_END, y2,G15_COLOR_BLACK,b_total-b_nice,b_total,5);
+
+ y1 = 0;
+ break;
+ case MODE_CPU_SUMARY :
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ g15r_drawBar(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_used+1, mem_total,4);
+
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ drawBar_reversed(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_total - mem_used, mem_total,5);
+ y1 = 0;
+ break;
+ }
}
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
-}
+ g15r_drawLine (canvas, VL_LEFT, y1, VL_LEFT, y2, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, y1, VL_LEFT+1, y2, G15_COLOR_BLACK);
-char * show_bytes(unsigned long bytes) {
- static char tmpstr[128];
- if(bytes>1024*1024) {
- bytes = bytes / (1024*1024);
- sprintf(tmpstr,"%liMb",bytes);
+ if(mode == 3) {
+ g15r_drawLine (canvas, VL_LEFT, 19+y1, VL_LEFT, 19+y2, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 19+y1, VL_LEFT+1, 19+y2, G15_COLOR_BLACK);
}
- else if(bytes<1024*1024 && bytes > 1024) {
- bytes = bytes / 1024;
- sprintf(tmpstr,"%likb",bytes);
- }
- else if(bytes<1024) {
- sprintf(tmpstr,"%lib",bytes);
- }
- return tmpstr;
}
void draw_net_screen(g15canvas *canvas, char *interface) {
@@ -424,16 +599,9 @@
sprintf(tmpstr,"%s",interface);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_LARGE, 25-(strlen(tmpstr)*9)/2, 14);
-
- sprintf(tmpstr,"Peak IN %s/s|",show_bytes(net_max_in));
- strcat(tmpstr,"Peak OUT ");
- strcat(tmpstr,show_bytes(net_max_out));
- strcat(tmpstr,"/s");
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
-
}
-void draw_bat_screen(g15canvas *canvas) {
+void draw_bat_screen(g15canvas *canvas, int all) {
g15_stats_bat_info bats[NUM_BATS];
long tot_max_charge = 0;
@@ -506,33 +674,34 @@
}
}
+ if (all) {
+ g15r_clearScreen (canvas, G15_COLOR_WHITE);
- g15r_clearScreen (canvas, G15_COLOR_WHITE);
+ g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, 155, 4);
+ g15r_renderString (canvas, (unsigned char*)"U", 1, G15_TEXT_MED, 155, 4);
+ g15r_renderString (canvas, (unsigned char*)"L", 2, G15_TEXT_MED, 155, 4);
+ g15r_renderString (canvas, (unsigned char*)"L", 3, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"U", 1, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"L", 2, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"L", 3, G15_TEXT_MED, 155, 4);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ for (i = 0; i < NUM_BATS; i++)
+ {
+ register float charge = 0;
+ register int bar_top = (i*10) + 1 + i;
+ register int bar_bottom = ((i+1)*10) + i;
+ if (bats[i].max_charge > 0)
+ {
+ charge = ((float)bats[i].cur_charge/(float)bats[i].max_charge)*100;
+ }
+ sprintf(tmpstr,"Bt%d %2.f%%", i, charge);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (i*12) + 2);
+ g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, bats[i].cur_charge, bats[i].max_charge, 4);
+ }
- for (i = 0; i < NUM_BATS; i++)
- {
- register float charge = 0;
- register int bar_top = (i*10) + 1 + i;
- register int bar_bottom = ((i+1)*10) + i;
- if (bats[i].max_charge > 0)
- {
- charge = ((float)bats[i].cur_charge/(float)bats[i].max_charge)*100;
- }
- sprintf(tmpstr,"Bt%d %2.f%%", i, charge);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (i*12) + 2);
- g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, bats[i].cur_charge, bats[i].max_charge, 4);
- }
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
+ }
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
-
float total_charge = 0;
if (tot_max_charge > 0)
{
@@ -573,9 +742,58 @@
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
}
+void print_info_label(g15canvas *canvas) {
+ static int timer;
+ int my_cycle = cycle;
+ timer++;
+ if (! submode) {
+ my_cycle = -1;
+ }
+
+ switch (my_cycle){
+ case CYCLE_CPU_SCREEN :
+ print_sys_load_info(canvas);
+ break;
+ case CYCLE_MEM_SCREEN :
+ print_mem_info(canvas);
+ break;
+ case CYCLE_SWAP_SCREEN :
+ print_swap_info(canvas);
+ break;
+ case CYCLE_NET_SCREEN :
+ print_net_info(canvas);
+ break;
+ case CYCLE_BAT_SCREEN :
+ draw_bat_screen(canvas, 0);
+ break;
+ default :
+ if ((timer < PAUSE)) {
+ print_sys_load_info(canvas);
+ } else if (timer < PAUSE_2) {
+ print_mem_info(canvas);
+ } else if (timer < PAUSE_3) {
+ print_swap_info(canvas);
+ } else if (timer < PAUSE_4) {
+ draw_bat_screen(canvas, 0);
+ } else if (timer < PAUSE_5) {
+ print_time_info(canvas);
+ } else if (have_nic) {
+ print_net_info(canvas);
+ } else {
+ print_sys_load_info(canvas);
+ timer = 0;
+ }
+ break;
+ }
+ if (timer > PAUSE_5) {
+ timer=0;
+ }
+}
+
void keyboard_watch(void) {
unsigned int keystate;
+ int change = 0;
while(1) {
recv(g15screen_fd,&keystate,4,0);
@@ -584,17 +802,19 @@
}
else if(keystate & G15_KEY_L2) {
cycle--;
- pthread_cond_broadcast(&wake_now);
+ change++;
}
else if(keystate & G15_KEY_L3) {
cycle++;
- pthread_cond_broadcast(&wake_now);
+ change++;
}
else if(keystate & G15_KEY_L4) {
- // These can now be passed to the "app" running
+ mode++;
+ change++;
}
else if(keystate & G15_KEY_L5) {
- // These can now be passed to the "app" running
+ submode++;
+ change++;
}
if (cycle<0)
{
@@ -606,6 +826,22 @@
//Wrap around the apps
cycle=0;
}
+
+ if (mode>MAX_MODE)
+ {
+ mode=0;
+ }
+
+ if (submode>MAX_SUB_MODE)
+ {
+ submode=0;
+ }
+
+ if (change)
+ {
+ pthread_cond_broadcast(&wake_now);
+ change = 0;
+ }
usleep(100*900);
}
@@ -616,8 +852,6 @@
char *interface = (char*)iface;
int i=0;
glibtop_netload netload;
- static unsigned long previous_in;
- static unsigned long previous_out;
int mac=0;
glibtop_get_netload(&netload,interface);
@@ -690,14 +924,16 @@
int i;
int go_daemon=0;
unsigned char interface[128];
- int multicore = 0;
+ int unicore = 0;
+ // Set the default CPU Screen mode to mem plus cpu
+ mode = MODE_CPU_SUMARY;
for (i=0;i<argc;i++) {
if(0==strncmp(argv[i],"-d",2)||0==strncmp(argv[i],"--daemon",8)) {
go_daemon=1;
}
- if(0==strncmp(argv[i],"-m",2)||0==strncmp(argv[i],"--multicore",11)) {
- multicore=1;
+ if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",11)) {
+ unicore=1;
}
if(0==strncmp(argv[i],"-nsa",4)||0==strncmp(argv[i],"--net-scale-absolute",20)) {
net_scale_absolute=1;
@@ -707,7 +943,7 @@
printf("%s (c) 2008 Mike Lampard\n",PACKAGE_NAME);
printf("\nOptions:\n");
printf("--daemon (-d) run in background\n");
- printf("--multicore (-m) display graphs for each core on the CPU screen\n");
+ printf("--unicore (-u) display unicore graphs only on the CPU screen\n");
printf("--help (-h) this help text.\n");
printf("--interface [interface] (-i) monitor network interface [interface] ie -i eth0\n");
printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
@@ -744,23 +980,27 @@
while(1) {
switch(cycle) {
- case 0:
- draw_cpu_screen_multicore(canvas,multicore);
+ case CYCLE_CPU_SCREEN:
+ draw_cpu_screen_multicore(canvas,unicore);
+ print_info_label(canvas);
break;
- case 1:
+ case CYCLE_MEM_SCREEN:
draw_mem_screen(canvas);
+ print_info_label(canvas);
...
[truncated message content] |
|
From: <cza...@us...> - 2009-05-27 22:12:28
|
Revision: 504
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=504&view=rev
Author: czarnyckm
Date: 2009-05-27 22:12:03 +0000 (Wed, 27 May 2009)
Log Message:
-----------
fixed --unicore parameter length
clean up
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-27 21:52:20 UTC (rev 503)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-27 22:12:03 UTC (rev 504)
@@ -6,7 +6,7 @@
- Improve response time when switching screens.
- Battery status monitoring courtesy of Pieter De Wit
- Detect if Network interface is incorrect and disable netscreen. Resolves 100% cpu issue reported by Guy Dierx.
-SVN:
+SVN 504:
- Bottom row information rotation switched with the L5 key
- 3 additional CPU graph variants switched with the L4 key (at this moment for multi core processors only)
- New default CPU Screen (at this moment for multi core processors only)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-27 21:52:20 UTC (rev 503)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-27 22:12:03 UTC (rev 504)
@@ -421,7 +421,6 @@
}
height = 12;
- //FIXME : It should be tested
ncpumax = height;
break;
case MODE_CPU_SUMARY :
@@ -430,7 +429,6 @@
}
height = 16;
- //FIXME : It should be tested
ncpumax = height;
glibtop_mem mem;
glibtop_get_mem(&mem);
@@ -932,7 +930,7 @@
if(0==strncmp(argv[i],"-d",2)||0==strncmp(argv[i],"--daemon",8)) {
go_daemon=1;
}
- if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",11)) {
+ if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",8)) {
unicore=1;
}
if(0==strncmp(argv[i],"-nsa",4)||0==strncmp(argv[i],"--net-scale-absolute",20)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-05-28 23:04:42
|
Revision: 505
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=505&view=rev
Author: czarnyckm
Date: 2009-05-28 23:04:27 +0000 (Thu, 28 May 2009)
Log Message:
-----------
- Bugfix: Render bottom line on the Memory Screen once
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-27 22:12:03 UTC (rev 504)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-28 23:04:27 UTC (rev 505)
@@ -10,4 +10,6 @@
- Bottom row information rotation switched with the L5 key
- 3 additional CPU graph variants switched with the L4 key (at this moment for multi core processors only)
- New default CPU Screen (at this moment for multi core processors only)
-- Display unicore graphs only on the CPU screen with the option -u (--unicore)
\ No newline at end of file
+- Display unicore graphs only on the CPU screen with the option -u (--unicore)
+SVN 505:
+- Bugfix: Render bottom line on the Memory Screen once
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-27 22:12:03 UTC (rev 504)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-28 23:04:27 UTC (rev 505)
@@ -240,21 +240,27 @@
glibtop_mem mem;
char tmpstr[MAX_LINES];
+ glibtop_get_mem(&mem);
+
+ int mem_total = mem.total / 1024;
+ int mem_free = mem.free / 1024;
+ int mem_user = mem.user / 1024;
+ int mem_buffer = mem.buffer / 1024;
+ int mem_cached = mem.cached / 1024;
+
g15r_clearScreen (canvas, G15_COLOR_WHITE);
- glibtop_get_mem(&mem);
-
- sprintf(tmpstr,"Usr %2.f%%",((float)mem.user/(float)mem.total)*100);
+ sprintf(tmpstr,"Usr %2.f%%",((float)mem_user/(float)mem_total)*100);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 2);
- sprintf(tmpstr,"Buf %2.f%%",((float)mem.buffer/(float)mem.total)*100);
+ sprintf(tmpstr,"Buf %2.f%%",((float)mem_buffer/(float)mem_total)*100);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 14);
- sprintf(tmpstr,"Che %2.f%%",((float)mem.cached/(float)mem.total)*100);
+ sprintf(tmpstr,"Che %2.f%%",((float)mem_cached/(float)mem_total)*100);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 26);
- g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,(mem.user/1024),(mem.total/1024),4);
- g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,(mem.buffer/1024),(mem.total/1024),4);
- g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,(mem.cached/1024),(mem.total/1024),4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,(mem.free/1024),(mem.total/1024),5);
+ g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,mem_user,mem_total,4);
+ g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,mem_buffer,mem_total,4);
+ g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,mem_cached,mem_total,4);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,mem_free,mem_total,5);
g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
@@ -263,10 +269,6 @@
g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
-
- sprintf(tmpstr,"Memory Used %dMb | Memory Total %dMb",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
-
}
void draw_swap_screen(g15canvas *canvas) {
@@ -277,13 +279,16 @@
glibtop_get_swap(&swap);
+ int swap_used = swap.used / 1024;
+ int swap_total = swap.total / 1024;
+
g15r_renderString (canvas, (unsigned char*)"Swap", 0, G15_TEXT_MED, TEXT_LEFT, 9);
- sprintf(tmpstr,"Used %i%%",(unsigned int)(((float)swap.used/(float)swap.total)*100));
+ sprintf(tmpstr,"Used %i%%",(unsigned int)(((float)swap_used/(float)swap_total)*100));
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 19);
- g15r_drawBar(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,(swap.used/1024),swap.total/1024,4);
+ g15r_drawBar(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,swap_used,swap_total,4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,(swap.total/1024)-(swap.used/1024),swap.total/1024,5);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,swap_total-swap_used,swap_total,5);
g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
@@ -292,8 +297,6 @@
g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
-
- print_swap_info(canvas);
}
/* draw cpu screen. if drawgraph = 0 then no graph is drawn */
@@ -432,8 +435,8 @@
ncpumax = height;
glibtop_mem mem;
glibtop_get_mem(&mem);
- mem_used = ((mem.total - mem.free) / 1024);
mem_total = (mem.total / 1024);
+ mem_used = mem_total - (mem.free / 1024);
sprintf(tmpstr,"MEM %3.f%%",((float)(mem_used)/(float)mem_total)*100);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 24);
@@ -446,12 +449,12 @@
height = (height - ((ncpu - 1) * spacer)) / (ncpu);
}
- if(height < 1){
+ if (height < 1) {
height = 1;
}
}
- for(core=0;core<ncpu && core<ncpumax;core++) {
+ for(core = 0; ((core < ncpu) && (core < ncpumax)); core++) {
total = ((unsigned long) cpu.xcpu_total[core]) ? ((double) cpu.xcpu_total[core]) : 1.0;
user = ((unsigned long) cpu.xcpu_user[core]) ? ((double) cpu.xcpu_user[core]) : 1.0;
nice = ((unsigned long) cpu.xcpu_nice[core]) ? ((double) cpu.xcpu_nice[core]) : 1.0;
@@ -476,8 +479,8 @@
if (mode) {
y1 = (core * height) + (core * spacer);
- y2 = y1 + height-1;
- currentValue = b_total-b_idle;
+ y2 = y1 + height - 1;
+ currentValue = b_total - b_idle;
}
switch (mode) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-06-06 23:12:27
|
Revision: 509
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=509&view=rev
Author: czarnyckm
Date: 2009-06-06 23:12:22 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
- Temperature sensors depends on the lmsensors sysfs filesystem
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/AUTHORS
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/AUTHORS
===================================================================
--- trunk/g15daemon-clients/g15stats/AUTHORS 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/AUTHORS 2009-06-06 23:12:22 UTC (rev 509)
@@ -1,4 +1,6 @@
Mike Lampard <mla...@us...>
Antonio Bartolini <rob...@gm...>
-- patch for relative scaling of net graph.
\ No newline at end of file
+- patch for relative scaling of net graph.
+
+Piotr Czarnecki <cza...@us...>
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-06 23:12:22 UTC (rev 509)
@@ -12,4 +12,6 @@
- New default CPU Screen (at this moment for multi core processors only)
- Display unicore graphs only on the CPU screen with the option -u (--unicore)
SVN 505:
-- Bugfix: Render bottom line on the Memory Screen once
\ No newline at end of file
+- Bugfix: Render bottom line on the Memory Screen once
+SVN 509:
+- Temperature sensors depends on the lmsensors sysfs filesystem
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/README 2009-06-06 23:12:22 UTC (rev 509)
@@ -24,6 +24,9 @@
default is to scale against the highest peak in the current graph.
-h Show help
-u Display unicore graphs only on the CPU screen
+-s device Monitor temperature sensors device (ie -s it87.656)
+ device should point to sysfs path /sys/devices/platform/[device]/temp1_input
+ depends on the lmsensors
Usage:
$> g15stats
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-06 23:12:22 UTC (rev 509)
@@ -66,6 +66,9 @@
int have_nic=0;
+int have_sensor=0;
+unsigned char sensor[128];
+
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -743,6 +746,100 @@
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
}
+void draw_temp_screen(g15canvas *canvas, char *sensor, int all) {
+
+ g15_stats_temp_info temps[NUM_TEMP];
+ long tot_max_temp = 1;
+
+ FILE *fd_input;
+ FILE *fd_max;
+ char line [MAX_LINES];
+ char tmpstr [MAX_LINES];
+
+ int i = 0;
+ int j = 0;
+ for (i = 0; i < NUM_TEMP; i++)
+ {
+ char filename[128];
+
+ // Initialize battery state
+ temps[i].max_temp = 1;
+ temps[i].cur_temp = 1;
+
+ /* /sys/devices/platform/it87.656/temp1_input */
+ sprintf(filename, "/sys/devices/platform/%s/temp%d_input",sensor, i+1);
+ fd_input=fopen (filename,"r");
+ if (fd_input!=NULL)
+ {
+ if (fgets (line,MAX_LINES,fd_input)!=NULL)
+ {
+ temps[i].cur_temp=atoi (line) / 1000;
+ }
+ fclose (fd_input);
+ } else {
+ break;
+ }
+
+ sprintf(filename, "/sys/devices/platform/%s/temp%d_max",sensor, i+1);
+ fd_max=fopen (filename,"r");
+ if (fd_max!=NULL)
+ {
+ if (fgets (line,MAX_LINES,fd_max)!=NULL)
+ {
+ temps[i].max_temp=atoi (line) / 1000;
+ }
+ fclose (fd_max);
+ }
+
+ if(tot_max_temp < temps[i].max_temp) {
+ tot_max_temp = temps[i].max_temp;
+ }
+
+ }
+ if (i == 0) {
+ have_sensor = 0;
+ }
+ if((i+1) >= NUM_TEMP) {
+ i = NUM_TEMP;
+ } else {
+ i++;
+ }
+
+ if (all) {
+ g15r_clearScreen (canvas, G15_COLOR_WHITE);
+
+ g15r_renderString (canvas, (unsigned char*)"M", 0, G15_TEXT_MED, 155, 3);
+ g15r_renderString (canvas, (unsigned char*)"A", 1, G15_TEXT_MED, 155, 7);
+ g15r_renderString (canvas, (unsigned char*)"X", 2, G15_TEXT_MED, 155, 11);
+
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+
+ for (j = 0; j < i; j++) {
+ register int bar_top = (j*10) + 1 + j;
+ register int bar_bottom = ((j+1)*10) + j;
+
+ sprintf(tmpstr,"T-%d %3.f\xb0", j+1, temps[j].cur_temp);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (j*12) + 2);
+ g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, temps[j].cur_temp + 1, tot_max_temp, 4);
+ drawBar_reversed(canvas, BAR_START, bar_top,BAR_END, bar_bottom, G15_COLOR_BLACK, tot_max_temp - temps[j].cur_temp, tot_max_temp, 5);
+ }
+ }
+
+ char extension[11];
+ sprintf(tmpstr, " ");
+ for (j = 0; j < i; j++) {
+ if ((j + 1) != i) {
+ sprintf(extension, "Temp%d %3.f\xb0 | ", j+1, temps[j].cur_temp);
+ } else {
+ sprintf(extension, "Temp%d %3.f\xb0 ", j+1, temps[j].cur_temp);
+ }
+ strcat (tmpstr, extension);
+ }
+
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
void print_info_label(g15canvas *canvas) {
static int timer;
int my_cycle = cycle;
@@ -753,21 +850,24 @@
}
switch (my_cycle){
- case CYCLE_CPU_SCREEN :
+ case SCREEN_CPU_SCREEN :
print_sys_load_info(canvas);
break;
- case CYCLE_MEM_SCREEN :
+ case SCREEN_MEM_SCREEN :
print_mem_info(canvas);
break;
- case CYCLE_SWAP_SCREEN :
+ case SCREEN_SWAP_SCREEN :
print_swap_info(canvas);
break;
- case CYCLE_NET_SCREEN :
+ case SCREEN_NET_SCREEN :
print_net_info(canvas);
break;
- case CYCLE_BAT_SCREEN :
+ case SCREEN_BAT_SCREEN :
draw_bat_screen(canvas, 0);
break;
+ case SCREEN_TEMP_SCREEN :
+ draw_temp_screen(canvas,(char*)sensor,0);
+ break;
default :
if ((timer < PAUSE)) {
print_sys_load_info(canvas);
@@ -779,15 +879,22 @@
draw_bat_screen(canvas, 0);
} else if (timer < PAUSE_5) {
print_time_info(canvas);
- } else if (have_nic) {
- print_net_info(canvas);
+ } else if (timer < PAUSE_6) {
+ if (have_nic) {
+ print_net_info(canvas);
+ } else {
+ timer = PAUSE_6;
+
+ }
+ }else if(have_sensor) {
+ draw_temp_screen(canvas,(char*)sensor,0);
} else {
print_sys_load_info(canvas);
timer = 0;
}
break;
}
- if (timer > PAUSE_5) {
+ if (timer > PAUSE_7) {
timer=0;
}
}
@@ -795,6 +902,7 @@
void keyboard_watch(void) {
unsigned int keystate;
int change = 0;
+ int direction = 0;
while(1) {
recv(g15screen_fd,&keystate,4,0);
@@ -803,10 +911,12 @@
}
else if(keystate & G15_KEY_L2) {
cycle--;
+ direction = 0;
change++;
}
else if(keystate & G15_KEY_L3) {
cycle++;
+ direction = 1;
change++;
}
else if(keystate & G15_KEY_L4) {
@@ -819,10 +929,21 @@
}
if (cycle<0)
{
- // Wrap around the apps
- cycle=MAX_SCREENS;
+ if(have_sensor) {
+ cycle=MAX_SCREENS;
+ } else {
+ cycle=MAX_SCREENS - 1;
+ }
}
- if (cycle>MAX_SCREENS)
+ if ((!have_nic) && (cycle == SCREEN_NET_SCREEN))
+ {
+ if (direction) {
+ cycle++;
+ } else {
+ cycle--;
+ }
+ }
+ if ((cycle>MAX_SCREENS) || ((cycle>(MAX_SCREENS-1)) && (!have_sensor)))
{
//Wrap around the apps
cycle=0;
@@ -933,7 +1054,7 @@
if(0==strncmp(argv[i],"-d",2)||0==strncmp(argv[i],"--daemon",8)) {
go_daemon=1;
}
- if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",8)) {
+ if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",9)) {
unicore=1;
}
if(0==strncmp(argv[i],"-nsa",4)||0==strncmp(argv[i],"--net-scale-absolute",20)) {
@@ -941,22 +1062,32 @@
}
if(0==strncmp(argv[i],"-h",2)||0==strncmp(argv[i],"--help",6)) {
- printf("%s (c) 2008 Mike Lampard\n",PACKAGE_NAME);
+ printf("%s (c) 2008-2009 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME);
printf("\nOptions:\n");
printf("--daemon (-d) run in background\n");
printf("--unicore (-u) display unicore graphs only on the CPU screen\n");
printf("--help (-h) this help text.\n");
printf("--interface [interface] (-i) monitor network interface [interface] ie -i eth0\n");
- printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
+ printf("--sensor [device] (-s) monitor temperature sensors [device] ie -s it87.656\n"
+ "\t[device] should point to sysfs path /sys/devices/platform/[device]/temp1_input\n");
+ printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n"
+ "\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
return 0;
}
- if(0==strncmp(argv[i],"-i",2)||0==strncmp(argv[i],"--interface",8)) {
+ if(0==strncmp(argv[i],"-i",2)||0==strncmp(argv[i],"--interface",11)) {
if(argv[i+1]!=NULL) {
have_nic=1;
i++;
strncpy((char*)interface,argv[i],128);
}
}
+ if(0==strncmp(argv[i],"-s",2)||0==strncmp(argv[i],"--sensor",8)) {
+ if(argv[i+1]!=NULL) {
+ have_sensor=1;
+ i++;
+ strncpy((char*)sensor,argv[i],128);
+ }
+ }
}
if((g15screen_fd = new_g15_screen(G15_G15RBUF))<0){
printf("Sorry, cant connect to the G15daemon\n");
@@ -981,28 +1112,34 @@
while(1) {
switch(cycle) {
- case CYCLE_CPU_SCREEN:
+ case SCREEN_CPU_SCREEN:
draw_cpu_screen_multicore(canvas,unicore);
print_info_label(canvas);
break;
- case CYCLE_MEM_SCREEN:
+ case SCREEN_MEM_SCREEN:
draw_mem_screen(canvas);
print_info_label(canvas);
break;
- case CYCLE_SWAP_SCREEN:
+ case SCREEN_SWAP_SCREEN:
draw_swap_screen(canvas);
print_info_label(canvas);
break;
- case CYCLE_NET_SCREEN:
+ case SCREEN_NET_SCREEN:
if(have_nic) {
draw_net_screen(canvas,(char*)interface);
print_info_label(canvas);
break;
}else
cycle++;
- case CYCLE_BAT_SCREEN:
+ case SCREEN_BAT_SCREEN:
draw_bat_screen(canvas,1);
break;
+ case SCREEN_TEMP_SCREEN:
+ if(have_sensor) {
+ draw_temp_screen(canvas,(char*)sensor,1);
+ break;
+ }else
+ cycle++;
default:
printf("cycle reached %i\n",cycle);
cycle=0;
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-06 23:12:22 UTC (rev 509)
@@ -1,6 +1,7 @@
#define TEXT_LEFT 1
#define NUM_BATS 3
-#define MAX_SCREENS 4
+#define NUM_TEMP 3
+#define MAX_SCREENS 5
#define MAX_MODE 3
#define MAX_SUB_MODE 1
@@ -9,6 +10,8 @@
#define PAUSE_3 3*PAUSE
#define PAUSE_4 4*PAUSE
#define PAUSE_5 5*PAUSE
+#define PAUSE_6 6*PAUSE
+#define PAUSE_7 7*PAUSE
#define VL_LEFT 42
#define BAR_START 45
@@ -17,11 +20,12 @@
#define TEXT_RIGHT 155
#define MAX_LINES 128
-#define CYCLE_CPU_SCREEN 0
-#define CYCLE_MEM_SCREEN 1
-#define CYCLE_SWAP_SCREEN 2
-#define CYCLE_NET_SCREEN 3
-#define CYCLE_BAT_SCREEN 4
+#define SCREEN_CPU_SCREEN 0
+#define SCREEN_MEM_SCREEN 1
+#define SCREEN_SWAP_SCREEN 2
+#define SCREEN_NET_SCREEN 3
+#define SCREEN_BAT_SCREEN 4
+#define SCREEN_TEMP_SCREEN 5
#define MODE_CPU_USR_SYS_NCE_1 0
#define MODE_CPU_TOTAL 1
@@ -35,3 +39,8 @@
long status;
} g15_stats_bat_info;
+typedef struct g15_stats_temp_info
+{
+ float max_temp;
+ float cur_temp;
+} g15_stats_temp_info;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-06-07 18:42:36
|
Revision: 510
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=510&view=rev
Author: czarnyckm
Date: 2009-06-07 18:42:32 +0000 (Sun, 07 Jun 2009)
Log Message:
-----------
- Temperature sensor autodetect
- Force user sensor id with the option -s id
(The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-06 23:12:22 UTC (rev 509)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-07 18:42:32 UTC (rev 510)
@@ -14,4 +14,7 @@
SVN 505:
- Bugfix: Render bottom line on the Memory Screen once
SVN 509:
-- Temperature sensors depends on the lmsensors sysfs filesystem
\ No newline at end of file
+- Temperature sensors depends on the lmsensors sysfs filesystem
+SVN 510:
+- Temperature sensor autodetect
+- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-06-06 23:12:22 UTC (rev 509)
+++ trunk/g15daemon-clients/g15stats/README 2009-06-07 18:42:32 UTC (rev 510)
@@ -24,9 +24,9 @@
default is to scale against the highest peak in the current graph.
-h Show help
-u Display unicore graphs only on the CPU screen
--s device Monitor temperature sensors device (ie -s it87.656)
- device should point to sysfs path /sys/devices/platform/[device]/temp1_input
- depends on the lmsensors
+-s id Force to monitor temperature sensor id (ie -s 1)
+ The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input
+ Default the sensor id is autoetected.
Usage:
$> g15stats
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-06 23:12:22 UTC (rev 509)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-07 18:42:32 UTC (rev 510)
@@ -66,8 +66,8 @@
int have_nic=0;
-int have_sensor=0;
-unsigned char sensor[128];
+int have_sensor=1;
+int sensorId = 0;
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -746,7 +746,7 @@
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
}
-void draw_temp_screen(g15canvas *canvas, char *sensor, int all) {
+void draw_temp_screen(g15canvas *canvas, int all) {
g15_stats_temp_info temps[NUM_TEMP];
long tot_max_temp = 1;
@@ -762,12 +762,13 @@
{
char filename[128];
- // Initialize battery state
+ // Initialize temperature state
temps[i].max_temp = 1;
temps[i].cur_temp = 1;
- /* /sys/devices/platform/it87.656/temp1_input */
- sprintf(filename, "/sys/devices/platform/%s/temp%d_input",sensor, i+1);
+ /* /sys/class/hwmon/hwmon0/temp1_input */
+ /* /sys/class/hwmon/hwmon1/device/temp1_input */
+ sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
fd_input=fopen (filename,"r");
if (fd_input!=NULL)
{
@@ -780,7 +781,7 @@
break;
}
- sprintf(filename, "/sys/devices/platform/%s/temp%d_max",sensor, i+1);
+ sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
fd_max=fopen (filename,"r");
if (fd_max!=NULL)
{
@@ -797,7 +798,11 @@
}
if (i == 0) {
- have_sensor = 0;
+ if (sensorId < 3) {
+ sensorId++;
+ } else {
+ have_sensor = 0;
+ }
}
if((i+1) >= NUM_TEMP) {
i = NUM_TEMP;
@@ -866,7 +871,7 @@
draw_bat_screen(canvas, 0);
break;
case SCREEN_TEMP_SCREEN :
- draw_temp_screen(canvas,(char*)sensor,0);
+ draw_temp_screen(canvas, 0);
break;
default :
if ((timer < PAUSE)) {
@@ -887,7 +892,7 @@
}
}else if(have_sensor) {
- draw_temp_screen(canvas,(char*)sensor,0);
+ draw_temp_screen(canvas, 0);
} else {
print_sys_load_info(canvas);
timer = 0;
@@ -1068,8 +1073,8 @@
printf("--unicore (-u) display unicore graphs only on the CPU screen\n");
printf("--help (-h) this help text.\n");
printf("--interface [interface] (-i) monitor network interface [interface] ie -i eth0\n");
- printf("--sensor [device] (-s) monitor temperature sensors [device] ie -s it87.656\n"
- "\t[device] should point to sysfs path /sys/devices/platform/[device]/temp1_input\n");
+ printf("--sensor [id] (-s) monitor temperature sensors [id] ie -s 1\n"
+ "\t[device] should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input\n");
printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n"
"\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
return 0;
@@ -1083,9 +1088,8 @@
}
if(0==strncmp(argv[i],"-s",2)||0==strncmp(argv[i],"--sensor",8)) {
if(argv[i+1]!=NULL) {
- have_sensor=1;
i++;
- strncpy((char*)sensor,argv[i],128);
+ sensorId = atoi(argv[i]);
}
}
}
@@ -1136,7 +1140,7 @@
break;
case SCREEN_TEMP_SCREEN:
if(have_sensor) {
- draw_temp_screen(canvas,(char*)sensor,1);
+ draw_temp_screen(canvas,1);
break;
}else
cycle++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-06-08 21:26:18
|
Revision: 511
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=511&view=rev
Author: czarnyckm
Date: 2009-06-08 21:25:10 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
- Improved sensor's autodetect
- Clean up
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-07 18:42:32 UTC (rev 510)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-08 21:25:10 UTC (rev 511)
@@ -16,5 +16,8 @@
SVN 509:
- Temperature sensors depends on the lmsensors sysfs filesystem
SVN 510:
-- Temperature sensor autodetect
-- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
\ No newline at end of file
+- Temperature sensor's autodetect
+- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
+SVN 511:
+- Improved sensor's autodetect
+- Clean up
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-07 18:42:32 UTC (rev 510)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-08 21:25:10 UTC (rev 511)
@@ -749,47 +749,43 @@
void draw_temp_screen(g15canvas *canvas, int all) {
g15_stats_temp_info temps[NUM_TEMP];
- long tot_max_temp = 1;
+ float tot_max_temp = 1;
- FILE *fd_input;
- FILE *fd_max;
- char line [MAX_LINES];
+ FILE *fd_main;
char tmpstr [MAX_LINES];
int i = 0;
int j = 0;
for (i = 0; i < NUM_TEMP; i++)
{
- char filename[128];
-
// Initialize temperature state
temps[i].max_temp = 1;
temps[i].cur_temp = 1;
/* /sys/class/hwmon/hwmon0/temp1_input */
/* /sys/class/hwmon/hwmon1/device/temp1_input */
- sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
- fd_input=fopen (filename,"r");
- if (fd_input!=NULL)
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
+ fd_main=fopen (tmpstr,"r");
+ if (fd_main!=NULL)
{
- if (fgets (line,MAX_LINES,fd_input)!=NULL)
+ if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
{
- temps[i].cur_temp=atoi (line) / 1000;
+ temps[i].cur_temp=atoi (tmpstr) / 1000;
}
- fclose (fd_input);
+ fclose (fd_main);
} else {
break;
}
- sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
- fd_max=fopen (filename,"r");
- if (fd_max!=NULL)
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
+ fd_main=fopen (tmpstr,"r");
+ if (fd_main!=NULL)
{
- if (fgets (line,MAX_LINES,fd_max)!=NULL)
+ if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
{
- temps[i].max_temp=atoi (line) / 1000;
+ temps[i].max_temp=atoi (tmpstr) / 1000;
}
- fclose (fd_max);
+ fclose (fd_main);
}
if(tot_max_temp < temps[i].max_temp) {
@@ -798,11 +794,16 @@
}
if (i == 0) {
- if (sensorId < 3) {
+ if (sensorId < MAX_SENSOR) {
+ printf("Temperature sensor doesn't appear to exist with id=%d . ",sensorId);
sensorId++;
+ printf("Let's try id=%d.\n",sensorId);
+ draw_temp_screen(canvas, all);
} else {
+ printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
have_sensor = 0;
}
+ return;
}
if((i+1) >= NUM_TEMP) {
i = NUM_TEMP;
@@ -831,7 +832,7 @@
}
}
- char extension[11];
+ char extension[16];
sprintf(tmpstr, " ");
for (j = 0; j < i; j++) {
if ((j + 1) != i) {
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-07 18:42:32 UTC (rev 510)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-08 21:25:10 UTC (rev 511)
@@ -1,6 +1,7 @@
#define TEXT_LEFT 1
#define NUM_BATS 3
#define NUM_TEMP 3
+#define MAX_SENSOR 3
#define MAX_SCREENS 5
#define MAX_MODE 3
#define MAX_SUB_MODE 1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-06-13 12:53:31
|
Revision: 512
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=512&view=rev
Author: czarnyckm
Date: 2009-06-13 12:13:32 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
- CPU Screens variants for uni core processors
- CPU frequency info (if available)
- Battery Screen is enabled if available
- Clean up
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-08 21:25:10 UTC (rev 511)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-13 12:13:32 UTC (rev 512)
@@ -19,5 +19,11 @@
- Temperature sensor's autodetect
- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
SVN 511:
-- Improved sensor's autodetect
+- Improve sensor's autodetect
- Clean up
+SVN 512:
+- CPU Screens variants for uni core processors
+- CPU frequency info (if available)
+- Battery Screen is enabled if available
+- Clean up
+
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-06-08 21:25:10 UTC (rev 511)
+++ trunk/g15daemon-clients/g15stats/README 2009-06-13 12:13:32 UTC (rev 512)
@@ -4,7 +4,7 @@
installed before compilation.
Features:
-CPU Screen displays graphs of User/System/Nice and Idle time, along with
+CPU Screen displays graphs of User/System/Nice and Idle time, along with frequency,
LoadAVG and Uptime.
Memory Screen displays Memory Total & Free, and graph of Used vs
@@ -17,6 +17,8 @@
Battery Status Screen displays battery charge data for up to three batteries
+Temperature Screen displays temperature current status for up to three sensors
+
Options:
-i interface Gather statistics from named interface (ie -i eth0)
-d Run in background (daemonise)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-08 21:25:10 UTC (rev 511)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-13 12:13:32 UTC (rev 512)
@@ -64,11 +64,18 @@
/** Holds the sub mode type variable of the application running */
int submode = 0;
-int have_nic=0;
+int timer;
-int have_sensor=1;
-int sensorId = 0;
+int have_freq = 1;
+int have_sensor = 1;
+int have_bat = 1;
+int have_nic = 0;
+int sensor_id = 0;
+
+/** Holds the number of the cpus */
+int ncpu;
+
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -89,7 +96,7 @@
}
char * show_bytes(unsigned long bytes) {
- static char tmpstr[128];
+ static char tmpstr[32];
if(bytes>1024*1024) {
bytes = bytes / (1024*1024);
sprintf(tmpstr,"%liMb",bytes);
@@ -104,6 +111,18 @@
return tmpstr;
}
+char * show_hertz(int hertz) {
+ static char tmpstr[32];
+ if (hertz > 1000000) {
+ sprintf(tmpstr, " %3.1fGHz", ((float)hertz / 1000000));
+ } else if (hertz > 1000) {
+ sprintf(tmpstr, " %3.fMHz", ((float)hertz / 1000));
+ } else {
+ sprintf(tmpstr, " %3iKHz", hertz);
+ }
+ return tmpstr;
+}
+
void drawBar_reversed (g15canvas * canvas, int x1, int y1, int x2, int y2, int color,
int num, int max, int type)
{
@@ -182,6 +201,74 @@
return 0;
}
+void init_cpu_count(void) {
+ // initialize cpu count once
+ if (!ncpu) {
+ const glibtop_sysinfo *cpuinfo = glibtop_get_sysinfo();
+
+ if(cpuinfo->ncpu == 0) {
+ ncpu = 1;
+ } else {
+ ncpu = cpuinfo->ncpu;
+ }
+ }
+}
+
+int get_sysfs_value(char * filename) {
+ static int ret_val = -1;
+ FILE *fd_main;
+ char tmpstr [MAX_LINES];
+
+ fd_main = fopen(filename, "r");
+ if (fd_main != NULL) {
+ if (fgets(tmpstr, MAX_LINES, fd_main) != NULL) {
+ fclose(fd_main);
+ ret_val = atoi(tmpstr);
+ } else
+ fclose(fd_main);
+ } else {
+ ret_val = SENSOR_ERROR;
+ }
+ return ret_val;
+}
+
+int get_processor_freq(char * which, int core) {
+ char tmpstr [MAX_LINES];
+ sprintf(tmpstr, "/sys/devices/system/cpu/cpu%d/cpufreq/%s", core, which);
+ return get_sysfs_value(tmpstr);
+}
+
+int get_cpu_freq_cur(int core) {
+ int ret_val = get_processor_freq("cpuinfo_cur_freq", core);
+ if ((!core) && (ret_val == SENSOR_ERROR)) {
+ have_freq = 0;
+ printf("Frequency sensor doesn't appear to exist with id=%d . ", sensor_id);
+ }
+ return ret_val;
+}
+
+int get_cpu_freq_max(int core) {
+ return get_processor_freq("cpuinfo_max_freq", core);
+}
+
+int get_cpu_freq_min(int core) {
+ return get_processor_freq("cpuinfo_min_freq", core);
+}
+
+int get_temp(char * which, int id) {
+ char tmpstr [MAX_LINES];
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_%s", sensor_id, id, which);
+ return get_sysfs_value(tmpstr);
+}
+
+int get_temp_cur(int id) {
+ return get_temp("input", id);
+}
+
+int get_temp_max(int id) {
+ return get_temp("max", id);
+}
+
void print_sys_load_info(g15canvas *canvas) {
char tmpstr[MAX_LINES];
glibtop_loadavg loadavg;
@@ -200,7 +287,7 @@
hours=(int)hours-(days*24);
sprintf(tmpstr,"LoadAVG %.2f %.2f %.2f | Uptime %.fd%.fh",loadavg.loadavg[0],loadavg.loadavg[1],loadavg.loadavg[2],days,hours);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
void print_mem_info(g15canvas *canvas) {
@@ -209,7 +296,7 @@
glibtop_get_mem(&mem);
sprintf(tmpstr,"Memory Used %dMb | Memory Total %dMb",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
void print_swap_info(g15canvas *canvas) {
@@ -218,7 +305,7 @@
glibtop_get_swap(&swap);
sprintf(tmpstr,"Swap Used %dMb | Swap Avail. %dMb",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
void print_net_info(g15canvas *canvas) {
@@ -227,16 +314,35 @@
strcat(tmpstr,"Peak OUT ");
strcat(tmpstr,show_bytes(net_max_out));
strcat(tmpstr,"/s");
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
+void print_freq_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ int core;
+ init_cpu_count();
+ if (ncpu < 4) {
+ sprintf(tmpstr, "%s", "CPU ");
+ } else {
+ sprintf(tmpstr, "%s", "");
+ }
+ for (core = 0; core < ncpu; core++) {
+ strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
+ if ((core + 1) < ncpu) {
+ strcat(tmpstr, " |");
+ }
+ }
+
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, BOTTOM_ROW);
+}
+
void print_time_info(g15canvas *canvas){
char tmpstr[MAX_LINES];
time_t now;
time(&now);
sprintf(tmpstr,"%s",ctime(&now));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
void draw_mem_screen(g15canvas *canvas) {
@@ -262,11 +368,11 @@
g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,mem_user,mem_total,4);
g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,mem_buffer,mem_total,4);
- g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,mem_cached,mem_total,4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,mem_free,mem_total,5);
+ g15r_drawBar(canvas,BAR_START,23,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,mem_cached,mem_total,4);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,mem_free,mem_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
@@ -289,12 +395,12 @@
sprintf(tmpstr,"Used %i%%",(unsigned int)(((float)swap_used/(float)swap_total)*100));
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 19);
- g15r_drawBar(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,swap_used,swap_total,4);
+ g15r_drawBar(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,swap_used,swap_total,4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,swap_total-swap_used,swap_total,5);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,swap_total-swap_used,swap_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
@@ -344,11 +450,11 @@
if(drawgraph) {
g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,b_user+1,b_total,4);
g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,b_sys+1,b_total,4);
- g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,b_nice+1,b_total,4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,b_idle+1,b_total,5);
+ g15r_drawBar(canvas,BAR_START,23,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,b_nice+1,b_total,4);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,b_idle+1,b_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
}
if (cpuandmemory) {
g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 3);
@@ -376,8 +482,7 @@
void draw_cpu_screen_multicore(g15canvas *canvas, int unicore) {
glibtop_cpu cpu;
char tmpstr[MAX_LINES];
- const glibtop_sysinfo *cpuinfo;
- int core,ncpu,ncpumax;
+ int core,ncpumax;
int divider = 0;
int total,user,nice,sys,idle;
@@ -385,18 +490,14 @@
static int last_total[GLIBTOP_NCPU],last_user[GLIBTOP_NCPU],last_nice[GLIBTOP_NCPU],
last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],last_irq[GLIBTOP_NCPU];
- cpuinfo = glibtop_get_sysinfo();
+ init_cpu_count();
- if(cpuinfo->ncpu == 0)
- ncpu = 1;
- else
- ncpu = cpuinfo->ncpu;
-
ncpumax = ncpu;
glibtop_get_cpu(&cpu);
- if (ncpu==1 || unicore) {
+ if ((ncpu==1 && ((mode == MODE_CPU_USR_SYS_NCE_1) || (mode == MODE_CPU_USR_SYS_NCE_2)))
+ || (unicore)) {
draw_cpu_screen_unicore_logic(canvas, cpu, 1, 1, 0);
return;
} else if (((ncpu > 5) && (mode != MODE_CPU_SUMARY))
@@ -409,7 +510,8 @@
draw_cpu_screen_unicore_logic(canvas, cpu, 0, 0, 1);
}
- int y1=0, y2=32, currentValue, mem_used=1, mem_total=1;
+ int y1=0, y2=BAR_BOTTOM;
+ int current_value=1, mem_used=1, mem_total=1;
int spacer = 1;
int height = 8;
@@ -419,7 +521,7 @@
if(ncpu > 11){
spacer = 0;
}
- height = 37;
+ height = 36;
break;
case MODE_CPU_USR_SYS_NCE_2 :
if(ncpu > 4){
@@ -483,7 +585,7 @@
if (mode) {
y1 = (core * height) + (core * spacer);
y2 = y1 + height - 1;
- currentValue = b_total - b_idle;
+ current_value = b_total - b_idle;
}
switch (mode) {
@@ -500,7 +602,11 @@
break;
case MODE_CPU_TOTAL :
if (ncpu < 6) {
- sprintf(tmpstr,"CPU%.f%3.f%%",(float)core,((float)(b_total-b_idle)/(float)b_total)*100);
+ if (have_freq) {
+ sprintf(tmpstr,"%s", show_hertz(get_cpu_freq_cur(core)));
+ } else {
+ sprintf(tmpstr,"CPU%.f%3.f%%",(float)core,((float)(b_total-b_idle)/(float)b_total)*100);
+ }
if (ncpu < 5) {
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, y1+1);
} else {
@@ -508,17 +614,17 @@
}
}
- g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
- drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, current_value, b_total,4);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-current_value, b_total,5);
y1 = 0;
break;
case MODE_CPU_USR_SYS_NCE_2 :
- g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, current_value, b_total,4);
g15r_drawBar(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_sys+1,b_total,4);
g15r_drawBar(canvas, BAR_START,24+y1,BAR_END,24+y2,G15_COLOR_BLACK,b_nice+1,b_total,4);
- drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-current_value, b_total,5);
drawBar_reversed(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_total-b_sys,b_total,5);
y2 += 24;
@@ -527,10 +633,10 @@
y1 = 0;
break;
case MODE_CPU_SUMARY :
- g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, current_value, b_total,4);
g15r_drawBar(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_used+1, mem_total,4);
- drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-current_value, b_total,5);
drawBar_reversed(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_total - mem_used, mem_total,5);
y1 = 0;
break;
@@ -540,7 +646,7 @@
g15r_drawLine (canvas, VL_LEFT, y1, VL_LEFT, y2, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, y1, VL_LEFT+1, y2, G15_COLOR_BLACK);
- if(mode == 3) {
+ if(mode == MODE_CPU_SUMARY) {
g15r_drawLine (canvas, VL_LEFT, 19+y1, VL_LEFT, 19+y2, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, 19+y1, VL_LEFT+1, 19+y2, G15_COLOR_BLACK);
}
@@ -676,8 +782,17 @@
tot_cur_charge += bats[i].cur_charge;
tot_max_charge += bats[i].max_charge;
- }
+ } else {
+ break;
+ }
}
+
+ if (i == 0) {
+ printf("Battery sensor doesn't appear to exist. Battery screen will be disabled.\n");
+ have_bat = 0;
+ return;
+ }
+
if (all) {
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -686,8 +801,8 @@
g15r_renderString (canvas, (unsigned char*)"L", 2, G15_TEXT_MED, 155, 4);
g15r_renderString (canvas, (unsigned char*)"L", 3, G15_TEXT_MED, 155, 4);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
for (i = 0; i < NUM_BATS; i++)
{
@@ -703,113 +818,93 @@
g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, bats[i].cur_charge, bats[i].max_charge, 4);
}
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
}
- float total_charge = 0;
- if (tot_max_charge > 0)
- {
- total_charge = ((float)tot_cur_charge/(float)tot_max_charge)*100;
- }
- sprintf (tmpstr,"Total %2.f%% | ", total_charge);
+ if ((!all) || (cycle == SCREEN_BAT)) {
+ float total_charge = 0;
+ if (tot_max_charge > 0)
+ {
+ total_charge = ((float)tot_cur_charge/(float)tot_max_charge)*100;
+ }
+ sprintf (tmpstr,"Total %2.f%% | ", total_charge);
- for (i = 0; i < NUM_BATS; i++)
- {
- char extension[11];
- switch (bats[i].status)
- {
- case -1:
- {
- sprintf(extension, "Bt%d - | ", i);
- break;
- }
- case 0:
- {
- sprintf(extension, "Bt%d F | ", i);
- break;
- }
- case 1:
- {
- sprintf(extension, "Bt%d C | ", i);
- break;
- }
- case 2:
- {
- sprintf(extension, "Bt%d D | ", i);
- break;
- }
- }
+ for (i = 0; i < NUM_BATS; i++)
+ {
+ char extension[11];
+ switch (bats[i].status)
+ {
+ case -1:
+ {
+ sprintf(extension, "Bt%d - | ", i);
+ break;
+ }
+ case 0:
+ {
+ sprintf(extension, "Bt%d F | ", i);
+ break;
+ }
+ case 1:
+ {
+ sprintf(extension, "Bt%d C | ", i);
+ break;
+ }
+ case 2:
+ {
+ sprintf(extension, "Bt%d D | ", i);
+ break;
+ }
+ }
- strcat (tmpstr, extension);
- }
+ strcat (tmpstr, extension);
+ }
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ }
}
void draw_temp_screen(g15canvas *canvas, int all) {
- g15_stats_temp_info temps[NUM_TEMP];
- float tot_max_temp = 1;
+ g15_stats_temp_info temps[NUM_TEMP];
+ float tot_max_temp = 1;
- FILE *fd_main;
- char tmpstr [MAX_LINES];
+ char tmpstr [MAX_LINES];
- int i = 0;
- int j = 0;
- for (i = 0; i < NUM_TEMP; i++)
- {
- // Initialize temperature state
- temps[i].max_temp = 1;
- temps[i].cur_temp = 1;
-
- /* /sys/class/hwmon/hwmon0/temp1_input */
- /* /sys/class/hwmon/hwmon1/device/temp1_input */
- sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
- fd_main=fopen (tmpstr,"r");
- if (fd_main!=NULL)
- {
- if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
- {
- temps[i].cur_temp=atoi (tmpstr) / 1000;
- }
- fclose (fd_main);
- } else {
- break;
- }
+ int i = 0;
+ int j = 0;
+ for (i = 0; i < NUM_TEMP; i++) {
- sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
- fd_main=fopen (tmpstr,"r");
- if (fd_main!=NULL)
- {
- if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
- {
- temps[i].max_temp=atoi (tmpstr) / 1000;
- }
- fclose (fd_main);
- }
+ if ((temps[i].cur_temp = get_temp_cur(i + 1)) == SENSOR_ERROR) {
+ break;
+ }
+ temps[i].cur_temp /= 1000;
+ if (all) {
+ temps[i].max_temp = get_temp_max(i + 1);
+ temps[i].max_temp /= 1000;
- if(tot_max_temp < temps[i].max_temp) {
- tot_max_temp = temps[i].max_temp;
- }
-
- }
- if (i == 0) {
- if (sensorId < MAX_SENSOR) {
- printf("Temperature sensor doesn't appear to exist with id=%d . ",sensorId);
- sensorId++;
- printf("Let's try id=%d.\n",sensorId);
- draw_temp_screen(canvas, all);
- } else {
- printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
- have_sensor = 0;
+ if (tot_max_temp < temps[i].max_temp) {
+ tot_max_temp = temps[i].max_temp;
}
- return;
}
- if((i+1) >= NUM_TEMP) {
- i = NUM_TEMP;
+
+ }
+ if (i == 0) {
+ if (sensor_id < MAX_SENSOR) {
+ printf("Temperature sensor doesn't appear to exist with id=%d . ", sensor_id);
+ sensor_id++;
+ printf("Let's try id=%d.\n", sensor_id);
+ draw_temp_screen(canvas, all);
} else {
- i++;
+ printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
+ have_sensor = 0;
}
+ return;
+ }
+ if ((i + 1) >= NUM_TEMP) {
+ i = NUM_TEMP;
+ } else {
+ i++;
+ }
if (all) {
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -817,97 +912,117 @@
g15r_renderString (canvas, (unsigned char*)"M", 0, G15_TEXT_MED, 155, 3);
g15r_renderString (canvas, (unsigned char*)"A", 1, G15_TEXT_MED, 155, 7);
g15r_renderString (canvas, (unsigned char*)"X", 2, G15_TEXT_MED, 155, 11);
-
+
g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
- for (j = 0; j < i; j++) {
+ for (j = 0; j < i; j++) {
register int bar_top = (j*10) + 1 + j;
register int bar_bottom = ((j+1)*10) + j;
sprintf(tmpstr,"T-%d %3.f\xb0", j+1, temps[j].cur_temp);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (j*12) + 2);
- g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, temps[j].cur_temp + 1, tot_max_temp, 4);
+ g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, temps[j].cur_temp + 1, tot_max_temp, 4);
drawBar_reversed(canvas, BAR_START, bar_top,BAR_END, bar_bottom, G15_COLOR_BLACK, tot_max_temp - temps[j].cur_temp, tot_max_temp, 5);
- }
}
+ }
+ if ((!all) || ((cycle == SCREEN_TEMP) && ((submode) || (timer/PAUSE) == SCREEN_TEMP))) {
char extension[16];
sprintf(tmpstr, " ");
- for (j = 0; j < i; j++) {
+ for (j = 0; j < i; j++) {
if ((j + 1) != i) {
- sprintf(extension, "Temp%d %3.f\xb0 | ", j+1, temps[j].cur_temp);
+ sprintf(extension, "Temp%d %3.f\xb0 | ", j + 1, temps[j].cur_temp);
} else {
- sprintf(extension, "Temp%d %3.f\xb0 ", j+1, temps[j].cur_temp);
+ sprintf(extension, "Temp%d %3.f\xb0 ", j + 1, temps[j].cur_temp);
}
- strcat (tmpstr, extension);
- }
-
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ strcat(tmpstr, extension);
+ }
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, BOTTOM_ROW);
+ }
}
void print_info_label(g15canvas *canvas) {
- static int timer;
int my_cycle = cycle;
timer++;
- if (! submode) {
+ if (!submode) {
my_cycle = -1;
}
- switch (my_cycle){
- case SCREEN_CPU_SCREEN :
+ switch (my_cycle) {
+ case SCREEN_CPU:
print_sys_load_info(canvas);
break;
- case SCREEN_MEM_SCREEN :
+ case SCREEN_MEM:
print_mem_info(canvas);
break;
- case SCREEN_SWAP_SCREEN :
+ case SCREEN_SWAP:
print_swap_info(canvas);
break;
- case SCREEN_NET_SCREEN :
+ case SCREEN_NET:
print_net_info(canvas);
break;
- case SCREEN_BAT_SCREEN :
- draw_bat_screen(canvas, 0);
+ case SCREEN_BAT:
+ //draw_bat_screen(canvas, 0);
break;
- case SCREEN_TEMP_SCREEN :
- draw_temp_screen(canvas, 0);
+ case SCREEN_TEMP:
+ //draw_temp_screen(canvas, 0);
break;
- default :
- if ((timer < PAUSE)) {
- print_sys_load_info(canvas);
- } else if (timer < PAUSE_2) {
- print_mem_info(canvas);
- } else if (timer < PAUSE_3) {
- print_swap_info(canvas);
- } else if (timer < PAUSE_4) {
- draw_bat_screen(canvas, 0);
- } else if (timer < PAUSE_5) {
- print_time_info(canvas);
- } else if (timer < PAUSE_6) {
- if (have_nic) {
+ default:
+ switch (timer / PAUSE) {
+ case SCREEN_CPU:
+ print_sys_load_info(canvas);
+ break;
+ case SCREEN_MEM:
+ print_mem_info(canvas);
+ break;
+ case SCREEN_SWAP:
+ print_swap_info(canvas);
+ break;
+ case SCREEN_NET:
print_net_info(canvas);
- } else {
- timer = PAUSE_6;
+ break;
+ case SCREEN_BAT:
+ if (have_bat) {
+ if (cycle != SCREEN_BAT)
+ draw_bat_screen(canvas, 0);
+ break;
+ } else {
+ timer += PAUSE;
+ }
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ if (cycle != SCREEN_TEMP)
+ draw_temp_screen(canvas, 0);
+ break;
+ } else {
+ timer += PAUSE;
+ }
+ case SCREEN_FREQ:
+ if (have_freq) {
+ if (cycle != SCREEN_FREQ)
+ print_freq_info(canvas);
+ break;
+ } else {
+ timer += PAUSE;
+ }
+ case SCREEN_TIME:
+ print_time_info(canvas);
+ break;
+ default:
+ timer=0;
+ print_sys_load_info(canvas);
+ break;
- }
- }else if(have_sensor) {
- draw_temp_screen(canvas, 0);
- } else {
- print_sys_load_info(canvas);
- timer = 0;
}
break;
}
- if (timer > PAUSE_7) {
- timer=0;
- }
}
void keyboard_watch(void) {
unsigned int keystate;
- int change = 0;
+ int change = 0;
int direction = 0;
while(1) {
@@ -917,12 +1032,12 @@
}
else if(keystate & G15_KEY_L2) {
cycle--;
- direction = 0;
+ direction = DIRECTION_DOWN;
change++;
}
else if(keystate & G15_KEY_L3) {
cycle++;
- direction = 1;
+ direction = DIRECTION_UP;
change++;
}
else if(keystate & G15_KEY_L4) {
@@ -940,37 +1055,63 @@
} else {
cycle=MAX_SCREENS - 1;
}
- }
- if ((!have_nic) && (cycle == SCREEN_NET_SCREEN))
+ }
+ if (direction == DIRECTION_UP)
{
- if (direction) {
- cycle++;
- } else {
- cycle--;
+ switch (cycle) {
+ ...
[truncated message content] |
|
From: <cza...@us...> - 2009-06-14 14:06:23
|
Revision: 513
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=513&view=rev
Author: czarnyckm
Date: 2009-06-14 13:31:49 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
Improve bottom line and keywatch logic
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-13 12:13:32 UTC (rev 512)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-14 13:31:49 UTC (rev 513)
@@ -26,4 +26,6 @@
- CPU frequency info (if available)
- Battery Screen is enabled if available
- Clean up
+SVN 513:
+- Improve bottom line and keywatch logic
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-13 12:13:32 UTC (rev 512)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-14 13:31:49 UTC (rev 513)
@@ -59,13 +59,12 @@
int g15screen_fd;
int cycle = 0;
+int info_cycle = 0;
/** Holds the mode type variable of the application running */
int mode = 0;
/** Holds the sub mode type variable of the application running */
int submode = 0;
-int timer;
-
int have_freq = 1;
int have_sensor = 1;
int have_bat = 1;
@@ -111,18 +110,26 @@
return tmpstr;
}
-char * show_hertz(int hertz) {
+char * show_hertz_logic(int hertz, char * hz) {
static char tmpstr[32];
if (hertz > 1000000) {
- sprintf(tmpstr, " %3.1fGHz", ((float)hertz / 1000000));
+ sprintf(tmpstr, " %3.1fG%s", ((float)hertz / 1000000), hz);
} else if (hertz > 1000) {
- sprintf(tmpstr, " %3.fMHz", ((float)hertz / 1000));
+ sprintf(tmpstr, " %3.fM%s", ((float)hertz / 1000), hz);
} else {
- sprintf(tmpstr, " %3iKHz", hertz);
+ sprintf(tmpstr, " %3iK%s", hertz, hz);
}
return tmpstr;
}
+char * show_hertz_short(int hertz) {
+ return show_hertz_logic(hertz, "");
+}
+
+char * show_hertz(int hertz) {
+ return show_hertz_logic(hertz, "Hz");
+}
+
void drawBar_reversed (g15canvas * canvas, int x1, int y1, int x2, int y2, int color,
int num, int max, int type)
{
@@ -319,15 +326,24 @@
void print_freq_info(g15canvas *canvas) {
char tmpstr[MAX_LINES];
+ int normal = 1;
int core;
init_cpu_count();
- if (ncpu < 4) {
+ if (ncpu < 5) {
sprintf(tmpstr, "%s", "CPU ");
+ } else if (ncpu > 5) {
+ normal = 0;
+ sprintf(tmpstr, "%s", "");
} else {
sprintf(tmpstr, "%s", "");
}
+
for (core = 0; core < ncpu; core++) {
- strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
+ if (normal) {
+ strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
+ } else {
+ strcat(tmpstr, show_hertz_short(get_cpu_freq_cur(core)));
+ }
if ((core + 1) < ncpu) {
strcat(tmpstr, " |");
}
@@ -787,7 +803,7 @@
}
}
- if (i == 0) {
+ if (!i) {
printf("Battery sensor doesn't appear to exist. Battery screen will be disabled.\n");
have_bat = 0;
return;
@@ -821,7 +837,7 @@
drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
}
- if ((!all) || (cycle == SCREEN_BAT)) {
+ if ((!all) || (info_cycle == SCREEN_BAT)) {
float total_charge = 0;
if (tot_max_charge > 0)
{
@@ -870,25 +886,25 @@
char tmpstr [MAX_LINES];
- int i = 0;
+ int count = 0;
int j = 0;
- for (i = 0; i < NUM_TEMP; i++) {
+ for (count = 0; count < NUM_TEMP; count++) {
- if ((temps[i].cur_temp = get_temp_cur(i + 1)) == SENSOR_ERROR) {
+ if ((temps[count].cur_temp = get_temp_cur(count + 1)) == SENSOR_ERROR) {
break;
}
- temps[i].cur_temp /= 1000;
+ temps[count].cur_temp /= 1000;
if (all) {
- temps[i].max_temp = get_temp_max(i + 1);
- temps[i].max_temp /= 1000;
+ temps[count].max_temp = get_temp_max(count + 1);
+ temps[count].max_temp /= 1000;
- if (tot_max_temp < temps[i].max_temp) {
- tot_max_temp = temps[i].max_temp;
+ if (tot_max_temp < temps[count].max_temp) {
+ tot_max_temp = temps[count].max_temp;
}
}
}
- if (i == 0) {
+ if (!count) {
if (sensor_id < MAX_SENSOR) {
printf("Temperature sensor doesn't appear to exist with id=%d . ", sensor_id);
sensor_id++;
@@ -900,38 +916,38 @@
}
return;
}
- if ((i + 1) >= NUM_TEMP) {
- i = NUM_TEMP;
+ if ((count + 1) >= NUM_TEMP) {
+ count = NUM_TEMP;
} else {
- i++;
+ count++;
}
- if (all) {
- g15r_clearScreen (canvas, G15_COLOR_WHITE);
+ if (all) {
+ g15r_clearScreen(canvas, G15_COLOR_WHITE);
- g15r_renderString (canvas, (unsigned char*)"M", 0, G15_TEXT_MED, 155, 3);
- g15r_renderString (canvas, (unsigned char*)"A", 1, G15_TEXT_MED, 155, 7);
- g15r_renderString (canvas, (unsigned char*)"X", 2, G15_TEXT_MED, 155, 11);
+ g15r_renderString(canvas, (unsigned char*) "M", 0, G15_TEXT_MED, 155, 3);
+ g15r_renderString(canvas, (unsigned char*) "A", 1, G15_TEXT_MED, 155, 7);
+ g15r_renderString(canvas, (unsigned char*) "X", 2, G15_TEXT_MED, 155, 11);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine(canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine(canvas, VL_LEFT + 1, 1, VL_LEFT + 1, 32, G15_COLOR_BLACK);
- for (j = 0; j < i; j++) {
- register int bar_top = (j*10) + 1 + j;
- register int bar_bottom = ((j+1)*10) + j;
+ for (j = 0; j < count; j++) {
+ register int bar_top = (j * 10) + 1 + j;
+ register int bar_bottom = ((j + 1)*10) + j;
- sprintf(tmpstr,"T-%d %3.f\xb0", j+1, temps[j].cur_temp);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (j*12) + 2);
+ sprintf(tmpstr, "T-%d %3.f\xb0", j + 1, temps[j].cur_temp);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, (j * 12) + 2);
g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, temps[j].cur_temp + 1, tot_max_temp, 4);
- drawBar_reversed(canvas, BAR_START, bar_top,BAR_END, bar_bottom, G15_COLOR_BLACK, tot_max_temp - temps[j].cur_temp, tot_max_temp, 5);
+ drawBar_reversed(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, tot_max_temp - temps[j].cur_temp, tot_max_temp, 5);
}
}
- if ((!all) || ((cycle == SCREEN_TEMP) && ((submode) || (timer/PAUSE) == SCREEN_TEMP))) {
+ if ((!all) || (info_cycle == SCREEN_TEMP)) {
char extension[16];
sprintf(tmpstr, " ");
- for (j = 0; j < i; j++) {
- if ((j + 1) != i) {
+ for (j = 0; j < count; j++) {
+ if ((j + 1) != count) {
sprintf(extension, "Temp%d %3.f\xb0 | ", j + 1, temps[j].cur_temp);
} else {
sprintf(extension, "Temp%d %3.f\xb0 ", j + 1, temps[j].cur_temp);
@@ -942,15 +958,59 @@
}
}
-void print_info_label(g15canvas *canvas) {
- int my_cycle = cycle;
+void calc_info_cycle(void) {
+ static int timer = -1;
+ info_cycle = cycle;
timer++;
if (!submode) {
- my_cycle = -1;
+ switch ((int) (timer / PAUSE)) {
+ case SCREEN_CPU:
+ info_cycle = SCREEN_CPU;
+ break;
+ case SCREEN_MEM:
+ info_cycle = SCREEN_MEM;
+ break;
+ case SCREEN_SWAP:
+ info_cycle = SCREEN_SWAP;
+ break;
+ case SCREEN_NET:
+ if (have_nic) {
+ info_cycle = SCREEN_NET;
+ break;
+ }
+ timer += PAUSE;
+ case SCREEN_BAT:
+ if (have_bat) {
+ info_cycle = SCREEN_BAT;
+ break;
+ }
+ timer += PAUSE;
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ info_cycle = SCREEN_TEMP;
+ break;
+ }
+ timer += PAUSE;
+ case SCREEN_FREQ:
+ if (have_freq) {
+ info_cycle = SCREEN_FREQ;
+ break;
+ }
+ timer += PAUSE;
+ case SCREEN_TIME:
+ info_cycle = SCREEN_TIME;
+ break;
+ default:
+ timer = 0;
+ info_cycle = SCREEN_CPU;
+ break;
+ }
}
+}
- switch (my_cycle) {
+void print_info_label(g15canvas *canvas) {
+ switch (info_cycle) {
case SCREEN_CPU:
print_sys_load_info(canvas);
break;
@@ -964,59 +1024,21 @@
print_net_info(canvas);
break;
case SCREEN_BAT:
- //draw_bat_screen(canvas, 0);
+ if (cycle != SCREEN_BAT) {
+ draw_bat_screen(canvas, 0);
+ }
break;
case SCREEN_TEMP:
- //draw_temp_screen(canvas, 0);
- break;
- default:
- switch (timer / PAUSE) {
- case SCREEN_CPU:
- print_sys_load_info(canvas);
- break;
- case SCREEN_MEM:
- print_mem_info(canvas);
- break;
- case SCREEN_SWAP:
- print_swap_info(canvas);
- break;
- case SCREEN_NET:
- print_net_info(canvas);
- break;
- case SCREEN_BAT:
- if (have_bat) {
- if (cycle != SCREEN_BAT)
- draw_bat_screen(canvas, 0);
- break;
- } else {
- timer += PAUSE;
- }
- case SCREEN_TEMP:
- if (have_sensor) {
- if (cycle != SCREEN_TEMP)
- draw_temp_screen(canvas, 0);
- break;
- } else {
- timer += PAUSE;
- }
- case SCREEN_FREQ:
- if (have_freq) {
- if (cycle != SCREEN_FREQ)
- print_freq_info(canvas);
- break;
- } else {
- timer += PAUSE;
- }
- case SCREEN_TIME:
- print_time_info(canvas);
- break;
- default:
- timer=0;
- print_sys_load_info(canvas);
- break;
-
+ if (cycle != SCREEN_TEMP) {
+ draw_temp_screen(canvas, 0);
}
break;
+ case SCREEN_FREQ:
+ print_freq_info(canvas);
+ break;
+ case SCREEN_TIME:
+ print_time_info(canvas);
+ break;
}
}
@@ -1048,68 +1070,71 @@
submode++;
change++;
}
- if (cycle<0)
- {
- if(have_sensor) {
- cycle=MAX_SCREENS;
- } else {
- cycle=MAX_SCREENS - 1;
+
+ if (change) {
+ change = 0;
+ if (cycle < 0) {
+ if (have_sensor) {
+ cycle = MAX_SCREENS;
+ } else if (have_bat) {
+ cycle = SCREEN_BAT;
+ } else if (have_nic) {
+ cycle = SCREEN_NET;
+ } else {
+ cycle = SCREEN_SWAP;
+ }
}
- }
- if (direction == DIRECTION_UP)
- {
- switch (cycle) {
- case SCREEN_NET:
- if (have_nic) {
- break;
- }
- cycle++;
- case SCREEN_BAT:
- if (have_bat) {
- break;
- }
- cycle++;
- case SCREEN_TEMP:
- if (have_sensor) {
- break;
- }
- cycle++;
+ if (direction == DIRECTION_UP) {
+ switch (cycle) {
+ case SCREEN_NET:
+ if (have_nic) {
+ break;
+ }
+ cycle++;
+ case SCREEN_BAT:
+ if (have_bat) {
+ break;
+ }
+ cycle++;
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ break;
+ }
+ cycle++;
+ }
+ } else if (direction == DIRECTION_DOWN) {
+ switch (cycle) {
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ break;
+ }
+ cycle--;
+ case SCREEN_BAT:
+ if (have_bat) {
+ break;
+ }
+ cycle--;
+ case SCREEN_NET:
+ if (have_nic) {
+ break;
+ }
+ cycle--;
+ }
}
- } else if (direction == DIRECTION_DOWN){
- switch (cycle) {
- case SCREEN_TEMP:
- if (have_sensor) {
- break;
- }
- cycle--;
- case SCREEN_BAT:
- if (have_bat) {
- break;
- }
- cycle--;
- case SCREEN_NET:
- if (have_nic) {
- break;
- }
- cycle--;
+ if (cycle > MAX_SCREENS) {
+ //Wrap around the apps
+ cycle = 0;
}
- }
- if (cycle > MAX_SCREENS) {
- //Wrap around the apps
- cycle = 0;
- }
- if (mode > MAX_MODE) {
- mode = 0;
- }
+ if (mode > MAX_MODE) {
+ mode = 0;
+ }
- if (submode > MAX_SUB_MODE) {
- submode = 0;
- }
+ if (submode > MAX_SUB_MODE) {
+ submode = 0;
+ }
- if (change) {
pthread_cond_broadcast(&wake_now);
- change = 0;
}
usleep(100 * 900);
}
@@ -1256,7 +1281,7 @@
pthread_create(&net_thread,NULL,(void*)network_watch,&interface);
while(1) {
-
+ calc_info_cycle();
switch (cycle) {
case SCREEN_CPU:
draw_cpu_screen_multicore(canvas, unicore);
@@ -1271,20 +1296,24 @@
if (have_nic) {
draw_net_screen(canvas, (char*) interface);
break;
- } else
- cycle++;
+ }
+ cycle++;
case SCREEN_BAT:
if (have_bat) {
draw_bat_screen(canvas, 1);
- break;
- } else
- cycle++;
+ if (have_bat) {
+ break;
+ }
+ }
+ cycle++;
case SCREEN_TEMP:
if (have_sensor) {
draw_temp_screen(canvas, 1);
- break;
- } else
- cycle++;
+ if (have_sensor) {
+ break;
+ }
+ }
+ cycle++;
default:
draw_cpu_screen_multicore(canvas, unicore);
cycle = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-06-28 18:57:43
|
Revision: 514
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=514&view=rev
Author: czarnyckm
Date: 2009-06-28 18:57:28 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
- Many fixes, clean up
- Changed version to 1.90
- CPU Frequency use proper sysfs variable
- New Summary Screen indicators
- Network current traffic info in the bottom line
- Refactor CPU variants into separates additional screens: Summary, CPU and CPU Freq.
- New Fan Speed Screen
- After change screen cycle the info bar content is set to the screen default one.
- Net Screen scaling is now controlled with the L4 key
- Force start temperature sensor id with the option -t id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/...)
- Force start fan speed sensor id with the option -f id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/...)
- Force to show temperature [id] in place of the maximal one on the Summary Screen with the option ie -gt 1
(the id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input)
- On the Fan / Temp Screen Current sensor is controlled with the L4 key (on systems with more then one sensor only).
- Every Screen has his own mode now (except Swap, Memory and Battery Screen)
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-14 13:31:49 UTC (rev 513)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-28 18:57:28 UTC (rev 514)
@@ -28,4 +28,19 @@
- Clean up
SVN 513:
- Improve bottom line and keywatch logic
-
+SVN 514:
+- Many fixes, clean up
+- Changed version to 1.90
+- CPU Frequency use proper sysfs variable
+- New Summary Screen indicators
+- Network current traffic info in the bottom line
+- Refactor CPU variants into separates additional screens: Summary, CPU and CPU Freq.
+- New Fan Speed Screen
+- After change screen cycle the info bar content is set to the screen default one.
+- Net Screen scaling is now controlled with the L4 key
+- Force start temperature sensor id with the option -t id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/...)
+- Force start fan speed sensor id with the option -f id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/...)
+- Force to show temperature [id] in place of the maximal one on the Summary Screen with the option ie -gt 1
+ (the id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input)
+- On the Fan / Temp Screen Current sensor is controlled with the L4 key (on systems with more then one sensor only).
+- Every Screen has his own mode now (except Swap, Memory and Battery Screen)
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-06-14 13:31:49 UTC (rev 513)
+++ trunk/g15daemon-clients/g15stats/README 2009-06-28 18:57:28 UTC (rev 514)
@@ -1,12 +1,15 @@
-G15Stats - a CPU/Memory/Swap/Network/Battery usage meter for G15Daemon.
+G15Stats - a CPU/Memory/Swap/Network/Battery/Temperature/Fan Speed/CPU Frequencies usage meter for G15Daemon.
-This first version of G15Stats requires libgtop development packages to be
-installed before compilation.
+The G15Stats requires libgtop development packages to be installed before compilation.
Features:
-CPU Screen displays graphs of User/System/Nice and Idle time, along with frequency,
-LoadAVG and Uptime.
+Summary Screen displays 4 or 5 indicators from CPU/Frequency/Memory/NET/Temperature/Fan Speed/Swap,
+ along with current time.
+CPU Screen displays graphs of User/System/Nice and Idle time, along with LoadAVG and Uptime.
+
+Frequency Screen displays all CPU cores frequency with the total
+
Memory Screen displays Memory Total & Free, and graph of Used vs
Buffered+Cached Memory.
@@ -17,8 +20,10 @@
Battery Status Screen displays battery charge data for up to three batteries
-Temperature Screen displays temperature current status for up to three sensors
+Temperature Screen displays temperature status for available sensors
+Fan Speed Screen displays fan current speed for the available sensors
+
Options:
-i interface Gather statistics from named interface (ie -i eth0)
-d Run in background (daemonise)
@@ -26,9 +31,14 @@
default is to scale against the highest peak in the current graph.
-h Show help
-u Display unicore graphs only on the CPU screen
--s id Force to monitor temperature sensor id (ie -s 1)
+-t id Force to monitor temperature sensor id on start (ie -t 1)
The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input
- Default the sensor id is autoetected.
+ Default the sensor id is auto-detected.
+-f id Force to monitor fan speed sensor id on start (ie -f 1)
+ The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/fan1_input
+ Default the sensor id is auto-detected.
+-gt id Show temperature [id] in place of the maximal one on the Summary Screen with the option -gt id ie -gt 1
+ The id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input
Usage:
$> g15stats
@@ -37,7 +47,7 @@
L2: Previous Screen
L3: Next Screen
-L4: Alternative Screen (Work at this moment with the CPU Screen only)
+L4: Alternative Screen (Doesn't work on Swap, Memory and Battery Screen)
L5: Bottom Info bar mode
BUGS:
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2009-06-14 13:31:49 UTC (rev 513)
+++ trunk/g15daemon-clients/g15stats/configure.in 2009-06-28 18:57:28 UTC (rev 514)
@@ -1,7 +1,7 @@
AC_INIT(g15stats,[1.1], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.1
+VERSION=1.90
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-14 13:31:49 UTC (rev 513)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-28 18:57:28 UTC (rev 514)
@@ -24,7 +24,7 @@
and arbitrates LCD display. Allows for multiple simultaneous clients.
Client screens can be cycled through by pressing the 'L1' key.
-This is a simple stats client showing graphs for CPU, MEM & Swap usage, Network traffic and Battery life.
+This is a simple stats client showing graphs for CPU, MEM & Swap usage, Network traffic, Temperatures, CPU Frequency and Battery life.
*/
#define _GNU_SOURCE 1
@@ -58,32 +58,53 @@
int g15screen_fd;
-int cycle = 0;
-int info_cycle = 0;
+int cycle = 0;
+int info_cycle = 0;
/** Holds the mode type variable of the application running */
-int mode = 0;
+int mode[MAX_SCREENS];
/** Holds the sub mode type variable of the application running */
-int submode = 0;
+int submode = 0;
-int have_freq = 1;
-int have_sensor = 1;
-int have_bat = 1;
-int have_nic = 0;
+int info_cycle_timer = -1;
-int sensor_id = 0;
+// Summary Screen indicators count 4 or 5
+int summary_rows = 4;
+int have_freq = 2;
+_Bool have_temp = 1;
+_Bool have_fan = 1;
+_Bool have_bat = 1;
+_Bool have_nic = 0;
+
+_Bool sensor_type_temp[MAX_SENSOR];
+_Bool sensor_type_fan[MAX_SENSOR];
+
+_Bool sensor_lost_temp[MAX_SENSOR];
+_Bool sensor_lost_fan[MAX_SENSOR];
+
+int sensor_temp_id = 0;
+int sensor_temp_main = 0;
+
+int sensor_fan_id = 0;
+
/** Holds the number of the cpus */
int ncpu;
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
-unsigned long net_max_in=0;
-unsigned long net_max_out=0;
+unsigned long net_max_in = 100;
+unsigned long net_max_out = 100;
-unsigned long previous_in;
-unsigned long previous_out;
+unsigned long net_cur_in = 0;
+unsigned long net_cur_out = 0;
+float temp_tot_cur = 1;
+float temp_tot_max = 1;
+
+float fan_tot_cur = 1;
+float fan_tot_max = 1;
+
_Bool net_scale_absolute=0;
pthread_cond_t wake_now = PTHREAD_COND_INITIALIZER;
@@ -94,31 +115,55 @@
return b;
}
+void format_float(char *tmpstr, char *format_less, char * format_great, float value){
+ if (value < 9.9) {
+ sprintf(tmpstr,format_less,value);
+ } else {
+ sprintf(tmpstr,format_great,(unsigned long)value);
+ }
+}
+
+char * show_bytes_short(unsigned long bytes) {
+ static char tmpstr[32];
+ if(bytes>=1024*1024) {
+ format_float(tmpstr, "%4.1fM","%4liM", (float)bytes / (1024*1024));
+ }
+ else if(bytes >= 1024) {
+ format_float(tmpstr, "%4.1fk","%4lik", (float)bytes / 1024);
+ }
+ else {
+ sprintf(tmpstr,"%4liB",bytes);
+ }
+ return tmpstr;
+}
+
+
char * show_bytes(unsigned long bytes) {
static char tmpstr[32];
- if(bytes>1024*1024) {
- bytes = bytes / (1024*1024);
- sprintf(tmpstr,"%liMb",bytes);
+ if(bytes>=1024*1024) {
+ format_float(tmpstr, "%2.1fMB","%liMB", (float)bytes / (1024*1024));
}
- else if(bytes<1024*1024 && bytes > 1024) {
- bytes = bytes / 1024;
- sprintf(tmpstr,"%likb",bytes);
+ else if(bytes >= 1024) {
+ format_float(tmpstr, "%2.1fMB","%likB", (float)bytes / 1024);
}
- else if(bytes<1024) {
- sprintf(tmpstr,"%lib",bytes);
+ else {
+ sprintf(tmpstr,"%liB",bytes);
}
return tmpstr;
}
-char * show_hertz_logic(int hertz, char * hz) {
+char * show_hertz_logic(int hertz, char *hz) {
static char tmpstr[32];
- if (hertz > 1000000) {
- sprintf(tmpstr, " %3.1fG%s", ((float)hertz / 1000000), hz);
- } else if (hertz > 1000) {
- sprintf(tmpstr, " %3.fM%s", ((float)hertz / 1000), hz);
+ if (hertz >= 1000000) {
+ format_float(tmpstr, "%3.1fG","%3.fG", (float)hertz / 1000000);
+ } else if (hertz >= 1000) {
+ format_float(tmpstr, "%3.1fM","%3liM", (float)hertz / 1000);
} else {
- sprintf(tmpstr, " %3iK%s", hertz, hz);
+ sprintf(tmpstr, "%3iK", hertz);
}
+ if (strlen((char *)hz) > 0) {
+ strcat(tmpstr, hz);
+ }
return tmpstr;
}
@@ -130,6 +175,42 @@
return show_hertz_logic(hertz, "Hz");
}
+void print_vert_label_logic(g15canvas *canvas, char *label, unsigned int sx){
+ int i;
+ int len =strlen((char *)label);
+ if (len > 5) {
+ len = 5;
+ }
+ int starty = 0;
+ int incy = 0;
+ switch (len){
+ case 6 :
+ break;
+ case 5 :
+ starty = 0;
+ break;
+ case 4 :
+ starty = 4;
+ break;
+ case 3 :
+ starty = 3;
+ incy = 4;
+ break;
+ default :
+ return;
+ }
+ char val[2];
+ for (i=0; i<len; i++) {
+ memcpy (val, &(label[i]), 1);
+ val[1] = '\0';
+ g15r_renderString (canvas, (unsigned char*)val, i, G15_TEXT_MED, sx, starty+(i*incy));
+ }
+}
+
+void print_vert_label(g15canvas *canvas, char *label){
+ print_vert_label_logic(canvas, label, TEXT_RIGHT);
+}
+
void drawBar_reversed (g15canvas * canvas, int x1, int y1, int x2, int y2, int color,
int num, int max, int type)
{
@@ -177,6 +258,21 @@
}
}
+void drawBar_both(g15canvas *canvas, int y1, int y2, int bar_current, int bar_total, int rbar_current, int rbar_total) {
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, bar_current, bar_total, 4);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, rbar_current, rbar_total, 5);
+}
+
+void drawLine_both(g15canvas *canvas, int y1, int y2) {
+ g15r_drawLine(canvas, VL_LEFT, y1, VL_LEFT, y2, G15_COLOR_BLACK);
+ g15r_drawLine(canvas, VL_LEFT + 1, y1, VL_LEFT + 1, y2, G15_COLOR_BLACK);
+}
+
+void drawAll_both(g15canvas *canvas, int y1, int y2, int bar_current, int bar_total, int rbar_current, int rbar_total) {
+ drawBar_both(canvas, y1, y2, bar_current, bar_total, rbar_current, rbar_total);
+ drawLine_both(canvas, y1, y2);
+}
+
int daemonise(int nochdir, int noclose) {
pid_t pid;
@@ -221,10 +317,10 @@
}
}
-int get_sysfs_value(char * filename) {
- static int ret_val = -1;
+int get_sysfs_value(char *filename) {
+ int ret_val = -1;
FILE *fd_main;
- char tmpstr [MAX_LINES];
+ static char tmpstr [MAX_LINES];
fd_main = fopen(filename, "r");
if (fd_main != NULL) {
@@ -239,17 +335,28 @@
return ret_val;
}
-int get_processor_freq(char * which, int core) {
- char tmpstr [MAX_LINES];
+int get_processor_freq(char *which, int core) {
+ static char tmpstr [MAX_LINES];
sprintf(tmpstr, "/sys/devices/system/cpu/cpu%d/cpufreq/%s", core, which);
return get_sysfs_value(tmpstr);
}
int get_cpu_freq_cur(int core) {
- int ret_val = get_processor_freq("cpuinfo_cur_freq", core);
+ int ret_val;
+ switch (have_freq) {
+ case 2:
+ ret_val = get_processor_freq("scaling_cur_freq", core);
+ break;
+ default:
+ ret_val = get_processor_freq("cpuinfo_%s_freq", core);
+ break;
+ }
if ((!core) && (ret_val == SENSOR_ERROR)) {
- have_freq = 0;
- printf("Frequency sensor doesn't appear to exist with id=%d . ", sensor_id);
+ have_freq--;
+ if (have_freq < 0) {
+ have_freq = 0;
+ }
+ printf("Frequency sensor doesn't appear to exist for core=%d . ", core);
}
return ret_val;
}
@@ -262,12 +369,32 @@
return get_processor_freq("cpuinfo_min_freq", core);
}
-int get_temp(char * which, int id) {
+int get_hwmon(int sensor_id, char *sensor, char *which, int id, _Bool sensor_type) {
char tmpstr [MAX_LINES];
- sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_%s", sensor_id, id, which);
+ if(sensor_type) {
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/%s%d_%s", sensor_id, sensor, id, which);
+ } else {
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/%s%d_%s", sensor_id, sensor, id, which);
+ }
return get_sysfs_value(tmpstr);
}
+int get_fan(char *which, int id) {
+ return get_hwmon(sensor_fan_id, "fan", which, id, sensor_type_fan[sensor_fan_id]);
+}
+
+int get_fan_cur(int id) {
+ return get_fan("input", id);
+}
+
+int get_fan_max(int id) {
+ return get_fan("alarm", id);
+}
+
+int get_temp(char *which, int id) {
+ return get_hwmon(sensor_temp_id, "temp", which, id, sensor_type_temp[sensor_temp_id]);
+}
+
int get_temp_cur(int id) {
return get_temp("input", id);
}
@@ -276,8 +403,120 @@
return get_temp("max", id);
}
-void print_sys_load_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
+int get_next(int sensor_id, _Bool *sensor_lost){
+ int new_sensor_id;
+ new_sensor_id = sensor_id;
+ do {
+ new_sensor_id++;
+ if (new_sensor_id >= MAX_SENSOR) {
+ new_sensor_id = 0;
+ }
+ if (!sensor_lost[new_sensor_id]){
+ return new_sensor_id;
+ }
+ } while(sensor_id != new_sensor_id);
+ return SENSOR_ERROR;
+}
+
+int get_temperature(g15_stats_info *temps) {
+ int count = 0;
+ temp_tot_cur = 0;
+
+ for (count = 0; count < NUM_TEMP; count++) {
+ if ((temps[count].cur = get_temp_cur(count + 1)) == SENSOR_ERROR) {
+ break;
+ }
+ temps[count].cur /= 1000;
+ temps[count].max = get_temp_max(count + 1);
+ temps[count].max /= 1000;
+
+ if (temp_tot_max < temps[count].max) {
+ temp_tot_max = temps[count].max;
+ }
+
+ if ((sensor_temp_main == (count +1)) || ((!sensor_temp_main) && (temp_tot_cur <temps[count].cur))) {
+ temp_tot_cur = temps[count].cur;
+ }
+ }
+ if ((!count) && (temps[0].cur == SENSOR_ERROR)) {
+ if (sensor_type_temp[sensor_temp_id]) {
+ sensor_lost_temp[sensor_temp_id] = 1;
+ printf("Temperature sensor doesn't appear to exist with id=%d .\n", sensor_temp_id);
+ sensor_temp_id = get_next(sensor_temp_id, sensor_lost_temp);
+ if (sensor_temp_id != SENSOR_ERROR) {
+ return get_temperature(temps);
+ }
+ } else {
+ sensor_type_temp[sensor_temp_id] = 1;
+ return get_temperature(temps);
+ }
+
+ if (sensor_temp_id == SENSOR_ERROR) {
+ have_temp = 0;
+ printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
+ return 0;
+ }
+ }
+
+ if (count >= NUM_TEMP) {
+ count = NUM_TEMP;
+ } else if(temps[count].cur != SENSOR_ERROR) {
+ count++;
+ }
+ return count;
+}
+
+int get_fans(g15_stats_info *fans) {
+ int count = 0;
+ fan_tot_cur = 0;
+ for (count = 0; count < NUM_FAN; count++) {
+
+ if ((fans[count].cur = get_fan_cur(count + 1)) == SENSOR_ERROR) {
+ break;
+ }
+ fans[count].max = get_fan_max(count + 1);
+
+ if (fan_tot_max < fans[count].max) {
+ fan_tot_max = fans[count].max;
+ }
+
+ if (fan_tot_cur <fans[count].cur) {
+ fan_tot_cur = fans[count].cur;
+ }
+
+ if (fan_tot_max < fan_tot_cur) {
+ fan_tot_max = (fan_tot_cur * 1.2);
+ }
+ }
+ if ((!count) && (fans[count].cur == SENSOR_ERROR)) {
+ if (sensor_type_fan[sensor_fan_id]) {
+ sensor_lost_fan[sensor_fan_id] = 1;
+ printf("Fan sensor doesn't appear to exist with id=%d .\n", sensor_fan_id);
+ sensor_fan_id = get_next(sensor_fan_id, sensor_lost_fan);
+ if (sensor_fan_id != SENSOR_ERROR) {
+ return get_fans(fans);
+ }
+ } else {
+ sensor_type_fan[sensor_fan_id] = 1;
+ return get_fans(fans);
+ }
+ if (sensor_fan_id == SENSOR_ERROR) {
+ have_fan = 0;
+ printf("Fan sensor doesn't appear to exist. Fan screen will be disabled.\n");
+ return 0;
+ }
+
+ }
+
+ if (count >= NUM_FAN) {
+ count = NUM_FAN;
+ } else if(fans[count].cur != SENSOR_ERROR) {
+ count++;
+ }
+ return count;
+}
+
+void print_sys_load_info(g15canvas *canvas, char *tmpstr) {
glibtop_loadavg loadavg;
glibtop_uptime uptime;
@@ -294,76 +533,73 @@
hours=(int)hours-(days*24);
sprintf(tmpstr,"LoadAVG %.2f %.2f %.2f | Uptime %.fd%.fh",loadavg.loadavg[0],loadavg.loadavg[1],loadavg.loadavg[2],days,hours);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void print_mem_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
+void print_mem_info(g15canvas *canvas, char *tmpstr) {
glibtop_mem mem;
glibtop_get_mem(&mem);
- sprintf(tmpstr,"Memory Used %dMb | Memory Total %dMb",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ sprintf(tmpstr,"Memory Used %dMB | Memory Total %dMB",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void print_swap_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
+void print_swap_info(g15canvas *canvas, char *tmpstr) {
glibtop_swap swap;
glibtop_get_swap(&swap);
- sprintf(tmpstr,"Swap Used %dMb | Swap Avail. %dMb",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ sprintf(tmpstr,"Swap Used %dMB | Swap Avail. %dMB",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void print_net_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
+void print_net_peak_info(g15canvas *canvas, char *tmpstr) {
sprintf(tmpstr,"Peak IN %s/s|",show_bytes(net_max_in));
strcat(tmpstr,"Peak OUT ");
strcat(tmpstr,show_bytes(net_max_out));
strcat(tmpstr,"/s");
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void print_freq_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
- int normal = 1;
+void print_net_current_info(g15canvas *canvas, char *tmpstr) {
+ sprintf(tmpstr,"Current IN %s/s|",show_bytes(net_cur_in));
+ strcat(tmpstr,"Current OUT ");
+ strcat(tmpstr,show_bytes(net_cur_out));
+ strcat(tmpstr,"/s");
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
+}
+
+void print_freq_info(g15canvas *canvas, char *tmpstr) {
+ char proc[12];
int core;
init_cpu_count();
- if (ncpu < 5) {
- sprintf(tmpstr, "%s", "CPU ");
- } else if (ncpu > 5) {
- normal = 0;
- sprintf(tmpstr, "%s", "");
- } else {
- sprintf(tmpstr, "%s", "");
- }
+ sprintf(tmpstr, "%s", "");
- for (core = 0; core < ncpu; core++) {
- if (normal) {
+ for (core = 0; (core < ncpu) && (core < 6); core++) {
+ sprintf(proc, "C%d ", core);
+ strcat(tmpstr,proc);
+ if (ncpu < 5) {
strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
} else {
strcat(tmpstr, show_hertz_short(get_cpu_freq_cur(core)));
}
if ((core + 1) < ncpu) {
- strcat(tmpstr, " |");
+ strcat(tmpstr, "|");
}
}
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, BOTTOM_ROW);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW);
}
-void print_time_info(g15canvas *canvas){
- char tmpstr[MAX_LINES];
+void print_time_info(g15canvas *canvas, char *tmpstr){
time_t now;
time(&now);
sprintf(tmpstr,"%s",ctime(&now));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void draw_mem_screen(g15canvas *canvas) {
+void draw_mem_screen(g15canvas *canvas, char *tmpstr) {
glibtop_mem mem;
- char tmpstr[MAX_LINES];
glibtop_get_mem(&mem);
@@ -387,18 +623,13 @@
g15r_drawBar(canvas,BAR_START,23,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,mem_cached,mem_total,4);
drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,mem_free,mem_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
+ drawLine_both(canvas, 1, BAR_BOTTOM);
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
+ print_vert_label(canvas, "FREE");
}
-void draw_swap_screen(g15canvas *canvas) {
+void draw_swap_screen(g15canvas *canvas, char *tmpstr) {
glibtop_swap swap;
- char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -411,25 +642,131 @@
sprintf(tmpstr,"Used %i%%",(unsigned int)(((float)swap_used/(float)swap_total)*100));
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 19);
- g15r_drawBar(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,swap_used,swap_total,4);
+ drawAll_both(canvas, 1, BAR_BOTTOM, swap_used, swap_total, swap_total-swap_used, swap_total);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,swap_total-swap_used,swap_total,5);
+ print_vert_label(canvas, "FREE");
+}
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
+void print_label(g15canvas *canvas, char *tmpstr, int cur_shift) {
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, cur_shift + 1);
+}
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
+void draw_summary_screen(g15canvas *canvas, char *tmpstr, int y1, int y2, int shift, int id) {
+ // Memory section
+ glibtop_mem mem;
+ glibtop_get_mem(&mem);
+ int mem_total = (mem.total / 1024);
+ int mem_used = mem_total - (mem.free / 1024);
+
+ int cur_shift = shift * id;
+
+ int y;
+ int last_y;
+ int j;
+ int step;
+ int count;
+
+ // Memory section
+ sprintf(tmpstr, "MEM %3.f%%", ((float) (mem_used) / (float) mem_total)*100);
+ print_label(canvas, tmpstr, cur_shift);
+
+ drawAll_both(canvas, cur_shift + y1, cur_shift + y2, mem_used + 1, mem_total, mem_total - mem_used, mem_total);
+
+ id++;
+ cur_shift += shift;
+
+ // Network section
+ if (have_nic) {
+ y = y2 / 2;
+
+ drawLine_both(canvas, cur_shift + y1, cur_shift + y2);
+ drawBar_both(canvas, cur_shift + y1, cur_shift + y, net_cur_in + 1, net_max_in, net_max_in - net_cur_in, net_max_in);
+
+ if ((y * 2) < y2) {
+ y++;
+ }
+
+ drawBar_both(canvas, cur_shift + y, cur_shift + y2, net_cur_out + 1, net_max_out, net_max_out - net_cur_out, net_max_out);
+
+ if (net_cur_in > net_cur_out) {
+ sprintf(tmpstr, "IN %s", show_bytes_short((int) net_cur_in));
+ } else {
+ sprintf(tmpstr, "OUT%s", show_bytes_short((int) net_cur_out));
+ }
+ print_label(canvas, tmpstr, cur_shift);
+
+ id++;
+ cur_shift += shift;
+ }
+ // Temperature section
+ if ((have_temp) && (id < summary_rows)) {
+ g15_stats_info sensors[NUM_FAN];
+ count = get_temperature(sensors);
+ if ((count) && (have_temp)) {
+ j = 0;
+ step = (int) (y2 / count);
+ y = cur_shift + y1;
+ for (j = 0; j < count; j++) {
+ last_y = y;
+ y += step;
+ drawBar_both(canvas, last_y, y, sensors[j].cur + 1, temp_tot_max, temp_tot_max - sensors[j].cur, temp_tot_max);
+ }
+ drawLine_both(canvas, cur_shift + y1, y);
+
+ sprintf(tmpstr, "TEM %3.f\xb0", temp_tot_cur);
+ print_label(canvas, tmpstr, cur_shift);
+
+ id++;
+ cur_shift += shift;
+ }
+ }
+
+ // Fan section
+ if ((have_fan) && (id < summary_rows)) {
+ g15_stats_info sensors[NUM_FAN];
+ count = get_fans(sensors);
+ if ((count) && (have_fan)) {
+ j = 0;
+ step = (int) (y2 / count);
+ y = cur_shift + y1;
+ for (j = 0; j < count; j++) {
+ last_y = y;
+ y += step;
+ drawBar_both(canvas, last_y, y, sensors[j].cur + 1, fan_tot_max, fan_tot_max - sensors[j].cur, fan_tot_max);
+ }
+ drawLine_both(canvas, cur_shift + y1, y);
+
+ sprintf(tmpstr, "RPM%5.f", fan_tot_cur);
+ print_label(canvas, tmpstr, cur_shift);
+
+ id++;
+ cur_shift += shift;
+ }
+ }
+
+ // Swap section
+ if (id < summary_rows) {
+ glibtop_swap swap;
+
+ glibtop_get_swap(&swap);
+
+ int swap_used = swap.used / 1024;
+ int swap_total = swap.total / 1024;
+
+ drawAll_both(canvas, cur_shift + y1, cur_shift + y2, swap_used, swap_total, swap_total - swap_used, swap_total);
+
+ sprintf(tmpstr, "Swp %3i%%", (unsigned int) (((float) swap_used / (float) swap_total)*100));
+ print_label(canvas, tmpstr, cur_shift);
+
+ id++;
+ cur_shift += shift;
+ }
}
-
/* draw cpu screen. if drawgraph = 0 then no graph is drawn */
-void draw_cpu_screen_unicore_logic(g15canvas *canvas, glibtop_cpu cpu, int drawgraph, int printlabels, int cpuandmemory) {
+void draw_cpu_screen_unicore_logic(g15canvas *canvas, glibtop_cpu cpu, char *tmpstr, int drawgraph, int printlabels, int cpuandmemory) {
int total,user,nice,sys,idle;
int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait,last_irq;
- char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -469,35 +806,29 @@
g15r_drawBar(canvas,BAR_START,23,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,b_nice+1,b_total,4);
drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,b_idle+1,b_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
+ drawLine_both(canvas, 1, BAR_BOTTOM);
}
if (cpuandmemory) {
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 3);
- g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 3);
- g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 3);
- g15r_...
[truncated message content] |
|
From: <cza...@us...> - 2009-06-29 22:43:16
|
Revision: 515
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=515&view=rev
Author: czarnyckm
Date: 2009-06-29 22:42:13 +0000 (Mon, 29 Jun 2009)
Log Message:
-----------
- Fixed temperature / fan sensor lost
- Fixed screen cycle
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-28 18:57:28 UTC (rev 514)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-29 22:42:13 UTC (rev 515)
@@ -44,3 +44,6 @@
(the id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input)
- On the Fan / Temp Screen Current sensor is controlled with the L4 key (on systems with more then one sensor only).
- Every Screen has his own mode now (except Swap, Memory and Battery Screen)
+SVN 515:
+- Fixed temperature / fan sensor lost
+- Fixed screen cycle
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-28 18:57:28 UTC (rev 514)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-29 22:42:13 UTC (rev 515)
@@ -79,8 +79,8 @@
_Bool sensor_type_temp[MAX_SENSOR];
_Bool sensor_type_fan[MAX_SENSOR];
-_Bool sensor_lost_temp[MAX_SENSOR];
-_Bool sensor_lost_fan[MAX_SENSOR];
+int sensor_lost_temp[MAX_SENSOR];
+int sensor_lost_fan[MAX_SENSOR];
int sensor_temp_id = 0;
int sensor_temp_main = 0;
@@ -144,7 +144,7 @@
format_float(tmpstr, "%2.1fMB","%liMB", (float)bytes / (1024*1024));
}
else if(bytes >= 1024) {
- format_float(tmpstr, "%2.1fMB","%likB", (float)bytes / 1024);
+ format_float(tmpstr, "%2.1fkB","%likB", (float)bytes / 1024);
}
else {
sprintf(tmpstr,"%liB",bytes);
@@ -403,7 +403,7 @@
return get_temp("max", id);
}
-int get_next(int sensor_id, _Bool *sensor_lost){
+int get_next(int sensor_id, int *sensor_lost){
int new_sensor_id;
new_sensor_id = sensor_id;
do {
@@ -411,7 +411,7 @@
if (new_sensor_id >= MAX_SENSOR) {
new_sensor_id = 0;
}
- if (!sensor_lost[new_sensor_id]){
+ if (sensor_lost[new_sensor_id]){
return new_sensor_id;
}
} while(sensor_id != new_sensor_id);
@@ -440,7 +440,10 @@
}
if ((!count) && (temps[0].cur == SENSOR_ERROR)) {
if (sensor_type_temp[sensor_temp_id]) {
- sensor_lost_temp[sensor_temp_id] = 1;
+ sensor_lost_temp[sensor_temp_id]--;
+ if(sensor_lost_temp[sensor_temp_id] < 0) {
+ sensor_lost_temp[sensor_temp_id] = 0;
+ }
printf("Temperature sensor doesn't appear to exist with id=%d .\n", sensor_temp_id);
sensor_temp_id = get_next(sensor_temp_id, sensor_lost_temp);
if (sensor_temp_id != SENSOR_ERROR) {
@@ -470,7 +473,6 @@
int count = 0;
fan_tot_cur = 0;
for (count = 0; count < NUM_FAN; count++) {
-
if ((fans[count].cur = get_fan_cur(count + 1)) == SENSOR_ERROR) {
break;
}
@@ -488,9 +490,13 @@
fan_tot_max = (fan_tot_cur * 1.2);
}
}
- if ((!count) && (fans[count].cur == SENSOR_ERROR)) {
+ if ((!count) && (fans[0].cur == SENSOR_ERROR)) {
if (sensor_type_fan[sensor_fan_id]) {
- sensor_lost_fan[sensor_fan_id] = 1;
+ sensor_lost_fan[sensor_fan_id]--;
+ if(sensor_lost_fan[sensor_fan_id] < 0) {
+ sensor_lost_fan[sensor_fan_id] = 0;
+ }
+
printf("Fan sensor doesn't appear to exist with id=%d .\n", sensor_fan_id);
sensor_fan_id = get_next(sensor_fan_id, sensor_lost_fan);
if (sensor_fan_id != SENSOR_ERROR) {
@@ -1271,6 +1277,8 @@
if ((!count) || (temps[0].cur == SENSOR_ERROR)) {
return;
+ } else {
+ sensor_lost_temp[sensor_temp_id] = 10;
}
int j = 0;
@@ -1314,6 +1322,8 @@
if ((!count) || (fans[0].cur == SENSOR_ERROR)) {
return;
+ } else {
+ sensor_lost_fan[sensor_fan_id] = 10;
}
int j = 0;
@@ -1326,8 +1336,6 @@
g15r_clearScreen(canvas, G15_COLOR_WHITE);
print_vert_label(canvas, "RPM");
-
-
for (j = 0; j < count; j++) {
register int bar_top = (j * shift) + 1 + j;
register int bar_bottom = ((j + 1)*shift) + j;
@@ -1508,7 +1516,7 @@
if (have_fan) {
break;
}
- cycle++;
+ cycle = 0;
break;
}
info_cycle_timer = cycle * PAUSE;
@@ -1760,6 +1768,11 @@
if(have_nic==1)
pthread_create(&net_thread,NULL,(void*)network_watch,&interface);
+ for (i=0;i<MAX_SENSOR;i++) {
+ sensor_lost_fan[i] = 1;
+ sensor_lost_temp[i] = 1;
+ }
+
int cycle_old = cycle;
while(1) {
calc_info_cycle();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-07-11 23:17:20
|
Revision: 516
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=516&view=rev
Author: czarnyckm
Date: 2009-07-11 23:17:13 +0000 (Sat, 11 Jul 2009)
Log Message:
-----------
- Refactored temperature and fan speed - share the logic
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-29 22:42:13 UTC (rev 515)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-11 23:17:13 UTC (rev 516)
@@ -47,3 +47,5 @@
SVN 515:
- Fixed temperature / fan sensor lost
- Fixed screen cycle
+SVN 516:
+- Refactored temperature and fan speed - share the logic
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2009-06-29 22:42:13 UTC (rev 515)
+++ trunk/g15daemon-clients/g15stats/configure.in 2009-07-11 23:17:13 UTC (rev 516)
@@ -1,7 +1,7 @@
AC_INIT(g15stats,[1.1], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.90
+VERSION=1.91
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-29 22:42:13 UTC (rev 515)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-11 23:17:13 UTC (rev 516)
@@ -16,7 +16,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(c) 2008-2009 Mike Lampard
-(c) 2009 Piotr Czarnecki
$Revision$ - $Date$ $Author$
@@ -348,7 +347,7 @@
ret_val = get_processor_freq("scaling_cur_freq", core);
break;
default:
- ret_val = get_processor_freq("cpuinfo_%s_freq", core);
+ ret_val = get_processor_freq("cpuinfo_%d_freq", core);
break;
}
if ((!core) && (ret_val == SENSOR_ERROR)) {
@@ -379,30 +378,22 @@
return get_sysfs_value(tmpstr);
}
-int get_fan(char *which, int id) {
- return get_hwmon(sensor_fan_id, "fan", which, id, sensor_type_fan[sensor_fan_id]);
+int get_sensor_cur(int id, int screen_id) {
+ if (screen_id == SCREEN_TEMP) {
+ return get_hwmon(sensor_temp_id, "temp", "input", id, sensor_type_temp[sensor_temp_id]);
+ } else {
+ return get_hwmon(sensor_fan_id, "fan", "input", id, sensor_type_fan[sensor_fan_id]);
+ }
}
-int get_fan_cur(int id) {
- return get_fan("input", id);
+int get_sensor_max(int id, int screen_id) {
+ if (screen_id == SCREEN_TEMP) {
+ return get_hwmon(sensor_temp_id, "temp", "max", id, sensor_type_temp[sensor_temp_id]);
+ } else {
+ return get_hwmon(sensor_fan_id, "fan", "alarm", id, sensor_type_fan[sensor_fan_id]);
+ }
}
-int get_fan_max(int id) {
- return get_fan("alarm", id);
-}
-
-int get_temp(char *which, int id) {
- return get_hwmon(sensor_temp_id, "temp", which, id, sensor_type_temp[sensor_temp_id]);
-}
-
-int get_temp_cur(int id) {
- return get_temp("input", id);
-}
-
-int get_temp_max(int id) {
- return get_temp("max", id);
-}
-
int get_next(int sensor_id, int *sensor_lost){
int new_sensor_id;
new_sensor_id = sensor_id;
@@ -418,105 +409,78 @@
return SENSOR_ERROR;
}
-int get_temperature(g15_stats_info *temps) {
+int get_sensors(g15_stats_info *sensors, int screen_id, _Bool *sensor_type, int *sensor_lost, int sensor_id) {
+ char label[16];
int count = 0;
- temp_tot_cur = 0;
-
- for (count = 0; count < NUM_TEMP; count++) {
- if ((temps[count].cur = get_temp_cur(count + 1)) == SENSOR_ERROR) {
- break;
- }
- temps[count].cur /= 1000;
- temps[count].max = get_temp_max(count + 1);
- temps[count].max /= 1000;
- if (temp_tot_max < temps[count].max) {
- temp_tot_max = temps[count].max;
- }
-
- if ((sensor_temp_main == (count +1)) || ((!sensor_temp_main) && (temp_tot_cur <temps[count].cur))) {
- temp_tot_cur = temps[count].cur;
- }
+ if (screen_id == SCREEN_TEMP) {
+ temp_tot_cur = 0;
+ sprintf(label, "Temperature");
+ } else { //SCREEN_FAN
+ fan_tot_cur = 0;
+ sprintf(label, "Fan");
}
- if ((!count) && (temps[0].cur == SENSOR_ERROR)) {
- if (sensor_type_temp[sensor_temp_id]) {
- sensor_lost_temp[sensor_temp_id]--;
- if(sensor_lost_temp[sensor_temp_id] < 0) {
- sensor_lost_temp[sensor_temp_id] = 0;
- }
- printf("Temperature sensor doesn't appear to exist with id=%d .\n", sensor_temp_id);
- sensor_temp_id = get_next(sensor_temp_id, sensor_lost_temp);
- if (sensor_temp_id != SENSOR_ERROR) {
- return get_temperature(temps);
- }
- } else {
- sensor_type_temp[sensor_temp_id] = 1;
- return get_temperature(temps);
- }
-
- if (sensor_temp_id == SENSOR_ERROR) {
- have_temp = 0;
- printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
- return 0;
- }
- }
- if (count >= NUM_TEMP) {
- count = NUM_TEMP;
- } else if(temps[count].cur != SENSOR_ERROR) {
- count++;
- }
- return count;
-}
-
-int get_fans(g15_stats_info *fans) {
- int count = 0;
- fan_tot_cur = 0;
- for (count = 0; count < NUM_FAN; count++) {
- if ((fans[count].cur = get_fan_cur(count + 1)) == SENSOR_ERROR) {
+ for (count = 0; count < NUM_PROBES; count++) {
+ if ((sensors[count].cur = get_sensor_cur(count + 1, screen_id)) == SENSOR_ERROR) {
break;
}
- fans[count].max = get_fan_max(count + 1);
+ sensors[count].max = get_sensor_max(count + 1, screen_id);
- if (fan_tot_max < fans[count].max) {
- fan_tot_max = fans[count].max;
- }
+ if (screen_id == SCREEN_TEMP) {
+ sensors[count].cur /= 1000;
+ sensors[count].max /= 1000;
+ if (temp_tot_max < sensors[count].max) {
+ temp_tot_max = sensors[count].max;
+ }
+ if ((sensor_temp_main == (count +1)) || ((!sensor_temp_main) && (temp_tot_cur < sensors[count].cur))) {
+ temp_tot_cur = sensors[count].cur;
+ }
+ } else { //SCREEN_FAN
+ if (fan_tot_cur <sensors[count].cur) {
+ fan_tot_cur = sensors[count].cur;
+ }
- if (fan_tot_cur <fans[count].cur) {
- fan_tot_cur = fans[count].cur;
+ if (fan_tot_max < fan_tot_cur) {
+ fan_tot_max = (fan_tot_cur * 1.2);
+ }
}
-
- if (fan_tot_max < fan_tot_cur) {
- fan_tot_max = (fan_tot_cur * 1.2);
- }
}
- if ((!count) && (fans[0].cur == SENSOR_ERROR)) {
- if (sensor_type_fan[sensor_fan_id]) {
- sensor_lost_fan[sensor_fan_id]--;
- if(sensor_lost_fan[sensor_fan_id] < 0) {
- sensor_lost_fan[sensor_fan_id] = 0;
+ if ((!count) && (sensors[0].cur == SENSOR_ERROR)) {
+ if (sensor_type[sensor_id]) {
+ sensor_lost[sensor_id]--;
+ if(sensor_lost[sensor_id] < 0) {
+ sensor_lost[sensor_id] = 0;
}
-
- printf("Fan sensor doesn't appear to exist with id=%d .\n", sensor_fan_id);
- sensor_fan_id = get_next(sensor_fan_id, sensor_lost_fan);
- if (sensor_fan_id != SENSOR_ERROR) {
- return get_fans(fans);
+ printf("%s sensor doesn't appear to exist with id=%d .\n", label, sensor_id);
+ sensor_id = get_next(sensor_id, sensor_lost);
+ if (screen_id == SCREEN_TEMP) {
+ sensor_temp_id = sensor_id;
+ } else { //SCREEN_FAN
+ sensor_fan_id = sensor_id;
}
+ if (sensor_id != SENSOR_ERROR) {
+ return get_sensors(sensors, screen_id, sensor_type, sensor_lost, sensor_id);
+ }
} else {
- sensor_type_fan[sensor_fan_id] = 1;
- return get_fans(fans);
+ sensor_type[sensor_id] = 1;
+ return get_sensors(sensors, screen_id, sensor_type, sensor_lost, sensor_id);
}
- if (sensor_fan_id == SENSOR_ERROR) {
- have_fan = 0;
- printf("Fan sensor doesn't appear to exist. Fan screen will be disabled.\n");
+
+ if (sensor_id == SENSOR_ERROR) {
+ if (screen_id == SCREEN_TEMP) {
+ have_temp = 0;
+ } else { //SCREEN_FAN
+ have_fan = 0;
+ }
+ printf("%s sensor doesn't appear to exist. %s screen will be disabled.\n", label, label);
return 0;
}
-
}
- if (count >= NUM_FAN) {
- count = NUM_FAN;
- } else if(fans[count].cur != SENSOR_ERROR) {
+ if (count >= NUM_PROBES) {
+ count = NUM_PROBES;
+ } else if(sensors[count].cur != SENSOR_ERROR) {
count++;
}
return count;
@@ -657,19 +621,37 @@
g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, cur_shift + 1);
}
+void draw_summary_sensors_logic(g15canvas *canvas, char *tmpstr, g15_stats_info *sensors, char *label, int y1, int y2, int cur_shift, int shift, int count, float tot_cur, float tot_max) {
+ if (count) {
+ int j = 0;
+ int step = (int) (y2 / count);
+ int y = cur_shift + y1;
+ int last_y;
+ for (j = 0; j < count; j++) {
+ last_y = y;
+ y += step;
+ drawBar_both(canvas, last_y, y, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max);
+ }
+ drawLine_both(canvas, cur_shift + y1, y);
+
+ sprintf(tmpstr, label, tot_cur);
+ print_label(canvas, tmpstr, cur_shift);
+
+ cur_shift += shift;
+ }
+}
+
void draw_summary_screen(g15canvas *canvas, char *tmpstr, int y1, int y2, int shift, int id) {
// Memory section
glibtop_mem mem;
glibtop_get_mem(&mem);
+
int mem_total = (mem.total / 1024);
int mem_used = mem_total - (mem.free / 1024);
int cur_shift = shift * id;
int y;
- int last_y;
- int j;
- int step;
int count;
// Memory section
@@ -704,49 +686,26 @@
id++;
cur_shift += shift;
}
- // Temperature section
- if ((have_temp) && (id < summary_rows)) {
- g15_stats_info sensors[NUM_FAN];
- count = get_temperature(sensors);
- if ((count) && (have_temp)) {
- j = 0;
- step = (int) (y2 / count);
- y = cur_shift + y1;
- for (j = 0; j < count; j++) {
- last_y = y;
- y += step;
- drawBar_both(canvas, last_y, y, sensors[j].cur + 1, temp_tot_max, temp_tot_max - sensors[j].cur, temp_tot_max);
+ if ((have_temp) || (have_fan)) {
+ g15_stats_info sensors[NUM_PROBES];
+ // Temperature section
+ if ((have_temp) && (id < summary_rows)) {
+ count = get_sensors(sensors, SCREEN_TEMP, sensor_type_temp, sensor_lost_temp, sensor_temp_id);
+ if ((count) && (have_temp)) {
+ draw_summary_sensors_logic(canvas, tmpstr, sensors, "TEM %3.f\xb0", y1, y2, cur_shift, shift, count, temp_tot_cur, temp_tot_max);
+ id++;
+ cur_shift += shift;
}
- drawLine_both(canvas, cur_shift + y1, y);
-
- sprintf(tmpstr, "TEM %3.f\xb0", temp_tot_cur);
- print_label(canvas, tmpstr, cur_shift);
-
- id++;
- cur_shift += shift;
}
- }
- // Fan section
- if ((have_fan) && (id < summary_rows)) {
- g15_stats_info sensors[NUM_FAN];
- count = get_fans(sensors);
- if ((count) && (have_fan)) {
- j = 0;
- step = (int) (y2 / count);
- y = cur_shift + y1;
- for (j = 0; j < count; j++) {
- last_y = y;
- y += step;
- drawBar_both(canvas, last_y, y, sensors[j].cur + 1, fan_tot_max, fan_tot_max - sensors[j].cur, fan_tot_max);
+ // Fan section
+ if ((have_fan) && (id < summary_rows)) {
+ count = get_sensors(sensors, SCREEN_FAN, sensor_type_fan, sensor_lost_fan, sensor_fan_id);
+ if ((count) && (have_fan)) {
+ draw_summary_sensors_logic(canvas, tmpstr, sensors, "RPM%5.f", y1, y2, cur_shift, shift, count, fan_tot_cur, fan_tot_max);
+ id++;
+ cur_shift += shift;
}
- drawLine_both(canvas, cur_shift + y1, y);
-
- sprintf(tmpstr, "RPM%5.f", fan_tot_cur);
- print_label(canvas, tmpstr, cur_shift);
-
- id++;
- cur_shift += shift;
}
}
@@ -840,6 +799,7 @@
int total,user,nice,sys,idle;
int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
+ int sub_val;
static int last_total[GLIBTOP_NCPU],last_user[GLIBTOP_NCPU],last_nice[GLIBTOP_NCPU],
last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],last_irq[GLIBTOP_NCPU];
@@ -1008,14 +968,15 @@
case SCREEN_CPU:
if (mode[SCREEN_CPU]) {
divider = 9 / ncpu;
- g15r_drawBar(canvas, BAR_START, (divider * core), BAR_END, (divider + (divider * (core))), G15_COLOR_BLACK, b_user + 1, b_total, 4);
- g15r_drawBar(canvas, BAR_START, shift + (divider * (core)), BAR_END, shift + (divider + (divider * (core))), G15_COLOR_BLACK, b_sys + 1, b_total, 4);
+ sub_val = divider * core;
+ g15r_drawBar(canvas, BAR_START, sub_val, BAR_END, divider + sub_val, G15_COLOR_BLACK, b_user + 1, b_total, 4);
+ g15r_drawBar(canvas, BAR_START, shift + sub_val, BAR_END, shift + divider + sub_val, G15_COLOR_BLACK, b_sys + 1, b_total, 4);
y1 = 0;
- y2 = shift2 + (divider + (divider * (core)));
- g15r_drawBar(canvas, BAR_START, shift2 + (divider * (core)), BAR_END, y2, G15_COLOR_BLACK, b_nice + 1, b_total, 4);
+ y2 = shift2 + divider + sub_val;
+ g15r_drawBar(canvas, BAR_START, shift2 + sub_val, BAR_END, y2, G15_COLOR_BLACK, b_nice + 1, b_total, 4);
divider = y2 / ncpu;
- drawBar_reversed(canvas, BAR_START, (divider * core), BAR_END, y2, G15_COLOR_BLACK, b_idle + 1, b_total, 5);
+ drawBar_reversed(canvas, BAR_START, sub_val, BAR_END, y2, G15_COLOR_BLACK, b_idle + 1, b_total, 5);
} else {
current_value = b_total - b_idle;
drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total);
@@ -1271,14 +1232,14 @@
}
}
-void draw_temp_screen(g15canvas *canvas, char *tmpstr, int all) {
- static g15_stats_info temps[NUM_TEMP];
- int count = get_temperature(temps);
-
- if ((!count) || (temps[0].cur == SENSOR_ERROR)) {
+void draw_g15_stats_info_screen_logic(g15canvas *canvas, char *tmpstr, int all, int screen_type,
+ g15_stats_info *probes, int count, float tot_max, int *sensor_lost, int sensor_id,
+ char *vert_label, char *format_main, char *format_bottom) {
+
+ if ((!count) || (probes[0].cur == SENSOR_ERROR)) {
return;
} else {
- sensor_lost_temp[sensor_temp_id] = 10;
+ sensor_lost[sensor_id] = 10;
}
int j = 0;
@@ -1289,23 +1250,23 @@
if (count) {
if (all) {
g15r_clearScreen(canvas, G15_COLOR_WHITE);
- print_vert_label(canvas, "TEMP");
+ print_vert_label(canvas, vert_label);
for (j = 0; j < count; j++) {
register int bar_top = (j * shift) + 1 + j;
register int bar_bottom = ((j + 1)*shift) + j;
- sprintf(tmpstr, "t-%d %3.f\xb0", j + 1, temps[j].cur);
+ sprintf(tmpstr, format_main, j + 1, probes[j].cur);
g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + 1);
- drawBar_both(canvas, bar_top, bar_bottom, temps[j].cur + 1, temp_tot_max, temp_tot_max - temps[j].cur, temp_tot_max);
+ drawBar_both(canvas, bar_top, bar_bottom, probes[j].cur + 1, tot_max, tot_max - probes[j].cur, tot_max);
}
drawLine_both(canvas, 1, ((j*shift) + j-1));
}
- if ((!all) || (info_cycle == SCREEN_TEMP)) {
+ if ((!all) || (info_cycle == screen_type)) {
char extension[16];
- sprintf(tmpstr, " ");
+ tmpstr[0] = '\0';
for (j = 0; j < count; j++) {
- sprintf(extension, "temp%d %1.f\xb0 ", j + 1, temps[j].cur);
+ sprintf(extension, format_bottom, j + 1, probes[j].cur);
if (j) {
strcat(tmpstr, "| ");
}
@@ -1316,49 +1277,23 @@
}
}
-void draw_fan_screen(g15canvas *canvas, char *tmpstr, int all) {
- static g15_stats_info fans[NUM_FAN];
- int count = get_fans(fans);
-
- if ((!count) || (fans[0].cur == SENSOR_ERROR)) {
- return;
- } else {
- sensor_lost_fan[sensor_fan_id] = 10;
+void draw_g15_stats_info_screen(g15canvas *canvas, char *tmpstr, int all, int screen_type) {
+ static g15_stats_info probes[NUM_PROBES];
+ int count;
+ switch (screen_type) {
+ case SCREEN_TEMP:
+ count = get_sensors(probes, SCREEN_TEMP, sensor_type_temp, sensor_lost_temp, sensor_temp_id);
+ draw_g15_stats_info_screen_logic(canvas, tmpstr, all, screen_type, probes,
+ count, temp_tot_max, sensor_lost_temp, sensor_temp_id, "TEMP", "t-%d %3.f\xb0", "temp%d %1.f\xb0 ");
+ break;
+ case SCREEN_FAN:
+ count = get_sensors(probes, SCREEN_FAN, sensor_type_fan, sensor_lost_fan, sensor_fan_id);
+ draw_g15_stats_info_screen_logic(canvas, tmpstr, all, screen_type, probes,
+ count, fan_tot_max, sensor_lost_fan, sensor_fan_id, "RPM", "F-%d%5.f", "Fan%d %1.f ");
+ break;
+ default:
+ break;
}
-
- int j = 0;
-
- int shift;
- shift = 32 / count;
-
- if (count) {
- if (all) {
- g15r_clearScreen(canvas, G15_COLOR_WHITE);
- print_vert_label(canvas, "RPM");
-
- for (j = 0; j < count; j++) {
- register int bar_top = (j * shift) + 1 + j;
- register int bar_bottom = ((j + 1)*shift) + j;
- sprintf(tmpstr, "F-%d%5.f", j + 1, fans[j].cur);
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + 1);
- drawBar_both(canvas, bar_top, bar_bottom, fans[j].cur + 1, fan_tot_max, fan_tot_max - fans[j].cur, fan_tot_max);
- }
- drawLine_both(canvas, 1, ((j*shift) + j-1));
- }
-
- if ((!all) || (info_cycle == SCREEN_FAN)) {
- char extension[16];
- sprintf(tmpstr, " ");
- for (j = 0; j < count; j++) {
- sprintf(extension, "Fan%d %1.f ", j + 1, fans[j].cur);
- if (j) {
- strcat(tmpstr, "| ");
- }
- strcat(tmpstr, extension);
- }
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW);
- }
- }
}
void calc_info_cycle(void) {
@@ -1450,12 +1385,12 @@
break;
case SCREEN_TEMP :
if (cycle != SCREEN_TEMP) {
- draw_temp_screen(canvas, tmpstr, 0);
+ draw_g15_stats_info_screen(canvas, tmpstr, 0, SCREEN_TEMP);
}
break;
case SCREEN_FAN :
if (cycle != SCREEN_FAN) {
- draw_fan_screen(canvas, tmpstr, 0);
+ draw_g15_stats_info_screen(canvas, tmpstr, 0, SCREEN_FAN);
}
break;
case SCREEN_NET2 :
@@ -1796,7 +1731,7 @@
switch (cycle) {
case SCREEN_FAN:
if (have_fan) {
- draw_fan_screen(canvas, tmpstr, 1);
+ draw_g15_stats_info_screen(canvas, tmpstr, 1, SCREEN_FAN);
if (have_fan) {
break;
}
@@ -1805,7 +1740,7 @@
info_cycle = cycle;
case SCREEN_TEMP:
if (have_temp) {
- draw_temp_screen(canvas, tmpstr, 1);
+ draw_g15_stats_info_screen(canvas, tmpstr, 1, SCREEN_TEMP);
if (have_temp) {
break;
}
@@ -1854,7 +1789,7 @@
info_cycle = cycle;
case SCREEN_TEMP:
if (have_temp) {
- draw_temp_screen(canvas, tmpstr, 1);
+ draw_g15_stats_info_screen(canvas, tmpstr, 1, SCREEN_TEMP);
if (have_temp) {
break;
}
@@ -1863,7 +1798,7 @@
info_cycle = cycle;
case SCREEN_FAN:
if (have_fan) {
- draw_fan_screen(canvas, tmpstr, 1);
+ draw_g15_stats_info_screen(canvas, tmpstr, 1, SCREEN_FAN);
if (have_fan) {
break;
}
@@ -1895,4 +1830,3 @@
free(canvas);
return 0;
}
-
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-29 22:42:13 UTC (rev 515)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-07-11 23:17:13 UTC (rev 516)
@@ -1,7 +1,6 @@
#define TEXT_LEFT 1
#define NUM_BATS 3
-#define NUM_TEMP 4
-#define NUM_FAN 4
+#define NUM_PROBES 4
#define MAX_NET_HIST 107
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-07-12 10:12:27
|
Revision: 517
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=517&view=rev
Author: czarnyckm
Date: 2009-07-12 10:12:21 +0000 (Sun, 12 Jul 2009)
Log Message:
-----------
- Improve Bat Screen deactivation logic
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-11 23:17:13 UTC (rev 516)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-12 10:12:21 UTC (rev 517)
@@ -49,3 +49,5 @@
- Fixed screen cycle
SVN 516:
- Refactored temperature and fan speed - share the logic
+SVN 517:
+- Improve Bat Screen deactivation logic (now is it similar to SVN 515: Fixed temperature / fan sensor lost)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-11 23:17:13 UTC (rev 516)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-12 10:12:21 UTC (rev 517)
@@ -80,6 +80,7 @@
int sensor_lost_temp[MAX_SENSOR];
int sensor_lost_fan[MAX_SENSOR];
+int sensor_lost_bat = 1;
int sensor_temp_id = 0;
int sensor_temp_main = 0;
@@ -1160,10 +1161,15 @@
}
}
- if (!i) {
- printf("Battery sensor doesn't appear to exist. Battery screen will be disabled.\n");
- have_bat = 0;
- return;
+ if (i) {
+ sensor_lost_bat = RETRY_COUNT;
+ } else {
+ sensor_lost_bat--;
+ if (sensor_lost_bat <= 0) {
+ printf("Battery sensor doesn't appear to exist. Battery screen will be disabled.\n");
+ have_bat = 0;
+ return;
+ }
}
if (all) {
@@ -1239,7 +1245,7 @@
if ((!count) || (probes[0].cur == SENSOR_ERROR)) {
return;
} else {
- sensor_lost[sensor_id] = 10;
+ sensor_lost[sensor_id] = RETRY_COUNT;
}
int j = 0;
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2009-07-11 23:17:13 UTC (rev 516)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-07-12 10:12:21 UTC (rev 517)
@@ -10,6 +10,7 @@
#define MAX_SUB_MODE 1
#define PAUSE 6
+#define RETRY_COUNT 10
#define VL_LEFT 42
#define BAR_START 45
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-07-14 19:32:26
|
Revision: 518
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=518&view=rev
Author: czarnyckm
Date: 2009-07-14 19:32:16 +0000 (Tue, 14 Jul 2009)
Log Message:
-----------
- Fix Summary, Freq and CPU Screens for some variants of the cpu cores number
- Improve Summary Screen
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-12 10:12:21 UTC (rev 517)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-14 19:32:16 UTC (rev 518)
@@ -51,3 +51,6 @@
- Refactored temperature and fan speed - share the logic
SVN 517:
- Improve Bat Screen deactivation logic (now is it similar to SVN 515: Fixed temperature / fan sensor lost)
+SVN 518:
+- Fix Summary, Freq and CPU Screens for some variants of the cpu cores number
+- Improve Summary Screen
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-12 10:12:21 UTC (rev 517)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-14 19:32:16 UTC (rev 518)
@@ -622,27 +622,33 @@
g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, cur_shift + 1);
}
-void draw_summary_sensors_logic(g15canvas *canvas, char *tmpstr, g15_stats_info *sensors, char *label, int y1, int y2, int cur_shift, int shift, int count, float tot_cur, float tot_max) {
+void draw_summary_sensors_logic(g15canvas *canvas, char *tmpstr, g15_stats_info *sensors,
+ char *label, int text_shift, int y1, int y2, int move, int cur_shift, int shift, int count, float tot_cur, float tot_max) {
+
if (count) {
int j = 0;
+ int rest;
int step = (int) (y2 / count);
+ rest = y2 - (step * count);
int y = cur_shift + y1;
int last_y;
for (j = 0; j < count; j++) {
last_y = y;
y += step;
- drawBar_both(canvas, last_y, y, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max);
+ if (rest > 0) {
+ rest--;
+ y++;
+ }
+ drawBar_both(canvas, last_y + move, y + move, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max);
}
- drawLine_both(canvas, cur_shift + y1, y);
+ drawLine_both(canvas, cur_shift + y1 + move, y + move);
sprintf(tmpstr, label, tot_cur);
- print_label(canvas, tmpstr, cur_shift);
-
- cur_shift += shift;
+ print_label(canvas, tmpstr, text_shift);
}
}
-void draw_summary_screen(g15canvas *canvas, char *tmpstr, int y1, int y2, int shift, int id) {
+void draw_summary_screen(g15canvas *canvas, char *tmpstr, int y1, int y2, int move, int shift, int text_shift, int id) {
// Memory section
glibtop_mem mem;
glibtop_get_mem(&mem);
@@ -652,14 +658,21 @@
int cur_shift = shift * id;
+ if (mode[SCREEN_SUMMARY]){
+ if (shift > 7) {
+ y2=4;
+ shift=6;
+ }
+ }
+
int y;
int count;
// Memory section
sprintf(tmpstr, "MEM %3.f%%", ((float) (mem_used) / (float) mem_total)*100);
- print_label(canvas, tmpstr, cur_shift);
+ print_label(canvas, tmpstr, text_shift * id);
- drawAll_both(canvas, cur_shift + y1, cur_shift + y2, mem_used + 1, mem_total, mem_total - mem_used, mem_total);
+ drawAll_both(canvas, cur_shift + y1 + move, cur_shift + y2 + move, mem_used + 1, mem_total, mem_total - mem_used, mem_total);
id++;
cur_shift += shift;
@@ -668,21 +681,18 @@
if (have_nic) {
y = y2 / 2;
- drawLine_both(canvas, cur_shift + y1, cur_shift + y2);
- drawBar_both(canvas, cur_shift + y1, cur_shift + y, net_cur_in + 1, net_max_in, net_max_in - net_cur_in, net_max_in);
+ drawLine_both(canvas, cur_shift + y1 + move, cur_shift + y2 + move);
+ 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);
- if ((y * 2) < y2) {
- y++;
- }
+
+ 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);
- drawBar_both(canvas, cur_shift + y, cur_shift + y2, net_cur_out + 1, net_max_out, net_max_out - net_cur_out, net_max_out);
-
if (net_cur_in > net_cur_out) {
sprintf(tmpstr, "IN %s", show_bytes_short((int) net_cur_in));
} else {
sprintf(tmpstr, "OUT%s", show_bytes_short((int) net_cur_out));
}
- print_label(canvas, tmpstr, cur_shift);
+ print_label(canvas, tmpstr, text_shift * id);
id++;
cur_shift += shift;
@@ -693,7 +703,7 @@
if ((have_temp) && (id < summary_rows)) {
count = get_sensors(sensors, SCREEN_TEMP, sensor_type_temp, sensor_lost_temp, sensor_temp_id);
if ((count) && (have_temp)) {
- draw_summary_sensors_logic(canvas, tmpstr, sensors, "TEM %3.f\xb0", y1, y2, cur_shift, shift, count, temp_tot_cur, temp_tot_max);
+ draw_summary_sensors_logic(canvas, tmpstr, sensors, "TEM %3.f\xb0", text_shift * id, y1, y2, move, cur_shift, shift, count, temp_tot_cur, temp_tot_max);
id++;
cur_shift += shift;
}
@@ -703,7 +713,7 @@
if ((have_fan) && (id < summary_rows)) {
count = get_sensors(sensors, SCREEN_FAN, sensor_type_fan, sensor_lost_fan, sensor_fan_id);
if ((count) && (have_fan)) {
- draw_summary_sensors_logic(canvas, tmpstr, sensors, "RPM%5.f", y1, y2, cur_shift, shift, count, fan_tot_cur, fan_tot_max);
+ draw_summary_sensors_logic(canvas, tmpstr, sensors, "RPM%5.f", text_shift * id, y1, y2, move, cur_shift, shift, count, fan_tot_cur, fan_tot_max);
id++;
cur_shift += shift;
}
@@ -719,10 +729,10 @@
int swap_used = swap.used / 1024;
int swap_total = swap.total / 1024;
- drawAll_both(canvas, cur_shift + y1, cur_shift + y2, swap_used, swap_total, swap_total - swap_used, swap_total);
+ drawAll_both(canvas, cur_shift + y1 + move, cur_shift + y2 + move, swap_used, swap_total, swap_total - swap_used, swap_total);
sprintf(tmpstr, "Swp %3i%%", (unsigned int) (((float) swap_used / (float) swap_total)*100));
- print_label(canvas, tmpstr, cur_shift);
+ print_label(canvas, tmpstr, text_shift * id);
id++;
cur_shift += shift;
@@ -836,7 +846,8 @@
float result;
int spacer = 1;
- int height = 8;
+ int height = 9;
+ int move = 0;
switch (cycle) {
case SCREEN_FREQ :
if(ncpu > 11){
@@ -859,32 +870,37 @@
switch (ncpu) {
case 1 :
case 2 :
+ case 3 :
+ case 5 :
+ move = 1;
height = 6;
shift = 7;
shift2 = (2 * shift);
break;
- case 3 :
- height = 6;
- shift = height;
- shift2 = (2 * shift) -1;
+ case 4 :
+ height = 8;
+ shift = 9;
+ shift2 = (2 * shift);
break;
default :
- height = 8;
- shift = 7;
+ height = 7;
+ shift = height;
shift2 = (2 * shift)-1;
break;
}
} else {
summary_rows = 4;
- if (ncpu % 2){
- height = 9;
- shift = height;
- shift2 = (2 * shift)-1;
- } else {
- height = 9;
- shift = height;
- shift2 = (2 * shift);
+ switch (ncpu) {
+ case 3 :
+ case 5 :
+ move = 1;
+ break;
+ default :
+ break;
}
+ height = 8;
+ shift = 9;
+ shift2 = (2 * shift);
}
ncpumax = height;
@@ -931,7 +947,7 @@
case SCREEN_FREQ:
if ((!mode[SCREEN_FREQ]) && (have_freq)) {
freq_cur = get_cpu_freq_cur(core);
- if (ncpu < 6) {
+ if (core < 6) {
result = ((float) (b_total - b_idle) / (float) b_total)*100;
if (result < 100.0) {
sprintf(tmpstr, "%2.f%% %s", result, show_hertz_short(freq_cur));
@@ -941,7 +957,7 @@
if (ncpu < 5) {
g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, y1 + 1);
} else {
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, y1 + 1);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, core * 6);
}
}
freq_total = get_cpu_freq_max(core);
@@ -958,7 +974,7 @@
if (ncpu < 5) {
g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, y1 + 1);
} else {
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, y1 + 1);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, core * 6);
}
}
current_value = b_total - b_idle;
@@ -992,13 +1008,13 @@
break;
case SCREEN_SUMMARY:
current_value = b_total - b_idle;
- drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total);
+ drawBar_both(canvas, y1 + move, y2 + move, current_value, b_total, b_total - current_value, b_total);
if (have_freq) {
freq_cur = get_cpu_freq_cur(core);
freq_total = get_cpu_freq_max(core);
freq_sum = maxi(freq_sum, freq_cur);
- drawBar_both(canvas, shift + y1, shift + y2, freq_cur, freq_total, freq_total - freq_cur, freq_total);
+ drawBar_both(canvas, shift + y1 + move, shift + y2 + move, freq_cur, freq_total, freq_total - freq_cur, freq_total);
}
y1 = 0;
@@ -1006,18 +1022,25 @@
}
}
- drawLine_both(canvas, y1, y2);
+ drawLine_both(canvas, y1 + move, y2 + move);
if (cycle == SCREEN_SUMMARY) {
+ int text_shift;
+ if (summary_rows > 4) {
+ text_shift = 7;
+ } else {
+ text_shift = 9;
+ }
if (have_freq) {
- drawLine_both(canvas, shift + y1, shift + y2);
+ drawLine_both(canvas, shift + y1 + move, shift + y2 + move);
sprintf(tmpstr, "FRQ %s", show_hertz_short((int) freq_sum));
- print_label(canvas, tmpstr, shift);
- draw_summary_screen(canvas, tmpstr, y1, y2, shift, 2);
+ print_label(canvas, tmpstr, text_shift);
+
+ draw_summary_screen(canvas, tmpstr, y1, y2, move, shift, text_shift, 2);
} else {
- draw_summary_screen(canvas, tmpstr, y1, y2, shift, 1);
+ draw_summary_screen(canvas, tmpstr, y1, y2, move, shift, text_shift, 1);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-07-16 22:11:56
|
Revision: 519
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=519&view=rev
Author: czarnyckm
Date: 2009-07-16 22:11:49 +0000 (Thu, 16 Jul 2009)
Log Message:
-----------
- Change default mode for Freq and Summary Screen
- Improve Summary Screen for cpus with more then 7 cores
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-14 19:32:16 UTC (rev 518)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-16 22:11:49 UTC (rev 519)
@@ -44,13 +44,16 @@
(the id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input)
- On the Fan / Temp Screen Current sensor is controlled with the L4 key (on systems with more then one sensor only).
- Every Screen has his own mode now (except Swap, Memory and Battery Screen)
-SVN 515:
+SVN 515 (1.90):
- Fixed temperature / fan sensor lost
- Fixed screen cycle
SVN 516:
- Refactored temperature and fan speed - share the logic
SVN 517:
- Improve Bat Screen deactivation logic (now is it similar to SVN 515: Fixed temperature / fan sensor lost)
-SVN 518:
+SVN 518 (1.91):
- Fix Summary, Freq and CPU Screens for some variants of the cpu cores number
- Improve Summary Screen
+SVN 519
+- Change default mode for Freq and Summary Screen
+- Improve Summary Screen for cpus with more then 7 cores
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2009-07-14 19:32:16 UTC (rev 518)
+++ trunk/g15daemon-clients/g15stats/configure.in 2009-07-16 22:11:49 UTC (rev 519)
@@ -1,7 +1,7 @@
AC_INIT(g15stats,[1.1], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.91
+VERSION=1.92
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-14 19:32:16 UTC (rev 518)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-16 22:11:49 UTC (rev 519)
@@ -658,7 +658,7 @@
int cur_shift = shift * id;
- if (mode[SCREEN_SUMMARY]){
+ if (summary_rows > 4){
if (shift > 7) {
y2=4;
shift=6;
@@ -789,7 +789,7 @@
sprintf(tmpstr,"CPU %3.f%%",((float)(b_total-b_idle)/(float)b_total)*100);
print_label(canvas, tmpstr, 0);
- } else if ((cycle == SCREEN_FREQ) && (!mode[SCREEN_FREQ]) && (have_freq)) {
+ } else if ((cycle == SCREEN_FREQ) && (mode[SCREEN_FREQ]) && (have_freq)) {
print_vert_label(canvas, "FREQ");
} else {
print_vert_label(canvas, "Idle");
@@ -865,28 +865,20 @@
break;
case SCREEN_SUMMARY :
spacer = 0;
- if (mode[SCREEN_SUMMARY]) {
+ if (!mode[SCREEN_SUMMARY]) {
summary_rows = 5;
switch (ncpu) {
case 1 :
case 2 :
case 3 :
case 5 :
+ case 7 :
move = 1;
height = 6;
- shift = 7;
- shift2 = (2 * shift);
break;
- case 4 :
+ default :
height = 8;
- shift = 9;
- shift2 = (2 * shift);
break;
- default :
- height = 7;
- shift = height;
- shift2 = (2 * shift)-1;
- break;
}
} else {
summary_rows = 4;
@@ -895,14 +887,12 @@
case 5 :
move = 1;
break;
- default :
- break;
}
height = 8;
- shift = 9;
- shift2 = (2 * shift);
}
+ shift = height + 1;
+ shift2 = (2 * shift);
ncpumax = height;
break;
}
@@ -945,7 +935,7 @@
switch (cycle) {
case SCREEN_FREQ:
- if ((!mode[SCREEN_FREQ]) && (have_freq)) {
+ if ((mode[SCREEN_FREQ]) && (have_freq)) {
freq_cur = get_cpu_freq_cur(core);
if (core < 6) {
result = ((float) (b_total - b_idle) / (float) b_total)*100;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-07-22 22:24:49
|
Revision: 520
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=520&view=rev
Author: czarnyckm
Date: 2009-07-22 22:24:45 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
- Disable monitoring CPUs frequencies with the option -df
- Improve Summary Screen without CPUs frequencies
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-16 22:11:49 UTC (rev 519)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-07-22 22:24:45 UTC (rev 520)
@@ -57,3 +57,6 @@
SVN 519
- Change default mode for Freq and Summary Screen
- Improve Summary Screen for cpus with more then 7 cores
+SVN 520 (1.9.2)
+- Disable monitoring CPUs frequencies with the option -df
+- Improve Summary Screen without CPUs frequencies
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-07-16 22:11:49 UTC (rev 519)
+++ trunk/g15daemon-clients/g15stats/README 2009-07-22 22:24:45 UTC (rev 520)
@@ -39,6 +39,7 @@
Default the sensor id is auto-detected.
-gt id Show temperature [id] in place of the maximal one on the Summary Screen with the option -gt id ie -gt 1
The id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input
+-df Disable monitoring CPUs frequencies.
Usage:
$> g15stats
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2009-07-16 22:11:49 UTC (rev 519)
+++ trunk/g15daemon-clients/g15stats/configure.in 2009-07-22 22:24:45 UTC (rev 520)
@@ -1,7 +1,7 @@
AC_INIT(g15stats,[1.1], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.92
+VERSION=1.9.2
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-16 22:11:49 UTC (rev 519)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-07-22 22:24:45 UTC (rev 520)
@@ -660,8 +660,13 @@
if (summary_rows > 4){
if (shift > 7) {
- y2=4;
- shift=6;
+ if (id == 2) {
+ y2 = 4;
+ shift = 6;
+ } else {
+ y2 = 5;
+ shift = 7;
+ }
}
}
@@ -860,8 +865,6 @@
spacer = 0;
}
height = 12;
-
- ncpumax = height;
break;
case SCREEN_SUMMARY :
spacer = 0;
@@ -893,10 +896,10 @@
shift = height + 1;
shift2 = (2 * shift);
- ncpumax = height;
break;
}
+ ncpumax = height;
if (ncpumax < ncpu) {
height = (height - ((ncpumax - 1) * spacer)) / (ncpumax);
} else {
@@ -1649,6 +1652,10 @@
net_scale_absolute=1;
}
+ if(0==strncmp(argv[i],"-df",3)||0==strncmp(argv[i],"--disable-freq",14)) {
+ have_freq=0;
+ }
+
if(0==strncmp(argv[i],"-h",2)||0==strncmp(argv[i],"--help",6)) {
printf("%s %s - (c) 2008-2009 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME,VERSION);
printf("Usage: %s [Options]\n", PACKAGE_NAME);
@@ -1665,7 +1672,8 @@
printf("--fan [id] (-f) monitor fans sensor [id] ie -f 1\n"
"\t[id] should point to sysfs path /sys/class/hwmon/hwmon[id]/device/fan1_input\n");
printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n"
- "\tDefault is to scale fullsize, similar to apps like gkrellm.\n\n");
+ "\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
+ printf("--disable-freq (-df) disable monitoring CPUs frequencies.\n\n");
return 0;
}
if(0==strncmp(argv[i],"-i",2)||0==strncmp(argv[i],"--interface",11)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2010-02-17 11:34:20
|
Revision: 530
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=530&view=rev
Author: czarnyckm
Date: 2010-02-17 11:34:11 +0000 (Wed, 17 Feb 2010)
Log Message:
-----------
- Activate the bottom info bar content rotate with the option -ir
- Change bottom info bar content to the component default one
- Activate variable CPUs count with the option -vc
- Improve Fan bottom info
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2010-02-06 18:09:38 UTC (rev 529)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-02-17 11:34:11 UTC (rev 530)
@@ -60,3 +60,8 @@
SVN 520 (1.9.2)
- Disable monitoring CPUs frequencies with the option -df
- Improve Summary Screen without CPUs frequencies
+SVN 530 (1.9.3)
+- Activate the bottom info bar content rotate with the option -ir
+- Change bottom info bar content to the component default one
+- Activate variable CPUs count with the option -vc
+- Improve Fan bottom info
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2010-02-06 18:09:38 UTC (rev 529)
+++ trunk/g15daemon-clients/g15stats/README 2010-02-17 11:34:11 UTC (rev 530)
@@ -40,6 +40,8 @@
-gt id Show temperature [id] in place of the maximal one on the Summary Screen with the option -gt id ie -gt 1
The id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input
-df Disable monitoring CPUs frequencies.
+-ir enable the bottom info bar content rotate cycle over all available sensors
+-vc The cpu cores will be calculated every time (for systems with the cpu hotplug)
Usage:
$> g15stats
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2010-02-06 18:09:38 UTC (rev 529)
+++ trunk/g15daemon-clients/g15stats/configure.in 2010-02-17 11:34:11 UTC (rev 530)
@@ -1,7 +1,7 @@
-AC_INIT(g15stats,[1.1], [mla...@us...])
+AC_INIT(g15stats,[1.9.3], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.9.2
+VERSION=1.9.3
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2010-02-06 18:09:38 UTC (rev 529)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-02-17 11:34:11 UTC (rev 530)
@@ -15,7 +15,7 @@
along with g15daemon; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-(c) 2008-2009 Mike Lampard
+(c) 2008-2010 Mike Lampard
$Revision$ - $Date$ $Author$
@@ -62,7 +62,7 @@
/** Holds the mode type variable of the application running */
int mode[MAX_SCREENS];
/** Holds the sub mode type variable of the application running */
-int submode = 0;
+int submode = 1;
int info_cycle_timer = -1;
@@ -74,6 +74,7 @@
_Bool have_fan = 1;
_Bool have_bat = 1;
_Bool have_nic = 0;
+_Bool variable_cpu = 0;
_Bool sensor_type_temp[MAX_SENSOR];
_Bool sensor_type_fan[MAX_SENSOR];
@@ -305,8 +306,7 @@
}
void init_cpu_count(void) {
- // initialize cpu count once
- if (!ncpu) {
+ if ((variable_cpu) || (!ncpu)) {
const glibtop_sysinfo *cpuinfo = glibtop_get_sysinfo();
if(cpuinfo->ncpu == 0) {
@@ -548,7 +548,7 @@
for (core = 0; (core < ncpu) && (core < 6); core++) {
sprintf(proc, "C%d ", core);
strcat(tmpstr,proc);
- if (ncpu < 5) {
+ if (ncpu < 4) {
strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
} else {
strcat(tmpstr, show_hertz_short(get_cpu_freq_cur(core)));
@@ -1656,8 +1656,16 @@
have_freq=0;
}
+ if(0==strncmp(argv[i],"-rc",3)||0==strncmp(argv[i],"--info-rotate",13)) {
+ submode = 0;
+ }
+
+ if(0==strncmp(argv[i],"-vc",3)||0==strncmp(argv[i],"--variable-cpu",14)) {
+ variable_cpu = 1;
+ }
+
if(0==strncmp(argv[i],"-h",2)||0==strncmp(argv[i],"--help",6)) {
- printf("%s %s - (c) 2008-2009 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME,VERSION);
+ printf("%s %s - (c) 2008-2010 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME,VERSION);
printf("Usage: %s [Options]\n", PACKAGE_NAME);
printf("Options:\n");
printf("--daemon (-d) run in background\n");
@@ -1673,6 +1681,8 @@
"\t[id] should point to sysfs path /sys/class/hwmon/hwmon[id]/device/fan1_input\n");
printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n"
"\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
+ printf("--info-rotate (-ir) enable the bottom info bar content rotate.\n");
+ printf("--variable-cpu (-vc) the cpu cores will be calculated every time (for systems with the cpu hotplug).\n");
printf("--disable-freq (-df) disable monitoring CPUs frequencies.\n\n");
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2010-04-08 16:38:48
|
Revision: 531
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=531&view=rev
Author: czarnyckm
Date: 2010-04-08 16:38:37 +0000 (Thu, 08 Apr 2010)
Log Message:
-----------
- Fix time info
- Improve Fan / Temperature Screens leading labels position
- Improve Fan / Temperature Screens height calculation
- Improve Summary Screen multi bar (temperature and network)
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2010-02-17 11:34:11 UTC (rev 530)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-04-08 16:38:37 UTC (rev 531)
@@ -65,3 +65,8 @@
- Change bottom info bar content to the component default one
- Activate variable CPUs count with the option -vc
- Improve Fan bottom info
+SVN 531 (1.9.4)
+- Fix time info
+- Improve Fan / Temperature Screens leading labels position
+- Improve Fan / Temperature Screens height calculation
+- Improve Summary Screen multi bar (temperature and network)
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2010-02-17 11:34:11 UTC (rev 530)
+++ trunk/g15daemon-clients/g15stats/configure.in 2010-04-08 16:38:37 UTC (rev 531)
@@ -1,7 +1,7 @@
-AC_INIT(g15stats,[1.9.3], [mla...@us...])
+AC_INIT(g15stats,[1.9.4], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.9.3
+VERSION=1.9.4
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2010-02-17 11:34:11 UTC (rev 530)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-04-08 16:38:37 UTC (rev 531)
@@ -566,6 +566,7 @@
time(&now);
sprintf(tmpstr,"%s",ctime(&now));
+ tmpstr[(strlen(tmpstr) - 1)] = '\0';
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
@@ -627,17 +628,23 @@
if (count) {
int j = 0;
- int rest;
- int step = (int) (y2 / count);
+ int rest, step;
+ step = y2 / count;
rest = y2 - (step * count);
int y = cur_shift + y1;
int last_y;
for (j = 0; j < count; j++) {
last_y = y;
+ if( j ) last_y++;
y += step;
if (rest > 0) {
- rest--;
- y++;
+ if ((j+1) < count) {
+ y++;
+ rest--;
+ } else {
+ y += rest;
+ rest = 0;
+ }
}
drawBar_both(canvas, last_y + move, y + move, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max);
}
@@ -687,11 +694,10 @@
y = y2 / 2;
drawLine_both(canvas, cur_shift + y1 + move, cur_shift + y2 + move);
+
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);
+ 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);
-
- 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);
-
if (net_cur_in > net_cur_out) {
sprintf(tmpstr, "IN %s", show_bytes_short((int) net_cur_in));
} else {
@@ -1266,36 +1272,56 @@
int j = 0;
- int shift;
- shift = 32 / count;
+ if (all) {
+ int shift;
+ int info_shift;
- if (count) {
- if (all) {
- g15r_clearScreen(canvas, G15_COLOR_WHITE);
- print_vert_label(canvas, vert_label);
+ shift = BAR_BOTTOM / count;
- for (j = 0; j < count; j++) {
- register int bar_top = (j * shift) + 1 + j;
- register int bar_bottom = ((j + 1)*shift) + j;
- sprintf(tmpstr, format_main, j + 1, probes[j].cur);
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + 1);
- drawBar_both(canvas, bar_top, bar_bottom, probes[j].cur + 1, tot_max, tot_max - probes[j].cur, tot_max);
- }
- drawLine_both(canvas, 1, ((j*shift) + j-1));
+ switch (count) {
+ case 1:
+ info_shift = 14;
+ shift = 33;
+ break;
+ case 2:
+ info_shift = 5;
+ break;
+ case 3:
+ info_shift = 2;
+ shift = 10;
+ break;
+ default:
+ info_shift = 1;
+ break;
}
- if ((!all) || (info_cycle == screen_type)) {
- char extension[16];
- tmpstr[0] = '\0';
- for (j = 0; j < count; j++) {
- sprintf(extension, format_bottom, j + 1, probes[j].cur);
- if (j) {
- strcat(tmpstr, "| ");
- }
- strcat(tmpstr, extension);
+ g15r_clearScreen(canvas, G15_COLOR_WHITE);
+ print_vert_label(canvas, vert_label);
+
+ int bar_top, bar_bottom;
+ bar_bottom = BAR_BOTTOM;
+ for (j = 0; j < count; j++) {
+ bar_top = (j * shift) + 1 + j;
+ bar_bottom = ((j + 1)*shift) + j;
+
+ sprintf(tmpstr, format_main, j + 1, probes[j].cur);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + info_shift);
+ drawBar_both(canvas, bar_top, bar_bottom, probes[j].cur + 1, tot_max, tot_max - probes[j].cur, tot_max);
+ }
+ drawLine_both(canvas, 1, bar_bottom);
+ }
+
+ if ((!all) || (info_cycle == screen_type)) {
+ char extension[16];
+ tmpstr[0] = '\0';
+ for (j = 0; j < count; j++) {
+ sprintf(extension, format_bottom, j + 1, probes[j].cur);
+ if (j) {
+ strcat(tmpstr, "| ");
}
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW);
+ strcat(tmpstr, extension);
}
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2010-10-26 09:11:07
|
Revision: 532
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=532&view=rev
Author: czarnyckm
Date: 2010-10-26 09:11:00 +0000 (Tue, 26 Oct 2010)
Log Message:
-----------
- Improve Summary Screen multi bar (temperature and network)
- Fix compilation with the never version of the glibc
- Improve refresh interval causing -nan error with the never kernel on very fast machines due to too often glibtop probing
- Fix possible -nan error on the fast screens switch
- Change refresh interval with the option -r seconds (The seconds must be between 1 and 300)
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/Makefile.am
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2010-04-08 16:38:37 UTC (rev 531)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-10-26 09:11:00 UTC (rev 532)
@@ -70,3 +70,9 @@
- Improve Fan / Temperature Screens leading labels position
- Improve Fan / Temperature Screens height calculation
- Improve Summary Screen multi bar (temperature and network)
+SVN 532 (1.9.5)
+- Improve Summary Screen multi bar (temperature and network)
+- Fix compilation with the never version of the glibc
+- Improve refresh interval causing -nan error with the never kernel on very fast machines due to too often glibtop probing
+- Fix possible -nan error on the fast screens switch
+- Change refresh interval with the option -r seconds (The seconds must be between 1 and 300)
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/Makefile.am
===================================================================
--- trunk/g15daemon-clients/g15stats/Makefile.am 2010-04-08 16:38:37 UTC (rev 531)
+++ trunk/g15daemon-clients/g15stats/Makefile.am 2010-10-26 09:11:00 UTC (rev 532)
@@ -1,5 +1,5 @@
-AM_CFLAGS = -O3 -Wall @CFLAGS@ -I$(top_builddir) -I$(top_srcdir)
+AM_CFLAGS = -O3 -Wall @CFLAGS@ -I$(top_builddir) -I$(top_srcdir)
METASOURCES = AUTO
bin_PROGRAMS = g15stats
noinst_HEADERS = g15stats.h
@@ -7,7 +7,7 @@
docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
doc_DATA = README ChangeLog AUTHORS NEWS COPYING
-LIBS = -lg15daemon_client -lg15render
+LIBS = -lg15daemon_client -lg15render -lpthread -lm -lrt
IMCLUDES = -I
g15stats_LDFLAGS = -avoid-version
g15stats_SOURCES = g15stats.c g15stats.h
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2010-04-08 16:38:37 UTC (rev 531)
+++ trunk/g15daemon-clients/g15stats/README 2010-10-26 09:11:00 UTC (rev 532)
@@ -30,6 +30,7 @@
-nsa Scale network graphs against highest speed recorded. The
default is to scale against the highest peak in the current graph.
-h Show help
+-r seconds Set the refresh interval to seconds The seconds must be between 1 and 300. ie -r 15
-u Display unicore graphs only on the CPU screen
-t id Force to monitor temperature sensor id on start (ie -t 1)
The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2010-04-08 16:38:37 UTC (rev 531)
+++ trunk/g15daemon-clients/g15stats/configure.in 2010-10-26 09:11:00 UTC (rev 532)
@@ -1,7 +1,7 @@
-AC_INIT(g15stats,[1.9.4], [mla...@us...])
+AC_INIT(g15stats,[1.9.5], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.9.4
+VERSION=1.9.5
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2010-04-08 16:38:37 UTC (rev 531)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-10-26 09:11:00 UTC (rev 532)
@@ -39,6 +39,7 @@
#include <libg15render.h>
#include <sched.h>
#include <sys/socket.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
@@ -70,6 +71,9 @@
int summary_rows = 4;
int have_freq = 2;
+
+int wait_seconds = 1;
+
_Bool have_temp = 1;
_Bool have_fan = 1;
_Bool have_bat = 1;
@@ -635,18 +639,23 @@
int last_y;
for (j = 0; j < count; j++) {
last_y = y;
- if( j ) last_y++;
- y += step;
- if (rest > 0) {
- if ((j+1) < count) {
- y++;
- rest--;
- } else {
- y += rest;
- rest = 0;
+ if( j ) {
+ last_y++;
+ if (rest > 0) {
+ if ((j+1) < count) {
+ y++;
+ last_y++;
+ rest--;
+ } else {
+ y += rest;
+ last_y += rest;
+ rest = 0;
+ }
}
}
+ y += step;
drawBar_both(canvas, last_y + move, y + move, sensors[j].cur + 1, tot_max, tot_max - sensors[j].cur, tot_max);
+
}
drawLine_both(canvas, cur_shift + y1 + move, y + move);
@@ -752,8 +761,8 @@
/* draw cpu screen. if drawgraph = 0 then no graph is drawn */
void draw_cpu_screen_unicore_logic(g15canvas *canvas, glibtop_cpu cpu, char *tmpstr, int drawgraph, int printlabels, int cpuandmemory) {
int total,user,nice,sys,idle;
- int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
- static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait,last_irq;
+ static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait,
+ last_irq,b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -763,21 +772,26 @@
sys = ((unsigned long) cpu.sys) ? ((double) cpu.sys) : 1.0;
idle = ((unsigned long) cpu.idle) ? ((double) cpu.idle) : 1.0;
- b_total = total - last_total;
- b_user = user - last_user;
- b_nice = nice - last_nice;
- b_sys = sys - last_sys;
- b_idle = idle - last_idle;
- b_irq = cpu.irq - last_irq;
- b_iowait= cpu.iowait - last_iowait;
+ if ((total - last_total) > 0) {
+ b_total = total - last_total;
+ b_user = user - last_user;
+ b_nice = nice - last_nice;
+ b_sys = sys - last_sys;
+ b_idle = idle - last_idle;
+ b_irq = cpu.irq - last_irq;
+ b_iowait= cpu.iowait - last_iowait;
- last_total = total;
- last_user = user;
- last_nice = nice;
- last_sys = sys;
- last_idle = idle;
- last_irq = cpu.irq;
- last_iowait = cpu.iowait;
+ last_total = total;
+ last_user = user;
+ last_nice = nice;
+ last_sys = sys;
+ last_idle = idle;
+ last_irq = cpu.irq;
+ last_iowait = cpu.iowait;
+ } else if (b_total == 0) {
+ b_total = 100;
+ b_idle = 100;
+ }
if(printlabels) {
sprintf(tmpstr,"Usr %2.f%%",((float)b_user/(float)b_total)*100);
@@ -820,10 +834,12 @@
int divider = 0;
int total,user,nice,sys,idle;
- int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
int sub_val;
static int last_total[GLIBTOP_NCPU],last_user[GLIBTOP_NCPU],last_nice[GLIBTOP_NCPU],
- last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],last_irq[GLIBTOP_NCPU];
+ last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],
+ last_irq[GLIBTOP_NCPU],b_total[GLIBTOP_NCPU],b_user[GLIBTOP_NCPU],
+ b_nice[GLIBTOP_NCPU],b_sys[GLIBTOP_NCPU],b_idle[GLIBTOP_NCPU],
+ b_irq[GLIBTOP_NCPU],b_iowait[GLIBTOP_NCPU];
init_cpu_count();
@@ -923,21 +939,26 @@
sys = ((unsigned long) cpu.xcpu_sys[core]) ? ((double) cpu.xcpu_sys[core]) : 1.0;
idle = ((unsigned long) cpu.xcpu_idle[core]) ? ((double) cpu.xcpu_idle[core]) : 1.0;
- b_total = total - last_total[core];
- b_user = user - last_user[core];
- b_nice = nice - last_nice[core];
- b_sys = sys - last_sys[core];
- b_idle = idle - last_idle[core];
- b_irq = cpu.xcpu_irq[core] - last_irq[core];
- b_iowait = cpu.xcpu_iowait[core] - last_iowait[core];
+ if ((total - last_total[core]) > 0) {
+ b_total[core] = total - last_total[core];
+ b_user[core] = user - last_user[core];
+ b_nice[core] = nice - last_nice[core];
+ b_sys[core] = sys - last_sys[core];
+ b_idle[core] = idle - last_idle[core];
+ b_irq[core] = cpu.xcpu_irq[core] - last_irq[core];
+ b_iowait[core] = cpu.xcpu_iowait[core] - last_iowait[core];
- last_total[core] = total;
- last_user[core] = user;
- last_nice[core] = nice;
- last_sys[core] = sys;
- last_idle[core] = idle;
- last_irq[core] = cpu.xcpu_irq[core];
- last_iowait[core] = cpu.xcpu_iowait[core];
+ last_total[core] = total;
+ last_user[core] = user;
+ last_nice[core] = nice;
+ last_sys[core] = sys;
+ last_idle[core] = idle;
+ last_irq[core] = cpu.xcpu_irq[core];
+ last_iowait[core] = cpu.xcpu_iowait[core];
+ } else if (b_total[core] == 0){
+ b_total[core] = 100;
+ b_idle[core] = 100;
+ }
y1 = (core * height) + (core * spacer);
y2 = y1 + height - 1;
@@ -947,7 +968,7 @@
if ((mode[SCREEN_FREQ]) && (have_freq)) {
freq_cur = get_cpu_freq_cur(core);
if (core < 6) {
- result = ((float) (b_total - b_idle) / (float) b_total)*100;
+ result = ((float) (b_total[core] - b_idle[core]) / (float) b_total[core])*100;
if (result < 100.0) {
sprintf(tmpstr, "%2.f%% %s", result, show_hertz_short(freq_cur));
} else {
@@ -966,9 +987,9 @@
if (core < 6) {
if (have_freq) {
freq_cur = get_cpu_freq_cur(core);
- sprintf(tmpstr, "%s%3.f%%", show_hertz_short(freq_cur), ((float) (b_total - b_idle) / (float) b_total)*100);
+ sprintf(tmpstr, "%s%3.f%%", show_hertz_short(freq_cur), ((float) (b_total[core] - b_idle[core]) / (float) b_total[core])*100);
} else {
- sprintf(tmpstr, "CPU%.f%3.f%%", (float) core, ((float) (b_total - b_idle) / (float) b_total)*100);
+ sprintf(tmpstr, "CPU%.f%3.f%%", (float) core, ((float) (b_total[core] - b_idle[core]) / (float) b_total[core])*100);
}
if (ncpu < 5) {
g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, y1 + 1);
@@ -976,8 +997,8 @@
g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, core * 6);
}
}
- current_value = b_total - b_idle;
- drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total);
+ current_value = b_total[core] - b_idle[core];
+ drawBar_both(canvas, y1, y2, current_value, b_total[core], b_total[core] - current_value, b_total[core]);
y1 = 0;
}
break;
@@ -985,29 +1006,29 @@
if (mode[SCREEN_CPU]) {
divider = 9 / ncpu;
sub_val = divider * core;
- g15r_drawBar(canvas, BAR_START, sub_val, BAR_END, divider + sub_val, G15_COLOR_BLACK, b_user + 1, b_total, 4);
- g15r_drawBar(canvas, BAR_START, shift + sub_val, BAR_END, shift + divider + sub_val, G15_COLOR_BLACK, b_sys + 1, b_total, 4);
+ g15r_drawBar(canvas, BAR_START, sub_val, BAR_END, divider + sub_val, G15_COLOR_BLACK, b_user[core] + 1, b_total[core], 4);
+ 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);
y1 = 0;
y2 = shift2 + divider + sub_val;
- g15r_drawBar(canvas, BAR_START, shift2 + sub_val, BAR_END, y2, G15_COLOR_BLACK, b_nice + 1, b_total, 4);
+ g15r_drawBar(canvas, BAR_START, shift2 + sub_val, BAR_END, y2, G15_COLOR_BLACK, b_nice[core] + 1, b_total[core], 4);
divider = y2 / ncpu;
- drawBar_reversed(canvas, BAR_START, sub_val, BAR_END, y2, G15_COLOR_BLACK, b_idle + 1, b_total, 5);
+ drawBar_reversed(canvas, BAR_START, sub_val, BAR_END, y2, G15_COLOR_BLACK, b_idle[core] + 1, b_total[core], 5);
} else {
- current_value = b_total - b_idle;
- drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total);
+ current_value = b_total[core] - b_idle[core];
+ drawBar_both(canvas, y1, y2, current_value, b_total[core], b_total[core] - current_value, b_total[core]);
- drawBar_both(canvas, shift + y1, shift + y2, b_sys + 1, b_total, b_total - b_sys, b_total);
+ drawBar_both(canvas, shift + y1, shift + y2, b_sys[core] + 1, b_total[core], b_total[core] - b_sys[core], b_total[core]);
y2 += shift2;
- drawBar_both(canvas, shift2 + y1, y2, b_nice + 1, b_total, b_total - b_nice, b_total);
+ drawBar_both(canvas, shift2 + y1, y2, b_nice[core] + 1, b_total[core], b_total[core] - b_nice[core], b_total[core]);
y1 = 0;
}
break;
case SCREEN_SUMMARY:
- current_value = b_total - b_idle;
- drawBar_both(canvas, y1 + move, y2 + move, current_value, b_total, b_total - current_value, b_total);
+ current_value = b_total[core] - b_idle[core];
+ drawBar_both(canvas, y1 + move, y2 + move, current_value, b_total[core], b_total[core] - current_value, b_total[core]);
if (have_freq) {
freq_cur = get_cpu_freq_cur(core);
@@ -1641,18 +1662,24 @@
/* wait for a max of <seconds> seconds.. if condition &wake_now is received leave immediately */
void g15stats_wait(int seconds) {
pthread_mutex_t dummy_mutex;
+ pthread_mutexattr_t mta;
struct timespec timeout;
/* Create a dummy mutex which doesn't unlock for sure while waiting. */
- pthread_mutex_init(&dummy_mutex, NULL);
+ pthread_mutexattr_init(&mta);
+
+ pthread_mutex_init(&dummy_mutex, &mta);
pthread_mutex_lock(&dummy_mutex);
- time(&timeout.tv_sec);
+ if (clock_gettime(CLOCK_REALTIME, &timeout) != 0) {
+ perror("clock_gettime");
+ }
+
timeout.tv_sec += seconds;
- timeout.tv_nsec = 0L;
pthread_cond_timedwait(&wake_now, &dummy_mutex, &timeout);
pthread_mutex_unlock(&dummy_mutex);
pthread_mutex_destroy(&dummy_mutex);
+ pthread_mutexattr_destroy(&mta);
}
int main(int argc, char *argv[]){
@@ -1709,6 +1736,7 @@
"\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
printf("--info-rotate (-ir) enable the bottom info bar content rotate.\n");
printf("--variable-cpu (-vc) the cpu cores will be calculated every time (for systems with the cpu hotplug).\n");
+ printf("--refresh [seconds] (-r) set the refresh interval to [seconds] The seconds must be between 1 and 300. ie -r 15\n");
printf("--disable-freq (-df) disable monitoring CPUs frequencies.\n\n");
return 0;
}
@@ -1745,6 +1773,16 @@
}
}
}
+
+ if(0==strncmp(argv[i],"-r",2)||0==strncmp(argv[i],"--refresh",9)) {
+ if(argv[i+1]!=NULL) {
+ i++;
+ wait_seconds = atoi(argv[i]);
+ if ((wait_seconds < 1) || (wait_seconds > MAX_INTERVAL)) {
+ wait_seconds = 1;
+ }
+ }
+ }
}
if((g15screen_fd = new_g15_screen(G15_G15RBUF))<0){
printf("Sorry, cant connect to the G15daemon\n");
@@ -1885,7 +1923,7 @@
canvas->mode_xor = 0;
g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN);
- g15stats_wait(1);
+ g15stats_wait(wait_seconds);
}
glibtop_close();
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2010-04-08 16:38:37 UTC (rev 531)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2010-10-26 09:11:00 UTC (rev 532)
@@ -9,6 +9,8 @@
#define MAX_MODE 1
#define MAX_SUB_MODE 1
+#define MAX_INTERVAL 300
+
#define PAUSE 6
#define RETRY_COUNT 10
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2010-12-12 01:18:41
|
Revision: 534
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=534&view=rev
Author: czarnyckm
Date: 2010-12-12 01:18:33 +0000 (Sun, 12 Dec 2010)
Log Message:
-----------
- Improve Summary Screen with 3 and 6 core CPU
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2010-10-26 09:23:31 UTC (rev 533)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-12-12 01:18:33 UTC (rev 534)
@@ -76,3 +76,5 @@
- Improve refresh interval causing -nan error with the newer kernel on very fast machines due to too often glibtop probing
- Fix possible -nan error on the fast screens switch
- Change refresh interval with the option -r seconds (The seconds must be between 1 and 300)
+SVN 533 (1.9.6)
+- Improve Summary Screen with 3 and 6 core CPU
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2010-10-26 09:23:31 UTC (rev 533)
+++ trunk/g15daemon-clients/g15stats/configure.in 2010-12-12 01:18:33 UTC (rev 534)
@@ -1,7 +1,7 @@
-AC_INIT(g15stats,[1.9.5], [mla...@us...])
+AC_INIT(g15stats,[1.9.6], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.9.5
+VERSION=1.9.6
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2010-10-26 09:23:31 UTC (rev 533)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-12-12 01:18:33 UTC (rev 534)
@@ -895,12 +895,15 @@
switch (ncpu) {
case 1 :
case 2 :
- case 3 :
case 5 :
case 7 :
move = 1;
height = 6;
break;
+ case 3 :
+ case 6 :
+ height =6;
+ break;
default :
height = 8;
break;
@@ -913,9 +916,9 @@
move = 1;
break;
}
- height = 8;
- }
-
+ height = 8;
+ }
+
shift = height + 1;
shift2 = (2 * shift);
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2010-12-12 01:30:36
|
Revision: 535
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=535&view=rev
Author: czarnyckm
Date: 2010-12-12 01:30:30 +0000 (Sun, 12 Dec 2010)
Log Message:
-----------
- Fix typo
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2010-12-12 01:18:33 UTC (rev 534)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2010-12-12 01:30:30 UTC (rev 535)
@@ -76,5 +76,5 @@
- Improve refresh interval causing -nan error with the newer kernel on very fast machines due to too often glibtop probing
- Fix possible -nan error on the fast screens switch
- Change refresh interval with the option -r seconds (The seconds must be between 1 and 300)
-SVN 533 (1.9.6)
+SVN 534 (1.9.6)
- Improve Summary Screen with 3 and 6 core CPU
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2010-12-12 01:18:33 UTC (rev 534)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2010-12-12 01:30:30 UTC (rev 535)
@@ -902,7 +902,7 @@
break;
case 3 :
case 6 :
- height =6;
+ height = 6;
break;
default :
height = 8;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2011-04-27 21:23:23
|
Revision: 538
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=538&view=rev
Author: czarnyckm
Date: 2011-04-27 21:23:15 +0000 (Wed, 27 Apr 2011)
Log Message:
-----------
- Improve Summary Screen Fan / Temperature sensors bar calculation
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2011-01-10 09:35:55 UTC (rev 537)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2011-04-27 21:23:15 UTC (rev 538)
@@ -78,3 +78,5 @@
- Change refresh interval with the option -r seconds (The seconds must be between 1 and 300)
SVN 534 (1.9.6)
- Improve Summary Screen with 3 and 6 core CPU
+SVN 538 (1.9.7)
+- Improve Summary Screen Fan / Temperature sensors bar calculation
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2011-01-10 09:35:55 UTC (rev 537)
+++ trunk/g15daemon-clients/g15stats/configure.in 2011-04-27 21:23:15 UTC (rev 538)
@@ -1,4 +1,4 @@
-AC_INIT(g15stats,[1.9.6], [mla...@us...])
+AC_INIT(g15stats,[1.9.7], [mla...@us...])
PACKAGE=g15stats
VERSION=1.9.6
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2011-01-10 09:35:55 UTC (rev 537)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2011-04-27 21:23:15 UTC (rev 538)
@@ -644,11 +644,9 @@
if (rest > 0) {
if ((j+1) < count) {
y++;
- last_y++;
rest--;
} else {
y += rest;
- last_y += rest;
rest = 0;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|