summaryrefslogtreecommitdiffstats
path: root/sysutils
diff options
context:
space:
mode:
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/Makefile1
-rw-r--r--sysutils/wmbluecpu/Makefile32
-rw-r--r--sysutils/wmbluecpu/distinfo1
-rw-r--r--sysutils/wmbluecpu/files/cpu_freebsd.c98
-rw-r--r--sysutils/wmbluecpu/files/cpu_freebsd.h30
-rw-r--r--sysutils/wmbluecpu/files/patch-Makefile61
-rw-r--r--sysutils/wmbluecpu/files/patch-draw.c11
-rw-r--r--sysutils/wmbluecpu/files/patch-timing.c26
-rw-r--r--sysutils/wmbluecpu/pkg-descr4
-rw-r--r--sysutils/wmbluecpu/pkg-plist1
10 files changed, 265 insertions, 0 deletions
diff --git a/sysutils/Makefile b/sysutils/Makefile
index a8037f8..e6234d6 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -264,6 +264,7 @@
SUBDIR += wmapmload
SUBDIR += wmavgload
SUBDIR += wmbattery
+ SUBDIR += wmbluecpu
SUBDIR += wmcpuload
SUBDIR += wmcube
SUBDIR += wmcube-gdk
diff --git a/sysutils/wmbluecpu/Makefile b/sysutils/wmbluecpu/Makefile
new file mode 100644
index 0000000..e1a0205
--- /dev/null
+++ b/sysutils/wmbluecpu/Makefile
@@ -0,0 +1,32 @@
+# New ports collection makefile for: wmbluecpu
+# Date created: 29 Mar 2003
+# Whom: Alexey Dokuchaev <danfe@regency.nsu.ru>
+#
+# $FreeBSD$
+#
+
+PORTNAME= wmbluecpu
+PORTVERSION= 0.4
+CATEGORIES= sysutils windowmaker
+MASTER_SITES= http://ibiblio.org/pub/linux/X11/xutils/ \
+ ftp://ftp.ibiblio.org/pub/linux/X11/xutils/
+
+MAINTAINER= danfe@regency.nsu.ru
+COMMENT= A CPU monitoring dockapp
+
+USE_BZIP2= yes
+USE_X_PREFIX= yes
+USE_XPM= yes
+
+MAN1= wmbluecpu.1
+
+post-patch:
+ @${CP} ${FILESDIR}/cpu_freebsd.* ${WRKSRC}
+
+do-install:
+ @${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${PREFIX}/bin
+ @${CHMOD} g+s ${PREFIX}/bin/${PORTNAME}
+ @${CHOWN} root:kmem ${PREFIX}/bin/${PORTNAME}
+ @${INSTALL_MAN} ${WRKSRC}/${PORTNAME}.1 ${MANPREFIX}/man/man1
+
+.include <bsd.port.mk>
diff --git a/sysutils/wmbluecpu/distinfo b/sysutils/wmbluecpu/distinfo
new file mode 100644
index 0000000..bab99db
--- /dev/null
+++ b/sysutils/wmbluecpu/distinfo
@@ -0,0 +1 @@
+MD5 (wmbluecpu-0.4.tar.bz2) = 91bd55c929efd60d70d7324485006842
diff --git a/sysutils/wmbluecpu/files/cpu_freebsd.c b/sysutils/wmbluecpu/files/cpu_freebsd.c
new file mode 100644
index 0000000..ae27a21
--- /dev/null
+++ b/sysutils/wmbluecpu/files/cpu_freebsd.c
@@ -0,0 +1,98 @@
+/*
+ * cpu_freebsd.c - get cpu usage
+ *
+ * Copyright (C) 2003 Alexey Dokuchaev <danfe@regency.nsu.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <kvm.h>
+#include <nlist.h>
+#include <fcntl.h>
+#include <sys/dkstat.h>
+
+static kvm_t *kd;
+static struct nlist nlst[] = { {"_cp_time"}, {0} };
+
+void
+cpu_init(void)
+{
+ if (!(kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")))
+ {
+ perror("kvm_open");
+ exit(1);
+ }
+
+ kvm_nlist(kd, nlst);
+
+ if (!nlst[0].n_type)
+ {
+ perror("kvm_nlist");
+ exit(1);
+ }
+
+ seteuid(getuid());
+ setegid(getgid());
+
+ if (geteuid() != getuid() || getegid() != getgid())
+ {
+ perror("sete?id");
+ exit(1);
+ }
+}
+
+long cpu_used;
+long oldused;
+long oldtotal;
+
+int history[17];
+
+void cpu_getusage()
+{
+ long cpu, nice, system, idle, used, total;
+ long cpu_time[CPUSTATES];
+
+ if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time))
+ != sizeof(cpu_time))
+ {
+ perror("kvm_read");
+ exit(1);
+ }
+
+ cpu = cpu_time[CP_USER];
+ nice = cpu_time[CP_NICE];
+ system = cpu_time[CP_SYS];
+ idle = cpu_time[CP_IDLE];
+
+ used = cpu + nice + system;
+ total = used + idle;
+
+ if ((total - oldtotal) != 0)
+ cpu_used = (100 * (double)(used - oldused)) /
+ (double)(total - oldtotal);
+ else
+ cpu_used = 0;
+
+ oldused = used;
+ oldtotal = total;
+
+ memmove(history + 1, history, 16 * sizeof(int));
+ history[0] = (double)cpu_used * 16 / 100;
+}
diff --git a/sysutils/wmbluecpu/files/cpu_freebsd.h b/sysutils/wmbluecpu/files/cpu_freebsd.h
new file mode 100644
index 0000000..467c033
--- /dev/null
+++ b/sysutils/wmbluecpu/files/cpu_freebsd.h
@@ -0,0 +1,30 @@
+/*
+ * cpu_freebsd.h
+ *
+ * Copyright (C) 2003 Alexey Dokuchaev <danfe@regency.nsu.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __CPU_FREEBSD_H__
+#define __CPU_FREEBSD_H__
+
+extern int cpu_used;
+extern int history[16];
+
+void cpu_init(void);
+void cpu_getusage(void);
+
+#endif /* __CPU_FREEBSD_H__ */
diff --git a/sysutils/wmbluecpu/files/patch-Makefile b/sysutils/wmbluecpu/files/patch-Makefile
new file mode 100644
index 0000000..45ed764
--- /dev/null
+++ b/sysutils/wmbluecpu/files/patch-Makefile
@@ -0,0 +1,61 @@
+--- Makefile.orig Sun Mar 23 02:04:32 2003
++++ Makefile Sat Mar 29 22:29:46 2003
+@@ -1,43 +1,23 @@
+-#Makefile
++CC ?= cc
++LDIR = -L${X11BASE}/lib
++IDIR = -I${X11BASE}/include
+
+-PREFIX=/usr/local
+-BINDIR=$(PREFIX)/bin
+-MANUALDIR=$(PREFIX)/share/man/man1
+-CC=gcc
+-STRIP=strip
+-FLAGS=-Wall -O2 -ffast-math
+-RM=rm -f
+-INST=install
+-OBJS=cpu_linux.o dockapp.o draw.o options.o timing.o wmbluecpu.o
+-PROG=wmbluecpu
+-MANUAL=$(PROG).1
+-LIBS=-L/usr/X11R6/lib -lX11 -lXext -lXpm
++LIBS = -lX11 -lXpm -lXext -lkvm
+
+-DEFS=-DOPT_TIMER_MILISECONDS=1000 -DOPT_WINDOW=0 -DOPT_SHAPE=1
++DEFS= -DOPT_TIMER_MILISECONDS=1000 -DOPT_WINDOW=0 -DOPT_SHAPE=1
+ # OPT_TIMER_MILISECONDS - the number of miliseconds between updates
+ # OPT_WINDOW - Run in a window ?
+ # OPT_SHAPE - Use XShape ?
+
+-all: $(PROG)
++OBJS = cpu_freebsd.o\
++ dockapp.o\
++ draw.o\
++ options.o\
++ timing.o\
++ wmbluecpu.o
+
+-$(PROG): $(OBJS)
+- $(CC) -o $(PROG) $(OBJS) $(LIBS)
+- $(STRIP) $(PROG)
+-%.o: %.c
+- $(CC) $(FLAGS) -c $< -o $@
+-clean:
+- $(RM) $(OBJS) $(PROG)
+-install: $(PROG)
+- $(INST) -m 755 $(PROG) $(BINDIR)
+- $(INST) -m 644 $(MANUAL) $(MANUALDIR)
+-uninstall:
+- $(RM) $(BINDIR)/$(PROG)
+- $(RM) $(MANUALDIR)/$(MANUAL)
++.c.o:
++ ${CC} ${CFLAGS} ${IDIR} ${DEFS} -c $< -o $*.o
+
+-cpu_linux.o: cpu_linux.c
+-dockapp.o: dockapp.c wmbluecpu.h options.h draw.h timing.h xpm/bg.xpm \
+- xpm/on.xpm xpm/off.xpm xpm/numbers.xpm xpm/panel.xpm
+-draw.o: draw.c cpu_linux.h dockapp.h options.h
+-options.o: options.c options.h wmbluecpu.h
+-timing.o: timing.c draw.h options.h cpu_linux.h
+-wmbluecpu.o: wmbluecpu.c options.h dockapp.h timing.h
++all: ${OBJS}
++ ${CC} ${CFLAGS} -o wmbluecpu ${OBJS} ${LDIR} ${LIBS}
diff --git a/sysutils/wmbluecpu/files/patch-draw.c b/sysutils/wmbluecpu/files/patch-draw.c
new file mode 100644
index 0000000..7d2db73
--- /dev/null
+++ b/sysutils/wmbluecpu/files/patch-draw.c
@@ -0,0 +1,11 @@
+--- draw.c.orig Sat Mar 29 21:26:19 2003
++++ draw.c Sat Mar 29 21:26:26 2003
+@@ -21,7 +21,7 @@
+ #include <string.h>
+ #include <X11/Xlib.h>
+
+-#include "cpu_linux.h"
++#include "cpu_freebsd.h"
+ #include "dockapp.h"
+ #include "options.h"
+
diff --git a/sysutils/wmbluecpu/files/patch-timing.c b/sysutils/wmbluecpu/files/patch-timing.c
new file mode 100644
index 0000000..d9f3081
--- /dev/null
+++ b/sysutils/wmbluecpu/files/patch-timing.c
@@ -0,0 +1,26 @@
+--- timing.c.orig Sat Mar 29 21:26:11 2003
++++ timing.c Sat Mar 29 23:23:09 2003
+@@ -24,7 +24,7 @@
+
+ #include "draw.h"
+ #include "options.h"
+-#include "cpu_linux.h"
++#include "cpu_freebsd.h"
+
+ void handle_timer(int sig)
+ {
+@@ -39,11 +39,12 @@
+ {
+ struct itimerval itv;
+
++ cpu_init();
+ signal(SIGALRM, handle_timer);
+ itv.it_value.tv_sec = 2;
+ itv.it_value.tv_usec = 0;
+- itv.it_interval.tv_sec = 0;
+- itv.it_interval.tv_usec = opt_timer_miliseconds * 1000;
++ itv.it_interval.tv_sec = opt_timer_miliseconds / 1000;
++ itv.it_interval.tv_usec = (opt_timer_miliseconds % 1000) * 1000;
+ setitimer(ITIMER_REAL, &itv, NULL);
+ }
+
diff --git a/sysutils/wmbluecpu/pkg-descr b/sysutils/wmbluecpu/pkg-descr
new file mode 100644
index 0000000..db99077
--- /dev/null
+++ b/sysutils/wmbluecpu/pkg-descr
@@ -0,0 +1,4 @@
+WMBlueCPU is a CPU monitoring dockapp. It displays current CPU usage
+with numbers and a graphical history list.
+
+WWW: http://misuceldestept.go.ro/wmbluecpu/
diff --git a/sysutils/wmbluecpu/pkg-plist b/sysutils/wmbluecpu/pkg-plist
new file mode 100644
index 0000000..7d8c0ac
--- /dev/null
+++ b/sysutils/wmbluecpu/pkg-plist
@@ -0,0 +1 @@
+bin/wmbluecpu
OpenPOWER on IntegriCloud