diff --git a/src/apple_sensors.c b/src/apple_sensors.c
index 04a97cc0791e3fc65c0db2880bce28c6535da7b9..37bd5c3965284f9e32ce39dc3cedda131d3f60c4 100644 (file)
--- a/src/apple_sensors.c
+++ b/src/apple_sensors.c
#if HAVE_CTYPE_H
# include <ctype.h>
#endif
#if HAVE_CTYPE_H
# include <ctype.h>
#endif
+
#if HAVE_MACH_MACH_TYPES_H
# include <mach/mach_types.h>
#endif
#if HAVE_MACH_MACH_TYPES_H
# include <mach/mach_types.h>
#endif
#if HAVE_MACH_MACH_ERROR_H
# include <mach/mach_error.h>
#endif
#if HAVE_MACH_MACH_ERROR_H
# include <mach/mach_error.h>
#endif
+#if HAVE_MACH_MACH_PORT_H
+# include <mach/mach_port.h>
+#endif
#if HAVE_COREFOUNDATION_COREFOUNDATION_H
# include <CoreFoundation/CoreFoundation.h>
#endif
#if HAVE_COREFOUNDATION_COREFOUNDATION_H
# include <CoreFoundation/CoreFoundation.h>
#endif
# define IOKIT_HAVE_READ 0
#endif
# define IOKIT_HAVE_READ 0
#endif
-#if IOKIT_HAVE_READ
-static mach_port_t io_master_port;
+#if HAVE_IOKIT_IOKITLIB_H
+static mach_port_t io_master_port = MACH_PORT_NULL;
#endif
static char *temperature_file = "apple_sensors/temperature-%s.rrd";
static char *fanspeed_file = "apple_sensors/fanspeed-%s.rrd";
#endif
static char *temperature_file = "apple_sensors/temperature-%s.rrd";
static char *fanspeed_file = "apple_sensors/fanspeed-%s.rrd";
-static char *voltage_file = "apple_sensors/temperature-%s.rrd";
static char *ds_def[] =
{
static char *ds_def[] =
{
#if IOKIT_HAVE_READ
kern_return_t status;
#if IOKIT_HAVE_READ
kern_return_t status;
- /* FIXME: de-allocate port if it's defined */
+ if (io_master_port != MACH_PORT_NULL)
+ {
+ mach_port_deallocate (mach_task_self (),
+ io_master_port);
+ io_master_port = MACH_PORT_NULL;
+ }
status = IOMasterPort (MACH_PORT_NULL, &io_master_port);
if (status != kIOReturnSuccess)
status = IOMasterPort (MACH_PORT_NULL, &io_master_port);
if (status != kIOReturnSuccess)
io_master_port = MACH_PORT_NULL;
return;
}
io_master_port = MACH_PORT_NULL;
return;
}
-#endif
+#endif /* IOKIT_HAVE_READ */
return;
}
return;
}
as_write (host, inst, val, fanspeed_file);
}
as_write (host, inst, val, fanspeed_file);
}
-static void voltage_write (char *host, char *inst, char *val)
-{
- as_write (host, inst, val, voltage_file);
-}
-
#if IOKIT_HAVE_READ
static void as_submit (char *type, char *inst, double value)
{
#if IOKIT_HAVE_READ
static void as_submit (char *type, char *inst, double value)
{
&value_int))
continue;
&value_int))
continue;
+ /* Found e.g. in the 1.5GHz PowerBooks */
if (strcmp (type, "temperature") == 0)
{
value_double = ((double) value_int) / 65536.0;
strncpy (type, "apple_temperature", 128);
}
if (strcmp (type, "temperature") == 0)
{
value_double = ((double) value_int) / 65536.0;
strncpy (type, "apple_temperature", 128);
}
+ else if (strcmp (type, "temp") == 0)
+ {
+ value_double = ((double) value_int) / 10.0;
+ strncpy (type, "apple_temperature", 128);
+ }
else if (strcmp (type, "fanspeed") == 0)
{
value_double = ((double) value_int) / 65536.0;
else if (strcmp (type, "fanspeed") == 0)
{
value_double = ((double) value_int) / 65536.0;
}
else if (strcmp (type, "voltage") == 0)
{
}
else if (strcmp (type, "voltage") == 0)
{
- value_double = ((double) value_int) / 65536.0;
- strncpy (type, "apple_voltage", 128);
+ /* Leave this to the battery plugin. */
+ continue;
+ }
+ else if (strcmp (type, "adc") == 0)
+ {
+ value_double = ((double) value_int) / 10.0;
+ strncpy (type, "apple_temperature", 128);
}
else
{
}
else
{
plugin_register (MODULE_NAME, as_init, as_read, NULL);
plugin_register ("apple_temperature", NULL, NULL, temperature_write);
plugin_register ("apple_fanspeed", NULL, NULL, fanspeed_write);
plugin_register (MODULE_NAME, as_init, as_read, NULL);
plugin_register ("apple_temperature", NULL, NULL, temperature_write);
plugin_register ("apple_fanspeed", NULL, NULL, fanspeed_write);
- plugin_register ("apple_voltage", NULL, NULL, voltage_write);
}
#undef MODULE_NAME
}
#undef MODULE_NAME