On Wed, Jul 16, 2008 at 08:37:09AM +0200, Landry Breuil wrote:
> On Wed, Jul 16, 2008 at 04:59:04AM +0200, Dawe wrote:
> > Josh Elsasser wrote:
> >> I have implemented support in gkrellm for reading and displaying the
> >> hw.sensors sysctls. Only sensors for temperature, fan speed, and DC
> >> voltage are supported due to limitations in gkrellm.
> >>
> >> Comments, bugs, suggestions?
> 
> Pretty nice, works fine here @i386 with acpitz0.temp0. Inserting the
> battery allows to show acpibat0.volt0/1 too, it'd be even better if it
> could show acpibat0.watthour* (battery capacity), but i understand there
> are limitations in gkrellm.

At least the battery gague works with acpi.

> You forgot to bump PKGNAME btw, so here's an updated diff against
> anoncvs this time. I also removed the irrelevant sysutils/gkrellm
> CATEGORY, there's no point in having a category for a single package (i
> shall do the same for gkrellm/plugins too btw)

Oops, thank you for catching that.

> Did you send it to maintainer first (i know he's off this week but i can
> handle this patch) ? And most important, did you send this patch
> upstream for inclusion, so we don't have to keep it for years in our
> tree ?

I haven't sent this either to the maintainer or upstream yet, I
thought I'd send it to this list first to see if someone found
something glaringly wrong.

> Thanks for you work,
> Landry

> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/sysutils/gkrellm/gkrellm/Makefile,v
> retrieving revision 1.39
> diff -u -p -r1.39 Makefile
> --- Makefile  1 Jul 2008 10:17:35 -0000       1.39
> +++ Makefile  16 Jul 2008 06:31:12 -0000
> @@ -7,9 +7,9 @@ COMMENT-client=       single process stack of 
>  
>  V=           2.3.1
>  DISTNAME=    gkrellm-${V}
> -PKGNAME-main=        gkrellm-server-${V}p1
> -PKGNAME-client=      gkrellm-${V}p2
> -CATEGORIES=  sysutils sysutils/gkrellm
> +PKGNAME-main=        gkrellm-server-${V}p2
> +PKGNAME-client=      gkrellm-${V}p3
> +CATEGORIES=  sysutils
>  
>  MAINTAINER=  Antoine Jacoutot <[EMAIL PROTECTED]>
>  
> Index: patches/patch-src_sysdeps_openbsd_c
> ===================================================================
> RCS file: 
> /cvs/ports/sysutils/gkrellm/gkrellm/patches/patch-src_sysdeps_openbsd_c,v
> retrieving revision 1.9
> diff -u -p -r1.9 patch-src_sysdeps_openbsd_c
> --- patches/patch-src_sysdeps_openbsd_c       1 Jul 2008 10:17:35 -0000       
> 1.9
> +++ patches/patch-src_sysdeps_openbsd_c       16 Jul 2008 06:31:13 -0000
> @@ -1,6 +1,6 @@
> -$OpenBSD: patch-src_sysdeps_openbsd_c,v 1.9 2008/07/01 10:17:35 ajacoutot 
> Exp $
> ---- src/sysdeps/openbsd.c.orig       Sat Jul  7 01:54:22 2007
> -+++ src/sysdeps/openbsd.c    Tue Jul  1 10:48:13 2008
> +$OpenBSD: patch-src_sysdeps_openbsd_c,v 1.7 2007/10/26 22:56:57 ajacoutot 
> Exp $
> +--- src/sysdeps/openbsd.c.orig       Fri Jul  6 16:54:22 2007
> ++++ src/sysdeps/openbsd.c    Sat Jul 12 09:14:03 2008
>  @@ -53,41 +53,71 @@ gkrellm_sys_main_cleanup(void)
>   #include <sys/dkstat.h>
>   #include <kvm.h>
> @@ -93,7 +93,133 @@ $OpenBSD: patch-src_sysdeps_openbsd_c,v 
>   /* ===================================================================== */
>   /* Proc monitor interface */
>   
> -@@ -293,7 +323,7 @@ gkrellm_sys_sensors_init(void)
> +@@ -259,41 +289,122 @@ gkrellm_sys_mem_init(void)
> + 
> + 
> + /* ===================================================================== */
> +-/* Sensor monitor interface - not implemented */
> ++/* Sensor monitor interface */
> + 
> ++#include <sys/param.h>
> ++#include <sys/sysctl.h>
> ++#include <sys/sensors.h>
> ++#include <errno.h>
> ++
> ++static gboolean
> ++get_sensor(int dev, int type, int num, gfloat *val)
> ++{
> ++    int mib[5] = { CTL_HW, HW_SENSORS };
> ++    struct sensor sen;
> ++    size_t len = sizeof(sen);
> ++
> ++    mib[2] = dev;
> ++    mib[3] = type;
> ++    mib[4] = num;
> ++    if (sysctl(mib, 5, &sen, &len, NULL, 0) == -1 ||
> ++        (SENSOR_FINVALID|SENSOR_FUNKNOWN) & sen.flags)
> ++            return FALSE;
> ++
> ++    *val = (gfloat)sen.value;
> ++    return TRUE;
> ++}
> ++
> + gboolean
> + gkrellm_sys_sensors_get_temperature(gchar *device_name, gint id,
> +             gint iodev, gint interface, gfloat *temp)
> +-    {
> +-    return FALSE;
> +-    }
> ++{
> ++    return get_sensor(id, iodev, interface, temp);
> ++}
> + 
> + gboolean
> + gkrellm_sys_sensors_get_fan(gchar *device_name, gint id,
> +             gint iodev, gint interface, gfloat *fan)
> +-    {
> +-    return FALSE;
> +-    }
> ++{
> ++    return get_sensor(id, iodev, interface, fan);
> ++}
> + 
> + gboolean
> + gkrellm_sys_sensors_get_voltage(gchar *device_name, gint id,
> +             gint iodev, gint interface, gfloat *volt)
> +-    {
> +-    return FALSE;
> ++{
> ++    return get_sensor(id, iodev, interface, volt);
> ++}
> ++
> ++static gboolean
> ++add_sensdev(int dev, struct sensordev *sensdev)
> ++{
> ++    static enum sensor_type stypes[] =
> ++            { SENSOR_TEMP, SENSOR_FANRPM, SENSOR_VOLTS_DC };
> ++    static gint gtypes[] =
> ++            { SENSOR_TEMPERATURE, SENSOR_FAN, SENSOR_VOLTAGE };
> ++    static gfloat fac[] = { 0.000001, 1.0, 0.000001 };
> ++    static gfloat off[] = { -273.15, 0.0, 0.0 };
> ++    char name[32];
> ++    int mib[5] = { CTL_HW, HW_SENSORS };
> ++    struct sensor sen;
> ++    size_t len = sizeof(sen);
> ++    int idx, num;
> ++    gboolean found = FALSE;
> ++
> ++    mib[2] = dev;
> ++    for (idx = 0; sizeof(stypes) / sizeof(stypes[0]) > idx; idx++) {
> ++            mib[3] = stypes[idx];
> ++            for (num = 0; sensdev->maxnumt[stypes[idx]] > num; num++) {
> ++                    mib[4] = num;
> ++                    len = sizeof(sen);
> ++                    if (sysctl(mib, 5, &sen, &len, NULL, 0) == -1) {
> ++                            if (ENOENT != errno)
> ++                                    return FALSE;
> ++                            continue;
> ++                    }
> ++                    if (SENSOR_FINVALID & sen.flags)
> ++                            continue;
> ++                    snprintf(name, sizeof(name), "%s.%s%d", sensdev->xname,
> ++                        sensor_type_s[stypes[idx]], num);
> ++                    gkrellm_sensors_add_sensor(gtypes[idx], NULL, name,
> ++                        sensdev->num, stypes[idx], num, fac[idx],
> ++                        off[idx], NULL, (sen.desc[0] ? sen.desc : NULL));
> ++                    found = TRUE;
> ++            }
> +     }
> + 
> ++    return found;
> ++}
> ++
> + gboolean
> + gkrellm_sys_sensors_init(void)
> +-    {
> +-    return FALSE;
> ++{
> ++    int mib[3] = { CTL_HW, HW_SENSORS };
> ++    struct sensordev sensdev;
> ++    size_t len = sizeof(sensdev);
> ++    int dev;
> ++    gboolean found = FALSE;
> ++
> ++    for (dev = 0; MAXSENSORDEVICES > dev; dev++) {
> ++            mib[2] = dev;
> ++            if (sysctl(mib, 3, &sensdev, &len, NULL, 0) == -1) {
> ++                    if (ENOENT != errno)
> ++                            return FALSE;
> ++                    continue;
> ++            }
> ++            if (add_sensdev(dev, &sensdev))
> ++                    found = TRUE;
> +     }
> + 
> ++    return found;
> ++}
> + 
> ++
> + /* ===================================================================== */
>   /* Battery monitor interface */
>   #include <sys/ioctl.h>
>   
> @@ -102,7 +228,7 @@ $OpenBSD: patch-src_sysdeps_openbsd_c,v 
>   
>   #include <machine/apmvar.h>
>   #define     APMDEV          "/dev/apm"
> -@@ -405,7 +435,7 @@ gkrellm_sys_disk_read_data(void)
> +@@ -405,7 +516,7 @@ gkrellm_sys_disk_read_data(void)
>               /* Separate read/write stats were implemented in NetBSD 1.6K.
>               */
>   
> @@ -111,7 +237,7 @@ $OpenBSD: patch-src_sysdeps_openbsd_c,v 
>               rbytes = d.dk_rbytes;
>               wbytes = d.dk_wbytes;
>   #else
> -@@ -413,7 +443,7 @@ gkrellm_sys_disk_read_data(void)
> +@@ -413,7 +524,7 @@ gkrellm_sys_disk_read_data(void)
>               wbytes = 0;
>   #endif
>   
> Index: pkg/PLIST-main
> ===================================================================
> RCS file: /cvs/ports/sysutils/gkrellm/gkrellm/pkg/PLIST-main,v
> retrieving revision 1.1
> diff -u -p -r1.1 PLIST-main
> --- pkg/PLIST-main    25 Nov 2006 20:12:10 -0000      1.1
> +++ pkg/PLIST-main    16 Jul 2008 06:31:13 -0000
> @@ -1,7 +1,6 @@
>  @comment $OpenBSD: PLIST-main,v 1.1 2006/11/25 20:12:10 espie Exp $
>  @pkgpath sysutils/gkrellm/gkrellm
>  @pkgpath sysutils/gkrellm/gkrellm,no_client
> -include/gkrellm2/
>  include/gkrellm2/gkrellmd.h
>  @man man/man1/gkrellmd.1
>  @mode 2755

Reply via email to