* [Jan Kaluza]: Added --debuginfo option to cifsiostat and
nfsiostat.
* cifsiostat and nfsiostat manual pages updated.
+ * Don't link sysstat's commands with sensors library if not
+ needed [DEBIAN Bug#612571].
* [Adam Heath]: iostat incorrectly mapped device-mapper IDs
greater than 256. This is now fixed [DEBIAN Bug#614397].
* Sysstat's commands option -V now displays the version number
INSTALL_DATA = @INSTALL_DATA@
INSTALL_BIN = @INSTALL_BIN@
+HAVE_SENSORS = @HAVE_SENSORS@
+LFSENSORS =
+DFSENSORS =
+ifeq ($(HAVE_SENSORS),y)
+LFSENSORS = @LFSENSORS@
+DFSENSORS = @DFSENSORS@
+endif
+
# Directories
ifndef PREFIX
PREFIX = @prefix@
DFLAGS = @DFLAGS@
LFLAGS = -s
DFLAGS += -DSA_DIR=\"$(SA_DIR)\" -DSADC_PATH=\"$(SADC_PATH)\"
+DFLAGS += $(DFSENSORS)
# Commands
ifndef MSGFMT
ioconf.o: ioconf.c ioconf.h common.h sysconfig.h
-act_sadc.o: activity.c sa.h rd_stats.h
+act_sadc.o: activity.c sa.h rd_stats.h rd_sensors.h
$(CC) -o $@ -c $(CFLAGS) -DSOURCE_SADC $(DFLAGS) $<
act_sar.o: activity.c sa.h pr_stats.h
rd_stats.o: rd_stats.c common.h rd_stats.h ioconf.h sysconfig.h
+rd_sensors.o: rd_sensors.c common.h rd_sensors.h sysconfig.h
+
pr_stats.o: pr_stats.c sa.h ioconf.h sysconfig.h pr_stats.h
rndr_stats.o: rndr_stats.c sa.h ioconf.h sysconfig.h rndr_stats.h
xml_stats.o: xml_stats.c sa.h ioconf.h sysconfig.h xml_stats.h
-sa_wrap.o: sa_wrap.c sa.h rd_stats.h
+sa_wrap.o: sa_wrap.c sa.h rd_stats.h rd_sensors.h
# Explicit rules needed to prevent possible file corruption
# when using parallel execution.
librdstats.a: librdstats.a(rd_stats.o)
-sadc.o: sadc.c sa.h version.h common.h ioconf.h sysconfig.h rd_stats.h
+librdsensors.a: librdsensors.a(rd_sensors.o)
+
+sadc.o: sadc.c sa.h version.h common.h ioconf.h sysconfig.h rd_stats.h rd_sensors.h
-sadc: sadc.o act_sadc.o sa_wrap.o sa_common.o librdstats.a libsyscom.a
+sadc: LFLAGS += $(LFSENSORS)
+sadc: sadc.o act_sadc.o sa_wrap.o sa_common.o librdstats.a librdsensors.a libsyscom.a
sar.o: sar.c sa.h version.h common.h ioconf.h pr_stats.h sysconfig.h
#ifdef SOURCE_SADC
#include "rd_stats.h"
+#include "rd_sensors.h"
#endif
#ifdef SOURCE_SAR
INIT_DIR
RC_DIR
rcdir
+DFSENSORS
+LFSENSORS
HAVE_SENSORS
PATH_CHKCONFIG
PATH_CP
fi
+DFLAGS=""
+
# Extract the first word of "chmod", so it can be a program name with args.
set dummy chmod; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
fi
if test $SENSORS != "yes"; then
- CFSENSORS=""
- DFSENSORS=""
+ HAVE_SENSORS="n"
else
- CFSENSORS="-lsensors"
- DFSENSORS="-DHAVE_SENSORS"
+ HAVE_SENSORS="y"
fi
{ $as_echo "$as_me:$LINENO: result: $SENSORS" >&5
$as_echo "$SENSORS" >&6; }
# Check for lm_sensors
-HAVE_SENSORS=no
-DFLAGS=""
+SENSORS=no
+LFSENSORS=""
+DFSENSORS=""
{ $as_echo "$as_me:$LINENO: checking for sensors_get_detected_chips in -lsensors" >&5
$as_echo_n "checking for sensors_get_detected_chips in -lsensors... " >&6; }
if test "${ac_cv_lib_sensors_sensors_get_detected_chips+set}" = set; then
{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_sensors_sensors_get_detected_chips" >&5
$as_echo "$ac_cv_lib_sensors_sensors_get_detected_chips" >&6; }
if test "x$ac_cv_lib_sensors_sensors_get_detected_chips" = x""yes; then
- CFLAGS="${CFLAGS} ${CFSENSORS}"
+ LFSENSORS="-lsensors"
+else
+ HAVE_SENSORS="n"
fi
{ $as_echo "$as_me:$LINENO: checking for sensors lib" >&5
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- HAVE_SENSORS=yes; DFLAGS="${DFLAGS} ${DFSENSORS}"
+ SENSORS=yes; DFSENSORS="-DHAVE_SENSORS"
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- HAVE_SENSORS=no
+ HAVE_SENSORS="n"; SENSORS=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:$LINENO: result: $HAVE_SENSORS" >&5
-$as_echo "$HAVE_SENSORS" >&6; }
+{ $as_echo "$as_me:$LINENO: result: $SENSORS" >&5
+$as_echo "$SENSORS" >&6; }
+
+
echo .
AC_GNU_SOURCE
AC_PROG_LN_S
+DFLAGS=""
+
AC_CHECK_PROG(CHMOD, chmod, chmod)
AC_CHECK_PROG(CHOWN, chown, chown)
AC_CHECK_PROG(AR, ar, ar)
[disable sensors support]),
SENSORS=$enableval,SENSORS=yes)
if test $SENSORS != "yes"; then
- CFSENSORS=""
- DFSENSORS=""
+ HAVE_SENSORS="n"
else
- CFSENSORS="-lsensors"
- DFSENSORS="-DHAVE_SENSORS"
+ HAVE_SENSORS="y"
fi
AC_MSG_RESULT($SENSORS)
# Check for lm_sensors
-HAVE_SENSORS=no
-DFLAGS=""
-AC_CHECK_LIB(sensors, sensors_get_detected_chips, CFLAGS="${CFLAGS} ${CFSENSORS}")
+SENSORS=no
+LFSENSORS=""
+DFSENSORS=""
+AC_CHECK_LIB(sensors, sensors_get_detected_chips, LFSENSORS="-lsensors", HAVE_SENSORS="n")
AC_MSG_CHECKING(for sensors lib)
AC_TRY_COMPILE(#include <sensors/sensors.h>
#include <sensors/error.h>
- , sensors_cleanup();,HAVE_SENSORS=yes; DFLAGS="${DFLAGS} ${DFSENSORS}", HAVE_SENSORS=no)
-AC_MSG_RESULT($HAVE_SENSORS)
+ , sensors_cleanup();,SENSORS=yes; DFSENSORS="-DHAVE_SENSORS", HAVE_SENSORS="n"; SENSORS=no)
+AC_MSG_RESULT($SENSORS)
AC_SUBST(HAVE_SENSORS)
+AC_SUBST(LFSENSORS)
+AC_SUBST(DFSENSORS)
echo .
echo Check system services:
--- /dev/null
+/*
+ * rd_sensors.c: Read sensors statistics
+ * (C) 1999-2011 by Sebastien GODARD (sysstat <at> orange.fr)
+ *
+ ***************************************************************************
+ * 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 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 Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "common.h"
+#include "rd_sensors.h"
+
+#ifdef USE_NLS
+#include <locale.h>
+#include <libintl.h>
+#define _(string) gettext(string)
+#else
+#define _(string) (string)
+#endif
+
+#ifdef HAVE_SENSORS
+#include "sensors/sensors.h"
+#endif
+
+/*
+ ***************************************************************************
+ * Read fan statistics.
+ *
+ * IN:
+ * @st_pwr_fan Structure where stats will be saved.
+ * @nbr Total number of fans.
+ *
+ * OUT:
+ * @st_pwr_fan Structure with statistics.
+ ***************************************************************************
+ */
+void read_fan(struct stats_pwr_fan *st_pwr_fan, int nbr)
+{
+#ifdef HAVE_SENSORS
+ int count = 0;
+ const sensors_chip_name *chip;
+ const sensors_feature *feature;
+ const sensors_subfeature *sub;
+ struct stats_pwr_fan *st_pwr_fan_i;
+ int chip_nr = 0;
+ int i, j;
+
+ memset(st_pwr_fan, 0, STATS_PWR_FAN_SIZE);
+ int err = 0;
+
+ while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
+ i = 0;
+ while ((feature = sensors_get_features(chip, &i))) {
+ if ((feature->type == SENSORS_FEATURE_FAN) && (count < nbr)) {
+ j = 0;
+ st_pwr_fan_i = st_pwr_fan + count;
+ sensors_snprintf_chip_name(st_pwr_fan_i->device, MAX_SENSORS_DEV_LEN, chip);
+
+ while ((sub = sensors_get_all_subfeatures(chip, feature, &j))) {
+ if ((sub->type == SENSORS_SUBFEATURE_FAN_INPUT) &&
+ (sub->flags & SENSORS_MODE_R)) {
+ if ((err = sensors_get_value(chip, sub->number, &st_pwr_fan_i->rpm))) {
+ st_pwr_fan_i->rpm = 0;
+ }
+ }
+ else if ((sub->type == SENSORS_SUBFEATURE_FAN_MIN)) {
+ if ((err = sensors_get_value(chip, sub->number, &st_pwr_fan_i->rpm_min))) {
+ st_pwr_fan_i->rpm_min = 0;
+ }
+ }
+ }
+ count++;
+ }
+ }
+ }
+#endif /* HAVE_SENSORS */
+}
+
+/*
+ ***************************************************************************
+ * Read device temperature statistics.
+ *
+ * IN:
+ * @st_pwr_temp Structure where stats will be saved.
+ * @nbr Total number of fans.
+ *
+ * OUT:
+ * @st_pwr_temp Structure with statistics.
+ ***************************************************************************
+ */
+void read_temp(struct stats_pwr_temp *st_pwr_temp, int nbr)
+{
+#ifdef HAVE_SENSORS
+ int count = 0;
+ const sensors_chip_name *chip;
+ const sensors_feature *feature;
+ const sensors_subfeature *sub;
+ struct stats_pwr_temp *st_pwr_temp_i;
+ int chip_nr = 0;
+ int i, j;
+
+ memset(st_pwr_temp, 0, STATS_PWR_TEMP_SIZE);
+ int err = 0;
+
+ while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
+ i = 0;
+ while ((feature = sensors_get_features(chip, &i))) {
+ if ((feature->type == SENSORS_FEATURE_TEMP) && (count < nbr)) {
+ j = 0;
+ st_pwr_temp_i = st_pwr_temp + count;
+ sensors_snprintf_chip_name(st_pwr_temp_i->device, MAX_SENSORS_DEV_LEN, chip);
+
+ while ((sub = sensors_get_all_subfeatures(chip, feature, &j))) {
+ if ((sub->type == SENSORS_SUBFEATURE_TEMP_INPUT) &&
+ (sub->flags & SENSORS_MODE_R)) {
+ if ((err = sensors_get_value(chip, sub->number, &st_pwr_temp_i->temp))) {
+ st_pwr_temp_i->temp = 0;
+ }
+ }
+ else if ((sub->type == SENSORS_SUBFEATURE_TEMP_MIN)) {
+ if ((err = sensors_get_value(chip, sub->number, &st_pwr_temp_i->temp_min))) {
+ st_pwr_temp_i->temp_min = 0;
+ }
+ }
+ else if ((sub->type == SENSORS_SUBFEATURE_TEMP_MAX)) {
+ if ((err = sensors_get_value(chip, sub->number, &st_pwr_temp_i->temp_max))) {
+ st_pwr_temp_i->temp_max = 0;
+ }
+ }
+ }
+ count++;
+ }
+ }
+ }
+#endif /* HAVE_SENSORS */
+}
+
+/*
+ ***************************************************************************
+ * Read voltage inputs statistics.
+ *
+ * IN:
+ * @st_pwr_in Structure where stats will be saved.
+ * @nbr Total number of voltage inputs.
+ *
+ * OUT:
+ * @st_pwr_in Structure with statistics.
+ ***************************************************************************
+ */
+void read_in(struct stats_pwr_in *st_pwr_in, int nbr)
+{
+#ifdef HAVE_SENSORS
+ int count = 0;
+ const sensors_chip_name *chip;
+ const sensors_feature *feature;
+ const sensors_subfeature *sub;
+ struct stats_pwr_in *st_pwr_in_i;
+ int chip_nr = 0;
+ int i, j;
+
+ memset(st_pwr_in, 0, STATS_PWR_IN_SIZE);
+ int err = 0;
+
+ while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
+ i = 0;
+ while ((feature = sensors_get_features(chip, &i))) {
+ if ((feature->type == SENSORS_FEATURE_IN) && (count < nbr)) {
+ j = 0;
+ st_pwr_in_i = st_pwr_in + count;
+ sensors_snprintf_chip_name(st_pwr_in_i->device, MAX_SENSORS_DEV_LEN, chip);
+
+ while ((sub = sensors_get_all_subfeatures(chip, feature, &j))) {
+ if ((sub->type == SENSORS_SUBFEATURE_IN_INPUT) &&
+ (sub->flags & SENSORS_MODE_R)) {
+ if ((err = sensors_get_value(chip, sub->number, &st_pwr_in_i->in))) {
+ st_pwr_in_i->in = 0;
+ }
+ }
+ else if ((sub->type == SENSORS_SUBFEATURE_IN_MIN)) {
+ if ((err = sensors_get_value(chip, sub->number, &st_pwr_in_i->in_min))) {
+ st_pwr_in_i->in_min = 0;
+ }
+ }
+ else if ((sub->type == SENSORS_SUBFEATURE_IN_MAX)) {
+ if ((err = sensors_get_value(chip, sub->number, &st_pwr_in_i->in_max))) {
+ st_pwr_in_i->in_max = 0;
+ }
+ }
+ }
+ count++;
+ }
+ }
+ }
+#endif /* HAVE_SENSORS */
+}
+
+#ifdef HAVE_SENSORS
+/*
+ ***************************************************************************
+ * Count the number of sensors of given type on the machine.
+ *
+ * IN:
+ * @type Type of sensors.
+ *
+ * RETURNS:
+ * Number of sensors.
+ ***************************************************************************
+ */
+int get_sensors_nr(sensors_feature_type type) {
+ int count = 0;
+ const sensors_chip_name *chip;
+ const sensors_feature *feature;
+ int chip_nr = 0;
+ int i;
+
+ while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
+ i = 0;
+ while ((feature = sensors_get_features(chip, &i))) {
+ if (feature->type == type) {
+ count++;
+ }
+ }
+ }
+
+ return count;
+}
+#endif /* HAVE_SENSORS */
+
+/*
+ ***************************************************************************
+ * Count the number of fans on the machine.
+ *
+ * RETURNS:
+ * Number of fans.
+ ***************************************************************************
+ */
+int get_fan_nr(void)
+{
+#ifdef HAVE_SENSORS
+ return get_sensors_nr(SENSORS_FEATURE_FAN);
+#else
+ return 0;
+#endif /* HAVE_SENSORS */
+}
+
+/*
+ ***************************************************************************
+ * Count the number of temperature sensors on the machine.
+ *
+ * RETURNS:
+ * Number of temperature sensors.
+ ***************************************************************************
+ */
+int get_temp_nr(void)
+{
+#ifdef HAVE_SENSORS
+ return get_sensors_nr(SENSORS_FEATURE_TEMP);
+#else
+ return 0;
+#endif /* HAVE_SENSORS */
+
+}
+
+/*
+ ***************************************************************************
+ * Count the number of voltage inputs on the machine.
+ *
+ * RETURNS:
+ * Number of voltage inputs.
+ ***************************************************************************
+ */
+int get_in_nr(void)
+{
+#ifdef HAVE_SENSORS
+ return get_sensors_nr(SENSORS_FEATURE_IN);
+#else
+ return 0;
+#endif /* HAVE_SENSORS */
+
+}
--- /dev/null
+/*
+ * rd_sensors.h: Include file used to read sensors statistics
+ * (C) 1999-2011 by Sebastien Godard (sysstat <at> orange.fr)
+ */
+
+#ifndef _RD_SENSORS_H
+#define _RD_SENSORS_H
+
+#include "common.h"
+
+/*
+ ***************************************************************************
+ * Definitions of structures for sensors statistics
+ ***************************************************************************
+ */
+
+/*
+ * Structure for fan statistics.
+ */
+struct stats_pwr_fan {
+ double rpm __attribute__ ((aligned (8)));
+ double rpm_min __attribute__ ((aligned (8)));
+ char device[MAX_SENSORS_DEV_LEN] __attribute__ ((aligned (8)));
+};
+
+#define STATS_PWR_FAN_SIZE (sizeof(struct stats_pwr_fan))
+
+/*
+ * Structure for device temperature statistics.
+ */
+struct stats_pwr_temp {
+ double temp __attribute__ ((aligned (8)));
+ double temp_min __attribute__ ((aligned (8)));
+ double temp_max __attribute__ ((aligned (8)));
+ char device[MAX_SENSORS_DEV_LEN] __attribute__ ((aligned (8)));
+};
+
+#define STATS_PWR_TEMP_SIZE (sizeof(struct stats_pwr_temp))
+
+/*
+ * Structure for voltage inputs statistics.
+ */
+struct stats_pwr_in {
+ double in __attribute__ ((aligned (8)));
+ double in_min __attribute__ ((aligned (8)));
+ double in_max __attribute__ ((aligned (8)));
+ char device[MAX_SENSORS_DEV_LEN] __attribute__ ((aligned (8)));
+};
+
+#define STATS_PWR_IN_SIZE (sizeof(struct stats_pwr_in))
+
+/*
+ ***************************************************************************
+ * Prototypes for functions used to read sensors statistics
+ ***************************************************************************
+ */
+
+extern void
+ read_fan(struct stats_pwr_fan *, int);
+extern void
+ read_temp(struct stats_pwr_temp *, int);
+extern void
+ read_in(struct stats_pwr_in *, int);
+
+/*
+ ***************************************************************************
+ * Prototypes for functions used to count number of items
+ ***************************************************************************
+ */
+
+extern int
+ get_fan_nr(void);
+extern int
+ get_temp_nr(void);
+extern int
+ get_in_nr(void);
+
+#endif /* _RD_SENSORS_H */
#define _(string) (string)
#endif
-#ifdef HAVE_SENSORS
-#include "sensors/sensors.h"
-#endif
-
/*
***************************************************************************
* Read CPU statistics and machine uptime.
}
}
-/*
- ***************************************************************************
- * Read fan statistics.
- *
- * IN:
- * @st_pwr_fan Structure where stats will be saved.
- * @nbr Total number of fans.
- *
- * OUT:
- * @st_pwr_fan Structure with statistics.
- ***************************************************************************
- */
-void read_fan(struct stats_pwr_fan *st_pwr_fan, int nbr)
-{
-#ifdef HAVE_SENSORS
- int count = 0;
- const sensors_chip_name *chip;
- const sensors_feature *feature;
- const sensors_subfeature *sub;
- struct stats_pwr_fan *st_pwr_fan_i;
- int chip_nr = 0;
- int i, j;
-
- memset(st_pwr_fan, 0, STATS_PWR_FAN_SIZE);
- int err = 0;
-
- while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
- i = 0;
- while ((feature = sensors_get_features(chip, &i))) {
- if ((feature->type == SENSORS_FEATURE_FAN) && (count < nbr)) {
- j = 0;
- st_pwr_fan_i = st_pwr_fan + count;
- sensors_snprintf_chip_name(st_pwr_fan_i->device, MAX_SENSORS_DEV_LEN, chip);
-
- while ((sub = sensors_get_all_subfeatures(chip, feature, &j))) {
- if ((sub->type == SENSORS_SUBFEATURE_FAN_INPUT) &&
- (sub->flags & SENSORS_MODE_R)) {
- if ((err = sensors_get_value(chip, sub->number, &st_pwr_fan_i->rpm))) {
- st_pwr_fan_i->rpm = 0;
- }
- }
- else if ((sub->type == SENSORS_SUBFEATURE_FAN_MIN)) {
- if ((err = sensors_get_value(chip, sub->number, &st_pwr_fan_i->rpm_min))) {
- st_pwr_fan_i->rpm_min = 0;
- }
- }
- }
- count++;
- }
- }
- }
-#endif /* HAVE_SENSORS */
-}
-
-/*
- ***************************************************************************
- * Read device temperature statistics.
- *
- * IN:
- * @st_pwr_temp Structure where stats will be saved.
- * @nbr Total number of fans.
- *
- * OUT:
- * @st_pwr_temp Structure with statistics.
- ***************************************************************************
- */
-void read_temp(struct stats_pwr_temp *st_pwr_temp, int nbr)
-{
-#ifdef HAVE_SENSORS
- int count = 0;
- const sensors_chip_name *chip;
- const sensors_feature *feature;
- const sensors_subfeature *sub;
- struct stats_pwr_temp *st_pwr_temp_i;
- int chip_nr = 0;
- int i, j;
-
- memset(st_pwr_temp, 0, STATS_PWR_TEMP_SIZE);
- int err = 0;
-
- while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
- i = 0;
- while ((feature = sensors_get_features(chip, &i))) {
- if ((feature->type == SENSORS_FEATURE_TEMP) && (count < nbr)) {
- j = 0;
- st_pwr_temp_i = st_pwr_temp + count;
- sensors_snprintf_chip_name(st_pwr_temp_i->device, MAX_SENSORS_DEV_LEN, chip);
-
- while ((sub = sensors_get_all_subfeatures(chip, feature, &j))) {
- if ((sub->type == SENSORS_SUBFEATURE_TEMP_INPUT) &&
- (sub->flags & SENSORS_MODE_R)) {
- if ((err = sensors_get_value(chip, sub->number, &st_pwr_temp_i->temp))) {
- st_pwr_temp_i->temp = 0;
- }
- }
- else if ((sub->type == SENSORS_SUBFEATURE_TEMP_MIN)) {
- if ((err = sensors_get_value(chip, sub->number, &st_pwr_temp_i->temp_min))) {
- st_pwr_temp_i->temp_min = 0;
- }
- }
- else if ((sub->type == SENSORS_SUBFEATURE_TEMP_MAX)) {
- if ((err = sensors_get_value(chip, sub->number, &st_pwr_temp_i->temp_max))) {
- st_pwr_temp_i->temp_max = 0;
- }
- }
- }
- count++;
- }
- }
- }
-#endif /* HAVE_SENSORS */
-}
-
-/*
- ***************************************************************************
- * Read voltage inputs statistics.
- *
- * IN:
- * @st_pwr_in Structure where stats will be saved.
- * @nbr Total number of voltage inputs.
- *
- * OUT:
- * @st_pwr_in Structure with statistics.
- ***************************************************************************
- */
-void read_in(struct stats_pwr_in *st_pwr_in, int nbr)
-{
-#ifdef HAVE_SENSORS
- int count = 0;
- const sensors_chip_name *chip;
- const sensors_feature *feature;
- const sensors_subfeature *sub;
- struct stats_pwr_in *st_pwr_in_i;
- int chip_nr = 0;
- int i, j;
-
- memset(st_pwr_in, 0, STATS_PWR_IN_SIZE);
- int err = 0;
-
- while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
- i = 0;
- while ((feature = sensors_get_features(chip, &i))) {
- if ((feature->type == SENSORS_FEATURE_IN) && (count < nbr)) {
- j = 0;
- st_pwr_in_i = st_pwr_in + count;
- sensors_snprintf_chip_name(st_pwr_in_i->device, MAX_SENSORS_DEV_LEN, chip);
-
- while ((sub = sensors_get_all_subfeatures(chip, feature, &j))) {
- if ((sub->type == SENSORS_SUBFEATURE_IN_INPUT) &&
- (sub->flags & SENSORS_MODE_R)) {
- if ((err = sensors_get_value(chip, sub->number, &st_pwr_in_i->in))) {
- st_pwr_in_i->in = 0;
- }
- }
- else if ((sub->type == SENSORS_SUBFEATURE_IN_MIN)) {
- if ((err = sensors_get_value(chip, sub->number, &st_pwr_in_i->in_min))) {
- st_pwr_in_i->in_min = 0;
- }
- }
- else if ((sub->type == SENSORS_SUBFEATURE_IN_MAX)) {
- if ((err = sensors_get_value(chip, sub->number, &st_pwr_in_i->in_max))) {
- st_pwr_in_i->in_max = 0;
- }
- }
- }
- count++;
- }
- }
- }
-#endif /* HAVE_SENSORS */
-}
-
/*
***************************************************************************
* Read hugepages statistics from /proc/meminfo.
return irq;
}
-#ifdef HAVE_SENSORS
-/*
- ***************************************************************************
- * Count the number of sensors of given type on the machine.
- *
- * IN:
- * @type Type of sensors.
- *
- * RETURNS:
- * Number of sensors.
- ***************************************************************************
- */
-int get_sensors_nr(sensors_feature_type type) {
- int count = 0;
- const sensors_chip_name *chip;
- const sensors_feature *feature;
- int chip_nr = 0;
- int i;
-
- while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
- i = 0;
- while ((feature = sensors_get_features(chip, &i))) {
- if (feature->type == type) {
- count++;
- }
- }
- }
-
- return count;
-}
-#endif /* HAVE_SENSORS */
-
-/*
- ***************************************************************************
- * Count the number of fans on the machine.
- *
- * RETURNS:
- * Number of fans.
- ***************************************************************************
- */
-int get_fan_nr(void)
-{
-#ifdef HAVE_SENSORS
- return get_sensors_nr(SENSORS_FEATURE_FAN);
-#else
- return 0;
-#endif /* HAVE_SENSORS */
-}
-
-/*
- ***************************************************************************
- * Count the number of temperature sensors on the machine.
- *
- * RETURNS:
- * Number of temperature sensors.
- ***************************************************************************
- */
-int get_temp_nr(void)
-{
-#ifdef HAVE_SENSORS
- return get_sensors_nr(SENSORS_FEATURE_TEMP);
-#else
- return 0;
-#endif /* HAVE_SENSORS */
-
-}
-
-/*
- ***************************************************************************
- * Count the number of voltage inputs on the machine.
- *
- * RETURNS:
- * Number of voltage inputs.
- ***************************************************************************
- */
-int get_in_nr(void)
-{
-#ifdef HAVE_SENSORS
- return get_sensors_nr(SENSORS_FEATURE_IN);
-#else
- return 0;
-#endif /* HAVE_SENSORS */
-
-}
-
/*
***************************************************************************
* Count number of possible frequencies for CPU#0.
#define STATS_PWR_CPUFREQ_SIZE (sizeof(struct stats_pwr_cpufreq))
-/*
- * Structure for fan statistics.
- */
-struct stats_pwr_fan {
- double rpm __attribute__ ((aligned (8)));
- double rpm_min __attribute__ ((aligned (8)));
- char device[MAX_SENSORS_DEV_LEN] __attribute__ ((aligned (8)));
-};
-
-#define STATS_PWR_FAN_SIZE (sizeof(struct stats_pwr_fan))
-
-/*
- * Structure for device temperature statistics.
- */
-struct stats_pwr_temp {
- double temp __attribute__ ((aligned (8)));
- double temp_min __attribute__ ((aligned (8)));
- double temp_max __attribute__ ((aligned (8)));
- char device[MAX_SENSORS_DEV_LEN] __attribute__ ((aligned (8)));
-};
-
-#define STATS_PWR_TEMP_SIZE (sizeof(struct stats_pwr_temp))
-
-/*
- * Structure for voltage inputs statistics.
- */
-struct stats_pwr_in {
- double in __attribute__ ((aligned (8)));
- double in_min __attribute__ ((aligned (8)));
- double in_max __attribute__ ((aligned (8)));
- char device[MAX_SENSORS_DEV_LEN] __attribute__ ((aligned (8)));
-};
-
-#define STATS_PWR_IN_SIZE (sizeof(struct stats_pwr_in))
-
/* Structure for hugepages statistics */
struct stats_huge {
unsigned long frhkb __attribute__ ((aligned (8)));
read_net_udp6(struct stats_net_udp6 *);
extern void
read_cpuinfo(struct stats_pwr_cpufreq *, int);
-extern void
- read_fan(struct stats_pwr_fan *, int);
-extern void
- read_temp(struct stats_pwr_temp *, int);
-extern void
- read_in(struct stats_pwr_in *, int);
extern void
read_meminfo_huge(struct stats_huge *);
extern void
get_cpu_nr(unsigned int);
extern int
get_irqcpu_nr(char *, int, int);
-extern int
- get_fan_nr(void);
-extern int
- get_temp_nr(void);
-extern int
- get_in_nr(void);
extern int
get_freq_nr(void);
#include "common.h"
#include "rd_stats.h"
-
+#include "rd_sensors.h"
/*
***************************************************************************
#include "sa.h"
#include "rd_stats.h"
+#include "rd_sensors.h"
extern unsigned int flags;
extern struct record_header record_hdr;