pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/wmSMPmon Initial import of wmSMPmon-2.3 into ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c6830c14973a
branches:  trunk
changeset: 487280:c6830c14973a
user:      agc <agc%pkgsrc.org@localhost>
date:      Wed Jan 12 11:52:09 2005 +0000

description:
Initial import of wmSMPmon-2.3 into the Packages Collection, provided by
Joel CARNAT in PR 28939, minor modifications by myself.

wmSMPmon is a CPU monitoring applet for SMP systems running Window Maker.
(it displays SMP CPU load just fine, despite what it says in the PR).

diffstat:

 sysutils/wmSMPmon/DESCR            |    1 +
 sysutils/wmSMPmon/Makefile         |   20 +++
 sysutils/wmSMPmon/PLIST            |    3 +
 sysutils/wmSMPmon/distinfo         |    6 +
 sysutils/wmSMPmon/patches/patch-aa |   35 +++++
 sysutils/wmSMPmon/patches/patch-ab |  242 +++++++++++++++++++++++++++++++++++++
 6 files changed, 307 insertions(+), 0 deletions(-)

diffs (truncated from 331 to 300 lines):

diff -r bfb7d1a141aa -r c6830c14973a sysutils/wmSMPmon/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/wmSMPmon/DESCR   Wed Jan 12 11:52:09 2005 +0000
@@ -0,0 +1,1 @@
+wmSMPmon is a CPU monitoring applet for SMP systems running Window Maker.
diff -r bfb7d1a141aa -r c6830c14973a sysutils/wmSMPmon/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/wmSMPmon/Makefile        Wed Jan 12 11:52:09 2005 +0000
@@ -0,0 +1,20 @@
+# $NetBSD: Makefile,v 1.1.1.1 2005/01/12 11:52:10 agc Exp $
+
+DISTNAME=      wmSMPmon-2.3
+CATEGORIES=    sysutils x11
+MASTER_SITES=  http://goupilfr.org/arch/
+
+MAINTAINER=    Joel CARNAT <joel%carnat.net@localhost>
+HOMEPAGE=      http://goupilfr.org/?soft=wmsmpmon
+COMMENT=       Dockable CPU (SMP) monitor
+
+WRKSRC=                ${WRKDIR}/wmSMPmon-2.x/wmSMPmon
+
+USE_BUILDLINK3=        yes
+USE_X11=       yes
+
+post-install:
+       ${INSTALL_MAN} ${WRKSRC}/wmsmpmon.1 ${PREFIX}/man/man1/wmSMPmon.1
+
+.include "../../graphics/xpm/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff -r bfb7d1a141aa -r c6830c14973a sysutils/wmSMPmon/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/wmSMPmon/PLIST   Wed Jan 12 11:52:09 2005 +0000
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2005/01/12 11:52:10 agc Exp $
+bin/wmSMPmon
+man/man1/wmSMPmon.1
diff -r bfb7d1a141aa -r c6830c14973a sysutils/wmSMPmon/distinfo
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/wmSMPmon/distinfo        Wed Jan 12 11:52:09 2005 +0000
@@ -0,0 +1,6 @@
+$NetBSD: distinfo,v 1.1.1.1 2005/01/12 11:52:10 agc Exp $
+
+SHA1 (wmSMPmon-2.3.tar.gz) = 90d6665e7314fd4e5dd21cde5d90abd887e519cf
+Size (wmSMPmon-2.3.tar.gz) = 16413 bytes
+SHA1 (patch-aa) = 312453d6f8646453d9676451d182f7cf1d669515
+SHA1 (patch-ab) = 362d0fc7a3ed58b84a9ecbf894dac4752f5b8ee0
diff -r bfb7d1a141aa -r c6830c14973a sysutils/wmSMPmon/patches/patch-aa
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/wmSMPmon/patches/patch-aa        Wed Jan 12 11:52:09 2005 +0000
@@ -0,0 +1,35 @@
+$NetBSD: patch-aa,v 1.1.1.1 2005/01/12 11:52:10 agc Exp $
+--- Makefile.orig      2003-03-10 13:54:28.000000000 +0100
++++ Makefile   2004-08-25 15:04:13.000000000 +0200
+@@ -3,21 +3,22 @@
+ SRC = wmSMPmon.c ../wmgeneral/wmgeneral.c 
+ EXE = wmSMPmon
+-OBJ = $(SRC:.c=.o)
+-CFLAGS = -Wall -O3 -m486
+-LIB = -L/usr/X11R6/lib -lXpm -lXext -lX11
++OBJ = wmSMPmon.o ../wmgeneral/wmgeneral.o
++CFLAGS = -Wall -O3
++LIB = -L${X11BASE}/lib -Wl,-R${X11BASE}/lib -L${LOCALBASE}/lib -Wl,-R${LOCALBASE}/lib -lXpm -lXext -lX11
++INC = -I${X11BASE}/include -I${LOCALBASE}/include
+ INSTALL = /usr/bin/install
+ CC = gcc
+ 
+-all: $(OBJ)
+-      $(CC) -o $(EXE) $(OBJ) $(LIB)
++all: ${OBJ}
++      ${CC} -o ${EXE} ${OBJ} ${INC} ${LIB}
+ 
+-$(OBJ): %.o : %.c 
+-      $(CC) $(CFLAGS) -c -o $@ $<
++.c.o:
++      ${CC} ${CFLAGS} ${INC} -c -o $@ $<
+ 
+ clean:
+-      rm -rf $(EXE) 
++      rm -rf ${EXE}
+       rm -rf *.o
+       rm -rf ../wmgeneral/*.o
+ 
+ install:
+-      $(INSTALL) $(EXE) /usr/local/bin/
++      ${INSTALL} ${EXE} ${LOCALBASE}/bin
diff -r bfb7d1a141aa -r c6830c14973a sysutils/wmSMPmon/patches/patch-ab
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/wmSMPmon/patches/patch-ab        Wed Jan 12 11:52:09 2005 +0000
@@ -0,0 +1,242 @@
+$NetBSD: patch-ab,v 1.1.1.1 2005/01/12 11:52:10 agc Exp $
+
+--- wmSMPmon.c.orig    2003-03-10 13:50:11.000000000 +0100
++++ wmSMPmon.c 2004-08-25 20:52:07.000000000 +0200
+@@ -9,5 +9,4 @@
+ *******************************************************************************/
+ 
+-#include      <linux/sys.h>
+ #include      <sys/param.h>
+ #include      <sys/types.h>
+@@ -20,5 +19,8 @@
+ #include      "wmSMPmon_master.xpm"
+ #include      "wmSMPmon_mask.xbm"
+-#include      <sys/utsname.h>
++//#include    <sys/utsname.h>
++#include      <sys/sched.h>
++#include      <sys/swap.h>
++#include      <sys/sysctl.h>
+ 
+ #define               VERSION         "2.2"
+@@ -35,12 +37,73 @@
+ void usage(void) ;
+ 
++int getCpuUsage() {
++        int mib[] = { CTL_KERN, KERN_CP_TIME };
++        u_int64_t cpu_time[CPUSTATES];
++        size_t size = sizeof(cpu_time);
++        int total, used, result;
++        static int pre_total, pre_used;
++
++        if (sysctl(mib, 2, &cpu_time, &size, NULL, 0) < 0)
++                return 0;
++        used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_NICE] + cpu_time[CP_INTR];
++        total = used + cpu_time[CP_IDLE];
++        if ((pre_total == 0) || !(total - pre_total > 0)) {
++                result = 0;
++        } else {
++                result = 100 * (double)(used - pre_used) / (double)(total - pre_total);
++        }
++        pre_used = used;
++        pre_total = total;
++
++        return result;
++};
++
++int getMemUsage() {
++        static int mib[] = { CTL_VM, VM_METER };
++        struct vmtotal vm;
++        size_t size = sizeof(vm);
++        int per_mem;
++
++      per_mem = 0;
++        if (sysctl(mib, 2, &vm, &size, NULL, 0) < 0)
++                bzero(&vm, sizeof(vm));
++        if (vm.t_rm > 0)
++                per_mem = 100 * (double) vm.t_rm / (double) (vm.t_rm + vm.t_free);
++        if (per_mem > 97) per_mem = 100;
++
++        return per_mem;
++};
++
++int getSwapUsage() {
++        int num_swap;
++        struct swapent *swap_dev;
++        int i, sused, stotal;
++
++        stotal = sused = 0;
++
++        if ((num_swap = swapctl(SWAP_NSWAP, 0, 0)) == 0)
++                return 0;
++        if ((swap_dev = malloc(num_swap * sizeof(*swap_dev))) == NULL)
++                return 0;
++        if (swapctl(SWAP_STATS, swap_dev, num_swap) == -1)
++                return 0;
++
++        for (i = 0; i < num_swap; i++) {
++                if (swap_dev[i].se_flags & SWF_ENABLE) {
++                        sused += swap_dev[i].se_inuse;
++                        stotal += swap_dev[i].se_nblks;
++                }
++        }
++
++        free(swap_dev);
++        if (sused == 0)
++                return 0;
++        return (100 * (double) sused / (double) stotal);
++};
++
+ int main(int argc, char **argv)
+ {
+    XEvent             Event ;
+ 
+-   unsigned char              *t = NULL,
+-                        *u = NULL,
+-                        tmp[192] ;
+-
+    unsigned int               t0[TAILLE_T],
+                               t1[TAILLE_T],
+@@ -57,7 +120,5 @@
+                         draw_graph = FAUX ;
+                         
+-   unsigned long      mem, prec_mem = 0, prec_swap = 0,
+-                      total0o = 0, charge0o = 0, 
+-                              total1o = 0, charge1o = 0, cpu0o=0, cpu1o=0 ;
++   unsigned long      mem, prec_mem = 0, prec_swap = 0;
+ 
+    register unsigned long     charge, total, cpu, i = 0 ;
+@@ -107,97 +168,25 @@
+       if(lecture)
+       {
+-         i = open("/proc/stat", O_RDONLY);
+-       read(i, tmp, 192);
+-         close(i);
+-              
+-         strtok(tmp, "\n");
+-         t = strtok(NULL, "\n");
+-         u = strtok(NULL, "\n"); /* For CPU 1 */
+-              
+-         strtok(t, " "); /* CPU 0 */
+-         charge = strtol(strtok(NULL, " "), NULL, 10) + 
+-                strtol(strtok(NULL, " "), NULL, 10) +
+-                strtol(strtok(NULL, " "), NULL, 10);
+-         total = charge+ strtol(strtok(NULL, " "), NULL, 10); 
+-         if(!charge || !total)
+-         {
+-            puts(ERREUR_SMP) ;
+-            exit(ERREUR) ;
+-         }
+-         cpu =  ((HAUTEUR * (charge - charge0o)) / (total - total0o + 0.001)) + 1 ;
+-         total0o = total ;
+-         charge0o = charge ;
+-         cpu0t = cpu0t + cpu ;
+-         if(cpu != cpu0o)
+-         {
+-            delta = HAUTEUR - cpu ;
+-                  copyXPMArea(111, 0, 3, HAUTEUR, 4, 5) ;
+-                  copyXPMArea(108, delta, 3, cpu, 4, 5 + delta) ;
+-            cpu0o = cpu;
+-         }
+-         if(strncmp ("cpu1", u, 4) == 0)
+-         {
+-            strtok(u, " ");  /* CPU 1*/
+-            charge = strtol(strtok(NULL, " "), NULL, 10) + 
+-                strtol(strtok(NULL, " "), NULL, 10) +
+-                strtol(strtok(NULL, " "), NULL, 10);
+-            total = charge+ strtol(strtok(NULL, " "), NULL, 10); 
+-            cpu = ((HAUTEUR * (charge - charge1o)) / (total - total1o + 0.001)) + 1 ;
+-            total1o = total;
+-            charge1o = charge;         
+-         }
+-         cpu1t = cpu1t + cpu ;
+-         if(cpu != cpu1o)
+-         {
+-            delta = HAUTEUR - cpu ;
+-                  copyXPMArea(111, 0, 3, HAUTEUR, 9, 5) ;
+-                  copyXPMArea(108, delta, 3, cpu, 9, 5 + delta) ;
+-            cpu1o = cpu;
+-         }            
+-         if(c1 > DIV1)
+-         {
+-            i = open("/proc/meminfo", O_RDONLY);
+-            read(i, tmp, 192);
+-            close(i);
+-            strtok(tmp, "\n");
+-            t = strtok(NULL, "\n");
+-            u = strtok(NULL, "\n");   
+-            strtok(t, " ");
+-            total = atoi(strtok(NULL, " "));
+-            charge = atoi(strtok(NULL, " "));
+-            strtok(NULL, " ");
+-            strtok(NULL, " ");
+-            strtok(NULL, " ");
+-            cpu = atoi(strtok(NULL, " "));
+-            
+-            mem = ((charge - cpu) / (total / 100)) ;
+-            if(mem != prec_mem)
+-            {
+-               copyXPMArea(30, 63, 30, 8, 29, 39) ;
+-               copyXPMArea(0, 63, (mem * 30 / 100), 8, 29, 39) ;
+-               prec_mem = mem ;
+-            }         
+-            strtok(u, " ");
+-            if(!no_swap)
+-            {
+-               total = charge = 0 ;
+-               total = atoi(strtok(NULL, " "));
+-               strtok(NULL, " ");
+-               charge = atoi(strtok(NULL, " "));
+-               if(!charge || !total)
+-               {
+-                  puts(ERREUR_SWP) ;
+-                  exit(ERREUR) ;
+-               }
+-               mem = 100 - (charge / (total / 100)) ; 
+-               if(mem != prec_swap)
+-               {
+-                  copyXPMArea(30, 63, 30, 8, 29, 50) ;
+-                  copyXPMArea(0, 63, (mem * 30 / 100), 8, 29, 50) ;
+-                  prec_swap = mem ;
+-               }
+-            }
+-            c1 = 0;
+-         }
++      cpu = getCpuUsage();
++      delta = (100 - cpu) * HAUTEUR / 100;
++      copyXPMArea(108, 0, 3, HAUTEUR, 4, 5);
++      copyXPMArea(108, 0, 3, HAUTEUR, 9, 5);
++      copyXPMArea(111, 0, 3, delta, 4, 5);
++      copyXPMArea(111, 0, 3, delta, 9, 5);
++      
++      mem = getMemUsage();



Home | Main Index | Thread Index | Old Index