Re: hw.sensors support for sysutils/gkrellm/gkrellm
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. 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) 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 ? 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 --- Makefile1 Jul 2008 10:17:35 - 1.39 +++ Makefile16 Jul 2008 06:31:12 - @@ -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 - 1.9 +++ patches/patch-src_sysdeps_openbsd_c 16 Jul 2008 06:31:13 - @@ -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.01, 1.0, 0.01 }; ++ 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++)
Re: hw.sensors support for sysutils/gkrellm/gkrellm
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 - 1.39 +++ Makefile 16 Jul 2008 06:31:12 - @@ -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 - 1.9 +++ patches/patch-src_sysdeps_openbsd_c 16 Jul 2008 06:31:13 - @@ -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.cTue 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.cSat 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,
Re: hw.sensors support for sysutils/gkrellm/gkrellm
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? diff -u -rP sysutils/gkrellm/gkrellm/patches/patch-src_sensors_c mystuff/sysutils/gkrellm/gkrellm/patches/patch-src_sensors_c --- sysutils/gkrellm/gkrellm/patches/patch-src_sensors_cWed Dec 31 16:00:00 1969 +++ mystuff/sysutils/gkrellm/gkrellm/patches/patch-src_sensors_cSat Jul 5 17:10:32 2008 @@ -0,0 +1,12 @@ +$OpenBSD$ +--- src/sensors.c.orig Sat Oct 20 11:04:07 2007 src/sensors.c Sat Jul 5 15:50:46 2008 +@@ -2759,7 +2759,7 @@ create_sensors_tab(GtkWidget *tab_vbox) + + box = gkrellm_gtk_framed_vbox(vbox1, _(Factor), 4, FALSE, 0, 2); + gkrellm_gtk_spin_button(box, factor_spin_button, 1.0, +- -1000.0, 1000.0, 0.01, 1.0, 4, 60, ++ -1000.0, 1000.0, 0.01, 1.0, 6, 60, + cb_correction_modified, NULL, FALSE, NULL); + + box = gkrellm_gtk_framed_vbox(vbox1, _(Offset), 4, FALSE, 0, 2); diff -u -rP sysutils/gkrellm/gkrellm/patches/patch-src_sysdeps_openbsd_c mystuff/sysutils/gkrellm/gkrellm/patches/patch-src_sysdeps_openbsd_c --- sysutils/gkrellm/gkrellm/patches/patch-src_sysdeps_openbsd_cSat Jul 12 09:23:45 2008 +++ mystuff/sysutils/gkrellm/gkrellm/patches/patch-src_sysdeps_openbsd_c Sat Jul 12 09:14:12 2008 @@ -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 @@ /* = */ /* 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.01, 1.0, 0.01 }; ++ 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, ++
hw.sensors support for sysutils/gkrellm/gkrellm
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? diff -u -rP sysutils/gkrellm/gkrellm/patches/patch-src_sensors_c mystuff/sysutils/gkrellm/gkrellm/patches/patch-src_sensors_c --- sysutils/gkrellm/gkrellm/patches/patch-src_sensors_cWed Dec 31 16:00:00 1969 +++ mystuff/sysutils/gkrellm/gkrellm/patches/patch-src_sensors_cSat Jul 5 17:10:32 2008 @@ -0,0 +1,12 @@ +$OpenBSD$ +--- src/sensors.c.orig Sat Oct 20 11:04:07 2007 src/sensors.c Sat Jul 5 15:50:46 2008 +@@ -2759,7 +2759,7 @@ create_sensors_tab(GtkWidget *tab_vbox) + + box = gkrellm_gtk_framed_vbox(vbox1, _(Factor), 4, FALSE, 0, 2); + gkrellm_gtk_spin_button(box, factor_spin_button, 1.0, +- -1000.0, 1000.0, 0.01, 1.0, 4, 60, ++ -1000.0, 1000.0, 0.01, 1.0, 6, 60, + cb_correction_modified, NULL, FALSE, NULL); + + box = gkrellm_gtk_framed_vbox(vbox1, _(Offset), 4, FALSE, 0, 2); diff -u -rP sysutils/gkrellm/gkrellm/patches/patch-src_sysdeps_openbsd_c mystuff/sysutils/gkrellm/gkrellm/patches/patch-src_sysdeps_openbsd_c --- sysutils/gkrellm/gkrellm/patches/patch-src_sysdeps_openbsd_cSat Jul 12 09:23:45 2008 +++ mystuff/sysutils/gkrellm/gkrellm/patches/patch-src_sysdeps_openbsd_c Sat Jul 12 09:14:12 2008 @@ -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 @@ /* = */ /* 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.01, 1.0, 0.01 }; ++ 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, ++