Date: Mon, 10 Jul 2006 10:49:59 +0400 (MSD) From: Stanislav Sedov <ssedov@mbsd.msk.ru> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/100007: [NEW PORT] x11/e17-module-cpu: An e17 module which allows users to monitor cpu load Message-ID: <200607100649.k6A6nxos009255@fonon.realnet> Resent-Message-ID: <200607100700.k6A70S8H039510@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 100007 >Category: ports >Synopsis: [NEW PORT] x11/e17-module-cpu: An e17 module which allows users to monitor cpu load >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Jul 10 07:00:28 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Stanislav Sedov >Release: FreeBSD 7.0-CURRENT i386 >Organization: MBSD labs, Inc. >Environment: System: FreeBSD fonon.realnet 7.0-CURRENT FreeBSD 7.0-CURRENT #7: Sun Jun 18 20:51:36 MSD 2006 >Description: This e17 module allows users to monitor current cpu load. It can draw load graph and display cpu load percentage. The polling interval is fully configurable. Author: Matthew Mullins WWW: http://www.enlightenment.org >How-To-Repeat: >Fix: --- e17-module-cpu-20060707.shar begins here --- # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # e17-module-cpu # e17-module-cpu/files # e17-module-cpu/files/patch-configure # e17-module-cpu/files/patch-e_mod_main.c # e17-module-cpu/pkg-descr # e17-module-cpu/Makefile # e17-module-cpu/pkg-plist # e17-module-cpu/distinfo # echo c - e17-module-cpu mkdir -p e17-module-cpu > /dev/null 2>&1 echo c - e17-module-cpu/files mkdir -p e17-module-cpu/files > /dev/null 2>&1 echo x - e17-module-cpu/files/patch-configure sed 's/^X//' >e17-module-cpu/files/patch-configure << 'END-of-e17-module-cpu/files/patch-configure' X--- configure.orig Fri Jun 23 16:14:40 2006 X+++ configure Fri Jun 23 16:14:53 2006 X@@ -21497,7 +21497,7 @@ X X X X-MODULE_ARCH="$host_os-$host_cpu" X+MODULE_ARCH="" X X X cat >>confdefs.h <<_ACEOF END-of-e17-module-cpu/files/patch-configure echo x - e17-module-cpu/files/patch-e_mod_main.c sed 's/^X//' >e17-module-cpu/files/patch-e_mod_main.c << 'END-of-e17-module-cpu/files/patch-e_mod_main.c' X--- e_mod_main.c.orig Sun Jul 9 14:15:46 2006 X+++ e_mod_main.c Sun Jul 9 15:58:09 2006 X@@ -3,6 +3,12 @@ X #include "e_mod_config.h" X #include "config.h" X X+#if defined(__FreeBSD__) X+# include <sys/types.h> X+# include <sys/sysctl.h> X+# include <sys/resource.h> X+#endif X+ X static Cpu *_cpu_init(E_Module *m); X static void _cpu_shutdown(Cpu *n); X static void _cpu_config_menu_new(Cpu *n); X@@ -460,31 +466,66 @@ X FILE *f; X int cpu = -1; X X+#if defined(__FreeBSD__) X+ cpu = 1; /* We can't retrive per-cpu statistics, so we'll assume UP arch*/ X+#else X if (!(f = fopen("/proc/stat", "r"))) X return -1; X X while (fscanf(f, "cp%s %*u %*u %*u %*u %*u %*u %*u %*u\n", (char *)&tmp) == 1) X cpu++; X- X fclose(f); X+#endif X+ X return cpu; X } X X static void X _cpu_face_get_load(Cpu_Face *cf) X { X+ int cpu_count; X+ Edje_Message_Float msg; X+#if defined(__FreeBSD__) X+ long cp_time[CPUSTATES]; X+ static long old_used, old_tot; X+ long new_used, new_tot; X+ size_t len; X+#else X static unsigned long old_u[4], old_n[4], old_s[4], old_i[4], old_wa[4], old_hi[4], old_si[4]; X unsigned long new_u, new_n, new_s, new_i, new_wa = 0, new_hi = 0, new_si = 0, ticks_past; X int tmp_u, tmp_n, tmp_s, tmp_i; X char dummy[16]; X FILE *stat; X- int cpu_count; X- Edje_Message_Float msg; X+#endif X X cpu_count = _cpu_face_get_cpu_count(cf); X if (cpu_count == -1) X return; X X+#if defined(__FreeBSD__) X+ len = sizeof(cp_time); X+ X+ if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) < 0) { X+ warn("sysctl()"); X+ return; X+ } X+ X+ new_used = cp_time[CP_USER] + cp_time[CP_NICE] + cp_time[CP_SYS]; X+ new_tot = new_used + cp_time[CP_IDLE]; X+ X+ if (new_tot == old_tot) X+ msg.val = 0; X+ else X+ msg.val = 100 * (float)(new_used - old_used) / (float)(new_tot - old_tot); X+ X+ cpu_stats[0] = msg.val; X+ edje_object_message_send(cf->cpu_obj, EDJE_MESSAGE_FLOAT, 0, &msg); X+ X+ old_tot = new_tot; X+ old_used = new_used; X+ X+#else X+ X if (!(stat = fopen("/proc/stat", "r"))) X return; X X@@ -537,6 +578,7 @@ X i++; X } X fclose(stat); X+#endif X } X X static void END-of-e17-module-cpu/files/patch-e_mod_main.c echo x - e17-module-cpu/pkg-descr sed 's/^X//' >e17-module-cpu/pkg-descr << 'END-of-e17-module-cpu/pkg-descr' XThis e17 module allows users to monitor current cpu load. It can draw Xload graph and display cpu load percentage. The polling interval is Xfully configurable. X XAuthor: Matthew Mullins XWWW: http://www.enlightenment.org END-of-e17-module-cpu/pkg-descr echo x - e17-module-cpu/Makefile sed 's/^X//' >e17-module-cpu/Makefile << 'END-of-e17-module-cpu/Makefile' X# New ports collection makefile for: e17-module-cpu X# Date created: 23 June 2006 X# Whom: Stanislav Sedov <ssedov@mbsd.msk.ru> X# X# $FreeBSD$ X# X XPORTNAME= cpu XPORTVERSION= 20060707 XCATEGORIES= x11 XMASTER_SITES= http://mbsd.msk.ru/dist/ XPKGNAMEPREFIX= e17-module- XDISTNAME= ${PORTNAME}-${PORTVERSION} X XMAINTAINER= ssedov@mbsd.msk.ru XCOMMENT= An e17 module which allows users to monitor cpu load X XBUILD_DEPENDS= enlightenment:${PORTSDIR}/x11-wm/enlightenment-devel XRUN_DEPENDS= ${BUILD_DEPENDS} X XUSE_BZIP2= yes XUSE_X_PREFIX= yes XUSE_GMAKE= yes XGNU_CONFIGURE= yes XCONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include -I${X11BASE}/include" \ X LDFLAGS="-L${LOCALBASE}/lib -L${X11BASE}/lib" X X.if !defined(WITHOUT_NLS) XUSE_GETTEXT= yes XPLIST_SUB+= NLS="" X.else XCONFIGURE_ARGS= --disable-nls XPLIST_SUB+= NLS="@comment " X.endif X X.include <bsd.port.mk> END-of-e17-module-cpu/Makefile echo x - e17-module-cpu/pkg-plist sed 's/^X//' >e17-module-cpu/pkg-plist << 'END-of-e17-module-cpu/pkg-plist' Xlib/enlightenment/modules/cpu/cpu.edj Xlib/enlightenment/modules/cpu/module.a Xlib/enlightenment/modules/cpu/module.eap Xlib/enlightenment/modules/cpu/module.la Xlib/enlightenment/modules/cpu/module.so Xlib/enlightenment/modules/cpu/module_icon.png X%%NLS%%share/locale/bg/LC_MESSAGES/cpu.mo X%%NLS%%share/locale/eo/LC_MESSAGES/cpu.mo X%%NLS%%share/locale/fi/LC_MESSAGES/cpu.mo X%%NLS%%share/locale/it/LC_MESSAGES/cpu.mo X%%NLS%%share/locale/ja/LC_MESSAGES/cpu.mo X%%NLS%%share/locale/ru/LC_MESSAGES/cpu.mo X%%NLS%%share/locale/sv/LC_MESSAGES/cpu.mo X@dirrm lib/enlightenment/modules/cpu END-of-e17-module-cpu/pkg-plist echo x - e17-module-cpu/distinfo sed 's/^X//' >e17-module-cpu/distinfo << 'END-of-e17-module-cpu/distinfo' XMD5 (cpu-20060707.tar.bz2) = c4f763fc3cf8bcac6da1fb90a54c60ac XSHA256 (cpu-20060707.tar.bz2) = 8b81a3acae9a48613ef4d10ef0f037687e084f572f4f1c7e023739fd7d4acac7 XSIZE (cpu-20060707.tar.bz2) = 298803 END-of-e17-module-cpu/distinfo exit --- e17-module-cpu-20060707.shar ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607100649.k6A6nxos009255>