Package: mrtgutils
Severity: normal

here's a patch to fix both of the bugs mentioned above

-- System Information:
Debian Release: squeeze/sid
  APT prefers stable
  APT policy: (750, 'stable'), (700, 'testing'), (600, 'unstable'), (550, 
'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.30-bpo.1-686 (SMP w/1 CPU core)
Locale: LANG=en_ZA, LC_CTYPE=en_ZA (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/bash

Versions of packages mrtgutils depends on:
ii  libc6                         2.9-4      GNU C Library: Shared libraries

Versions of packages mrtgutils recommends:
ii  libsensors3                   1:2.10.8-2 library to read temperature/voltag

Versions of packages mrtgutils suggests:
ii  lm-sensors                    1:3.1.1-4  utilities to read temperature/volt
ii  mrtg                          2.16.2-3   multi router traffic grapher

-- no debconf information
diff -ur mrtgutils-0.7/debian/changelog mrtgutils-0.7+nr1/debian/changelog
--- mrtgutils-0.7/debian/changelog	2008-04-20 03:00:22.000000000 +0100
+++ mrtgutils-0.7+nr1/debian/changelog	2010-01-03 20:08:26.307754669 +0000
@@ -1,3 +1,10 @@
+mrtgutils (0.7+nr1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Migrate to libsensors4. Closes: #563556
+
+ -- Norman Rasmussen <[email protected]>  Sun, 03 Jan 2010 20:07:12 +0000
+
 mrtgutils (0.7) unstable; urgency=low
 
   * The "It's time to grown up" release 
diff -ur mrtgutils-0.7/debian/control mrtgutils-0.7+nr1/debian/control
--- mrtgutils-0.7/debian/control	2008-04-20 03:03:13.000000000 +0100
+++ mrtgutils-0.7+nr1/debian/control	2010-01-03 19:26:32.267748767 +0000
@@ -1,7 +1,7 @@
 Source: mrtgutils
 Section: net
 Priority: optional
-Build-Depends: debhelper, libsensors-dev [i386]
+Build-Depends: debhelper, libsensors4-dev [i386]
 Maintainer: Luciano Bello <[email protected]>
 Standards-Version: 3.7.3
 
diff -ur mrtgutils-0.7/mrtg-sensors.c mrtgutils-0.7+nr1/mrtg-sensors.c
--- mrtgutils-0.7/mrtg-sensors.c	2001-03-04 07:16:41.000000000 +0000
+++ mrtgutils-0.7+nr1/mrtg-sensors.c	2010-01-03 20:06:19.504902515 +0000
@@ -9,7 +9,8 @@
 
 int print_value(char *chipname, char *label, double mult) {
 	int a, b, chip_nr, gotchip;
-	const sensors_feature_data *feature;
+	const sensors_feature *feature;
+	const sensors_subfeature *subfeature;
 	char *name;
 	double val;
 	const sensors_chip_name *chip;
@@ -32,21 +33,28 @@
 	 * matches the parsed name is found.
 	 */
 	for (gotchip= chip_nr = 0;
-	     ! gotchip && (chip = sensors_get_detected_chips(&chip_nr));)
-		if (sensors_match_chip(chipparsed, *chip))
-			gotchip = 1;
+	     ! gotchip && (chip = sensors_get_detected_chips(&chipparsed, &chip_nr));)
+		gotchip = 1;
+
+	if (!gotchip) {
+		fprintf(stderr, "could not find chip, \"%s\"\n", chipname);
+		printf("0\n");
+		return(0);
+	}
 
 	/*
 	 * Now get all features and iterate through to find
 	 * the one that was requested.
 	 */
 	a=b=0;
-	while ((feature=sensors_get_all_features(*chip,&a,&b))) {
-		if ((sensors_get_label(*chip, feature->number, &name)) == 0 &&
-		    (strcmp(name, label) == 0) &&
-		    (sensors_get_feature(*chip, feature->number, &val)) == 0) {
-	                printf("%.0f\n", val * mult);
-			return(1);
+	while ((feature=sensors_get_features(chip, &a))) {
+		while ((subfeature=sensors_get_all_subfeatures(chip, feature, &b))) {
+			if ((name = sensors_get_label(chip, feature)) &&
+			    (strcmp(name, label) == 0) &&
+			    (sensors_get_value(chip, subfeature->number, &val)) == 0) {
+				printf("%.0f\n", val * mult);
+				return(1);
+			}
 		}
 	}
 
@@ -61,7 +69,6 @@
 }
 
 int main (int argc, char *argv[]) {
-	FILE *config_file;
 	int res, c, success = 1;
 	double mult = 1;
 
@@ -75,14 +82,8 @@
 	if (optind >= argc || (argc - optind != 2 && argc - optind != 4))
 		usage();
 
-	config_file = fopen("/etc/sensors.conf", "r");
-	if (! config_file) {
-		/* Allow the program to work w/o a config file. */
-		config_file = fopen("/dev/null", "r");
-	}
-	
-	if ((res = sensors_init(config_file))) {
-		if (res == SENSORS_ERR_PROC) {
+	if ((res = sensors_init(NULL))) {
+		if (res == SENSORS_ERR_KERNEL) {
 			fprintf(stderr,
 				"/proc/sys/dev/sensors/chips or /proc/bus/i2c unreadable:\n"
 				"Make sure you have inserted modules sensors.o and i2c-proc.o!");

Reply via email to