Fri Jan 11 23:31:15 2013 UTC ()
Requires sys/vmmeter.h on NetBSD/current


(joerg)
diff -r1.2 -r1.3 pkgsrc/sysutils/wmSMPmon/distinfo
diff -r1.1.1.1 -r1.2 pkgsrc/sysutils/wmSMPmon/patches/patch-ab

cvs diff -r1.2 -r1.3 pkgsrc/sysutils/wmSMPmon/distinfo (expand / switch to unified diff)

--- pkgsrc/sysutils/wmSMPmon/distinfo 2005/02/24 13:40:59 1.2
+++ pkgsrc/sysutils/wmSMPmon/distinfo 2013/01/11 23:31:14 1.3
@@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
1$NetBSD: distinfo,v 1.2 2005/02/24 13:40:59 agc Exp $ 1$NetBSD: distinfo,v 1.3 2013/01/11 23:31:14 joerg Exp $
2 2
3SHA1 (wmSMPmon-2.3.tar.gz) = 90d6665e7314fd4e5dd21cde5d90abd887e519cf 3SHA1 (wmSMPmon-2.3.tar.gz) = 90d6665e7314fd4e5dd21cde5d90abd887e519cf
4RMD160 (wmSMPmon-2.3.tar.gz) = 2c95b70488d33b811bd261b0cbb4aad26c845e86 4RMD160 (wmSMPmon-2.3.tar.gz) = 2c95b70488d33b811bd261b0cbb4aad26c845e86
5Size (wmSMPmon-2.3.tar.gz) = 16413 bytes 5Size (wmSMPmon-2.3.tar.gz) = 16413 bytes
6SHA1 (patch-aa) = 312453d6f8646453d9676451d182f7cf1d669515 6SHA1 (patch-aa) = 312453d6f8646453d9676451d182f7cf1d669515
7SHA1 (patch-ab) = 362d0fc7a3ed58b84a9ecbf894dac4752f5b8ee0 7SHA1 (patch-ab) = 68275308cf08d2911383f1eeacbdc16e94ad2ed7

cvs diff -r1.1.1.1 -r1.2 pkgsrc/sysutils/wmSMPmon/patches/patch-ab (expand / switch to unified diff)

--- pkgsrc/sysutils/wmSMPmon/patches/patch-ab 2005/01/12 11:52:10 1.1.1.1
+++ pkgsrc/sysutils/wmSMPmon/patches/patch-ab 2013/01/11 23:31:15 1.2
@@ -1,34 +1,42 @@ @@ -1,34 +1,42 @@
1$NetBSD: patch-ab,v 1.1.1.1 2005/01/12 11:52:10 agc Exp $ 1$NetBSD: patch-ab,v 1.2 2013/01/11 23:31:15 joerg Exp $
2 2
3--- wmSMPmon.c.orig 2003-03-10 13:50:11.000000000 +0100 3--- wmSMPmon.c.orig 2003-03-10 12:50:11.000000000 +0000
4+++ wmSMPmon.c 2004-08-25 20:52:07.000000000 +0200 4+++ wmSMPmon.c
5@@ -9,5 +9,4 @@ 5@@ -8,7 +8,6 @@ CONTRIBUTOR: Alain Schröder <alain@parka
 6 This program is covered by GPL.
6 *******************************************************************************/ 7 *******************************************************************************/
7  8
8-#include <linux/sys.h> 9-#include <linux/sys.h>
9 #include <sys/param.h> 10 #include <sys/param.h>
10 #include <sys/types.h> 11 #include <sys/types.h>
11@@ -20,5 +19,8 @@ 12 #include <string.h>
 13@@ -19,7 +18,13 @@ CONTRIBUTOR: Alain Schröder <alain@parka
 14 #include "../wmgeneral/wmgeneral.h"
12 #include "wmSMPmon_master.xpm" 15 #include "wmSMPmon_master.xpm"
13 #include "wmSMPmon_mask.xbm" 16 #include "wmSMPmon_mask.xbm"
14-#include <sys/utsname.h> 17-#include <sys/utsname.h>
15+//#include <sys/utsname.h> 18+//#include <sys/utsname.h>
16+#include <sys/sched.h> 19+#include <sys/sched.h>
17+#include <sys/swap.h> 20+#include <sys/swap.h>
18+#include <sys/sysctl.h> 21+#include <sys/sysctl.h>
 22+#ifdef __NetBSD__
 23+#include <sys/vmmeter.h>
 24+#endif
19  25
20 #define VERSION "2.2" 26 #define VERSION "2.2"
21@@ -35,12 +37,73 @@ 27 #define T_DATA 255
 28@@ -34,14 +39,75 @@ CONTRIBUTOR: Alain Schröder <alain@parka
 29
22 void usage(void) ; 30 void usage(void) ;
23  31
24+int getCpuUsage() { 32+int getCpuUsage() {
25+ int mib[] = { CTL_KERN, KERN_CP_TIME }; 33+ int mib[] = { CTL_KERN, KERN_CP_TIME };
26+ u_int64_t cpu_time[CPUSTATES]; 34+ u_int64_t cpu_time[CPUSTATES];
27+ size_t size = sizeof(cpu_time); 35+ size_t size = sizeof(cpu_time);
28+ int total, used, result; 36+ int total, used, result;
29+ static int pre_total, pre_used; 37+ static int pre_total, pre_used;
30+ 38+
31+ if (sysctl(mib, 2, &cpu_time, &size, NULL, 0) < 0) 39+ if (sysctl(mib, 2, &cpu_time, &size, NULL, 0) < 0)
32+ return 0; 40+ return 0;
33+ used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_NICE] + cpu_time[CP_INTR]; 41+ used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_NICE] + cpu_time[CP_INTR];
34+ total = used + cpu_time[CP_IDLE]; 42+ total = used + cpu_time[CP_IDLE];
@@ -86,36 +94,40 @@ $NetBSD: patch-ab,v 1.1.1.1 2005/01/12 1 @@ -86,36 +94,40 @@ $NetBSD: patch-ab,v 1.1.1.1 2005/01/12 1
86+ return (100 * (double) sused / (double) stotal); 94+ return (100 * (double) sused / (double) stotal);
87+}; 95+};
88+ 96+
89 int main(int argc, char **argv) 97 int main(int argc, char **argv)
90 { 98 {
91 XEvent Event ; 99 XEvent Event ;
92  100
93- unsigned char *t = NULL, 101- unsigned char *t = NULL,
94- *u = NULL, 102- *u = NULL,
95- tmp[192] ; 103- tmp[192] ;
96- 104-
97 unsigned int t0[TAILLE_T], 105 unsigned int t0[TAILLE_T],
98 t1[TAILLE_T], 106 t1[TAILLE_T],
99@@ -57,7 +120,5 @@ 107 tm[TAILLE_T],
 108@@ -56,9 +122,7 @@ int main(int argc, char **argv)
 109 no_swap = FAUX,
100 draw_graph = FAUX ; 110 draw_graph = FAUX ;
101  111
102- unsigned long mem, prec_mem = 0, prec_swap = 0, 112- unsigned long mem, prec_mem = 0, prec_swap = 0,
103- total0o = 0, charge0o = 0,  113- total0o = 0, charge0o = 0,
104- total1o = 0, charge1o = 0, cpu0o=0, cpu1o=0 ; 114- total1o = 0, charge1o = 0, cpu0o=0, cpu1o=0 ;
105+ unsigned long mem, prec_mem = 0, prec_swap = 0; 115+ unsigned long mem, prec_mem = 0, prec_swap = 0;
106  116
107 register unsigned long charge, total, cpu, i = 0 ; 117 register unsigned long charge, total, cpu, i = 0 ;
108@@ -107,97 +168,25 @@ 118
 119@@ -106,99 +170,27 @@ int main(int argc, char **argv)
 120 {
109 if(lecture) 121 if(lecture)
110 { 122 {
111- i = open("/proc/stat", O_RDONLY); 123- i = open("/proc/stat", O_RDONLY);
112- read(i, tmp, 192); 124- read(i, tmp, 192);
113- close(i); 125- close(i);
114-  126-
115- strtok(tmp, "\n"); 127- strtok(tmp, "\n");
116- t = strtok(NULL, "\n"); 128- t = strtok(NULL, "\n");
117- u = strtok(NULL, "\n"); /* For CPU 1 */ 129- u = strtok(NULL, "\n"); /* For CPU 1 */
118-  130-
119- strtok(t, " "); /* CPU 0 */ 131- strtok(t, " "); /* CPU 0 */
120- charge = strtol(strtok(NULL, " "), NULL, 10) +  132- charge = strtol(strtok(NULL, " "), NULL, 10) +
121- strtol(strtok(NULL, " "), NULL, 10) + 133- strtol(strtok(NULL, " "), NULL, 10) +
@@ -214,29 +226,32 @@ $NetBSD: patch-ab,v 1.1.1.1 2005/01/12 1 @@ -214,29 +226,32 @@ $NetBSD: patch-ab,v 1.1.1.1 2005/01/12 1
214+ copyXPMArea(0, 63, (mem * 30 / 100), 8, 29, 39); 226+ copyXPMArea(0, 63, (mem * 30 / 100), 8, 29, 39);
215+ prec_mem = mem; 227+ prec_mem = mem;
216+ } 228+ }
217+ if(!no_swap) { 229+ if(!no_swap) {
218+ mem = getSwapUsage(); 230+ mem = getSwapUsage();
219+ if(mem != prec_swap) { 231+ if(mem != prec_swap) {
220+ copyXPMArea(30, 63, 30, 8, 29, 50); 232+ copyXPMArea(30, 63, 30, 8, 29, 50);
221+ copyXPMArea(0, 63, (mem * 30 / 100), 8, 29, 50); 233+ copyXPMArea(0, 63, (mem * 30 / 100), 8, 29, 50);
222+ prec_swap = mem; 234+ prec_swap = mem;
223+ } 235+ }
224+ } 236+ }
225 if(c2 > DIV2) 237 if(c2 > DIV2)
226 draw_graph = VRAI ; 238 draw_graph = VRAI ;
227@@ -210,10 +199,13 @@ 239 if(draw_graph)
 240@@ -209,12 +201,15 @@ int main(int argc, char **argv)
 241 t1[i - 1] = t1[i] ;
228 tm[i - 1] = tm[i] ; 242 tm[i - 1] = tm[i] ;
229 } 243 }
230- if((t0[TAILLE_T - 1] = cpu0t / c2) > HAUTEUR) 244- if((t0[TAILLE_T - 1] = cpu0t / c2) > HAUTEUR)
231+/* if((t0[TAILLE_T - 1] = cpu0t / c2) > HAUTEUR) 245+/* if((t0[TAILLE_T - 1] = cpu0t / c2) > HAUTEUR)
232 t0[TAILLE_T - 1] = HAUTEUR ; 246 t0[TAILLE_T - 1] = HAUTEUR ;
233 if((t1[TAILLE_T - 1] = cpu1t / c2) > HAUTEUR) 247 if((t1[TAILLE_T - 1] = cpu1t / c2) > HAUTEUR)
234 t1[TAILLE_T - 1] = HAUTEUR ; 248 t1[TAILLE_T - 1] = HAUTEUR ;
235 if((tm[TAILLE_T - 1] = (cpu0t + cpu1t) / (2 * c2)) > HAUTEUR) 249 if((tm[TAILLE_T - 1] = (cpu0t + cpu1t) / (2 * c2)) > HAUTEUR)
236- tm[TAILLE_T - 1] = HAUTEUR ; 250- tm[TAILLE_T - 1] = HAUTEUR ;
237+ tm[TAILLE_T - 1] = HAUTEUR ;*/ 251+ tm[TAILLE_T - 1] = HAUTEUR ;*/
238+ t0[TAILLE_T - 1] = cpu * HAUTEUR / 100; 252+ t0[TAILLE_T - 1] = cpu * HAUTEUR / 100;
239+ t1[TAILLE_T - 1] = cpu * HAUTEUR / 100; 253+ t1[TAILLE_T - 1] = cpu * HAUTEUR / 100;
240+ tm[TAILLE_T - 1] = cpu * HAUTEUR / 100; 254+ tm[TAILLE_T - 1] = cpu * HAUTEUR / 100;
241 cpu0t = 0 ; 255 cpu0t = 0 ;
242 cpu1t = 0 ; 256 cpu1t = 0 ;
 257 switch(etat)