~ubuntu-branches/ubuntu/precise/net-snmp/precise

« back to all changes in this revision

Viewing changes to debian/patches/60_libsensors_api.patch

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-11-26 01:27:00 UTC
  • mfrom: (1.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091126012700-pox7w0a5j2x305h9
Tags: 5.4.2.1~dfsg-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - Set Ubuntu maintainer address.
  - net-snmp-config: Use bash. (LP: #104738)
  - Removed multiuser option when calling update-rc.d. (LP: #254261)
  - debian/snmpd.init: LSBify the init script.
  - debian/patches/52_fix_snmpcmd_1_typo.patch: Adjust a typo in snmpcmd.1
    (LP: #250459)
  - debian/patches/99-fix-ubuntu-div0.patch: Fix dvision by zero.
    (LP: #426813).
 * Dropped patches:
   - debian/patches/101-fix-ipalias.patch: Applied upstream.
   - debian/patches/99-fix-net-snmp-syslog.patch: Applied upstream.
   - debian/patches/99-fix-perl-counter-in-subagent.patch: Applied upstream.
   - ebian/patches/103-fix-ubuntu-lmsensors.patch: No longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff --git a/agent/mibgroup/ucd-snmp/lmSensors.c b/agent/mibgroup/ucd-snmp/lmSensors.c
 
2
index d7dbd98..8f9fcd2 100644
 
3
--- a/agent/mibgroup/ucd-snmp/lmSensors.c
 
4
+++ b/agent/mibgroup/ucd-snmp/lmSensors.c
 
5
@@ -390,7 +390,7 @@ static int
 
6
 sensor_load(void)
 
7
 {
 
8
     int rc = 0;
 
9
-    time_t        t = time(NULL);
 
10
+    time_t        t = time(NULL);
 
11
 
 
12
     if (t > timestamp + 7) /* this may require some tuning - currently 7 seconds*/
 
13
     {
 
14
@@ -962,77 +962,78 @@ else{
 
15
     } /* end for */
 
16
 
 
17
     while ((chip = sensors_get_detected_chips(&chip_nr))) {
 
18
-       int             a = 0;
 
19
-       int             b = 0;
 
20
+        int             a = 0;
 
21
+            int             b = 0;
 
22
 
 
23
-        while ((data = sensors_get_all_features(*chip, &a, &b))) {
 
24
-            char           *label = NULL;
 
25
-            double          val;
 
26
+            while ((data = sensors_get_all_features(*chip, &a, &b))) {
 
27
+                char           *label = NULL;
 
28
+                double          val;
 
29
 
 
30
-            if ((data->mode & SENSORS_MODE_R) &&
 
31
-                (data->mapping == SENSORS_NO_MAPPING) &&
 
32
-                !sensors_get_label(*chip, data->number, &label) &&
 
33
-                !sensors_get_feature(*chip, data->number, &val)) {
 
34
-                int             type = -1;
 
35
-                float           mul;
 
36
-                _sensor_array  *array;
 
37
+                if ((data->mode & SENSORS_MODE_R) &&
 
38
+                    (data->mapping == SENSORS_NO_MAPPING) &&
 
39
+                    !sensors_get_label(*chip, data->number, &label) &&
 
40
+                    !sensors_get_feature(*chip, data->number, &val)) {
 
41
+                    int             type = -1;
 
42
+                    float           mul;
 
43
+                    _sensor_array  *array;
 
44
 
 
45
-                /* The label, as determined for a given chip in sensors.conf,
 
46
-                 * is used to place each sensor in the appropriate bucket.
 
47
-                 * Volt, Fan, Temp, and Misc.  If the text being looked for below
 
48
-                 * is not in the label of a given sensor (e.g., the temp1 sensor
 
49
-                 * has been labeled 'CPU' and not 'CPU temp') it will end up being
 
50
-                 * lumped in the MISC bucket. */
 
51
+                    /* The label, as determined for a given chip in
 
52
+                     * sensors.conf, is used to place each sensor in the
 
53
+                     * appropriate bucket.  Volt, Fan, Temp, and Misc.
 
54
+                     * If the text being looked for below is not in the
 
55
+                     * label of a given sensor (e.g., the temp1 sensor
 
56
+                     * has been labeled 'CPU' and not 'CPU temp') it
 
57
+                     * will end up being lumped in the MISC bucket. */
 
58
 
 
59
-                if (strstr(label, "V")) {
 
60
-                    type = VOLT_TYPE;
 
61
-                    mul = 1000.0;
 
62
-                }
 
63
-                if (strstr(label, "fan") || strstr(label, "Fan")) {
 
64
-                    type = FAN_TYPE;
 
65
-                    mul = 1.0;
 
66
-                }
 
67
-                if (strstr(label, "temp") || strstr(label, "Temp")) {
 
68
-                    type = TEMP_TYPE;
 
69
-                    mul = 1000.0;
 
70
-                }
 
71
-                if (type == -1) {
 
72
-                    type = MISC_TYPE;
 
73
-                    mul = 1000.0;
 
74
-                }
 
75
+                    if (strstr(label, "V")) {
 
76
+                        type = VOLT_TYPE;
 
77
+                        mul = 1000.0;
 
78
+                    }
 
79
+                    if (strstr(label, "fan") || strstr(label, "Fan")) {
 
80
+                        type = FAN_TYPE;
 
81
+                        mul = 1.0;
 
82
+                    }
 
83
+                    if (strstr(label, "temp") || strstr(label, "Temp")) {
 
84
+                        type = TEMP_TYPE;
 
85
+                        mul = 1000.0;
 
86
+                    }
 
87
+                    if (type == -1) {
 
88
+                        type = MISC_TYPE;
 
89
+                        mul = 1000.0;
 
90
+                    }
 
91
 
 
92
-                array = &sensor_array[type];
 
93
-                if ( array->current_len <= array->n) {
 
94
-                    _sensor* old_buffer = array->sensor;
 
95
-                    size_t new_size = (sizeof(_sensor) * array->current_len) + (sizeof(_sensor) * DEFAULT_SENSORS);
 
96
-                    array->sensor = (_sensor*)realloc(array->sensor, new_size);
 
97
-                    if (array->sensor == NULL)
 
98
-                    {
 
99
-                       /* Continuing would be unsafe */
 
100
-                       snmp_log(LOG_ERR, "too many sensors to fit, and failed to alloc more, failing on %s\n", label);
 
101
-                       free(old_buffer);
 
102
-                       old_buffer = NULL;
 
103
-                       if (label) {
 
104
-                           free(label);
 
105
-                           label = NULL;
 
106
-                       } /* end if label */
 
107
-                       return (rc=1);
 
108
-                    } /* end if array->sensor */
 
109
-                    array->current_len = new_size / sizeof(_sensor);
 
110
-                    DEBUGMSG(("ucd-snmp/lmSensors", "type #%d increased to %d elements\n", type, array->current_len));
 
111
-                } /* end if array->current */
 
112
-                strncpy(array->sensor[array->n].name, label, MAX_NAME);
 
113
-                array->sensor[array->n].value = (int) (val * mul);
 
114
-                DEBUGMSGTL(("sensors","sensor %d, value %d\n",
 
115
-                            array->sensor[array->n].name,
 
116
-                            array->sensor[array->n].value));
 
117
-                array->n++;
 
118
-            } /* end if data-mode */
 
119
-           if (label) {
 
120
-               free(label);
 
121
-               label = NULL;
 
122
-           } /* end if label */
 
123
-        } /* end while data */
 
124
+                    array = &sensor_array[type];
 
125
+                    if ( array->current_len <= array->n) {
 
126
+                        _sensor* old_buffer = array->sensor;
 
127
+                        size_t new_size = (sizeof(_sensor) * array->current_len) + (sizeof(_sensor) * DEFAULT_SENSORS);
 
128
+                        array->sensor = (_sensor*)realloc(array->sensor, new_size);
 
129
+                        if (array->sensor == NULL)
 
130
+                        {
 
131
+                           /* Continuing would be unsafe */
 
132
+                           snmp_log(LOG_ERR, "too many sensors to fit, and failed to alloc more, failing on %s\n", label);
 
133
+                           free(old_buffer);
 
134
+                           old_buffer = NULL;
 
135
+                           if (label) {
 
136
+                               free(label);
 
137
+                               label = NULL;
 
138
+                           } /* end if label */
 
139
+                           return (rc=1);
 
140
+                        } /* end if array->sensor */
 
141
+                        array->current_len = new_size / sizeof(_sensor);
 
142
+                        DEBUGMSG(("ucd-snmp/lmSensors", "type #%d increased to %d elements\n", type, array->current_len));
 
143
+                    } /* end if array->current */
 
144
+                    strncpy(array->sensor[array->n].name, label, MAX_NAME);
 
145
+                    array->sensor[array->n].value = (int) (val * mul);
 
146
+                    DEBUGMSGTL(("sensors","sensor %d, value %d\n",
 
147
+                                array->sensor[array->n].name,
 
148
+                                array->sensor[array->n].value));
 
149
+                    array->n++;
 
150
+                } /* end if data-mode */
 
151
+                if (label) {
 
152
+                    free(label);
 
153
+                    label = NULL;
 
154
+                } /* end if label */
 
155
+            } /* end while data */
 
156
     } /* end while chip */
 
157
     return rc;
 
158
 #endif  /* end else ie. ifdef everything else */
 
159
diff --git a/agent/mibgroup/ucd-snmp/lmSensors.c b/agent/mibgroup/ucd-snmp/lmSensors.c
 
160
index 8f9fcd2..e42e0e2 100644
 
161
--- a/agent/mibgroup/ucd-snmp/lmSensors.c
 
162
+++ b/agent/mibgroup/ucd-snmp/lmSensors.c
 
163
@@ -89,7 +89,6 @@
 
164
     #include </usr/platform/sun4u/include/sys/envctrl.h>
 
165
 #else
 
166
     #include <sensors/sensors.h>
 
167
-    #define CONFIG_FILE_NAME "/etc/sensors.conf"
 
168
 #endif
 
169
 
 
170
 #include "lmSensors.h"
 
171
@@ -247,7 +246,7 @@ var_lmSensorsTable(struct variable *vp,
 
172
                    size_t * var_len, WriteMethod ** write_method)
 
173
 {
 
174
     static long     long_ret;
 
175
-    static unsigned char string[SPRINT_MAX_LEN];
 
176
+    static char string[SPRINT_MAX_LEN];
 
177
 
 
178
     int             s_index;
 
179
     int             s_type = -1;
 
180
@@ -352,9 +351,7 @@ sensor_init(void)
 
181
 {
 
182
     int             res;
 
183
 #ifndef solaris2
 
184
-    char            filename[] = CONFIG_FILE_NAME;
 
185
     time_t          t = time(NULL);
 
186
-    FILE            *fp = fopen(filename, "r");
 
187
     int             i = 0;
 
188
   
 
189
     DEBUGMSG(("ucd-snmp/lmSensors", "=> sensor_init\n"));
 
190
@@ -366,13 +363,7 @@ sensor_init(void)
 
191
         sensor_array[i].sensor = NULL;
 
192
     }
 
193
 
 
194
-    if (!fp)
 
195
-    {
 
196
-        res = 1;
 
197
-        goto leaving;
 
198
-    }
 
199
-
 
200
-    if (sensors_init(fp))
 
201
+    if (sensors_init(NULL))
 
202
     {
 
203
         res = 2;
 
204
         goto leaving;
 
205
@@ -940,7 +931,8 @@ else{
 
206
 #else /* end solaris2 only ie. ifdef everything else */
 
207
 
 
208
     const sensors_chip_name *chip;
 
209
-    const sensors_feature_data *data;
 
210
+    const sensors_feature *feature;
 
211
+    const sensors_subfeature *subfeature;
 
212
     int             chip_nr = 0;
 
213
     int             rc = 0;
 
214
     unsigned int    i = 0;
 
215
@@ -961,18 +953,19 @@ else{
 
216
         sensor_array[i].current_len = DEFAULT_SENSORS;
 
217
     } /* end for */
 
218
 
 
219
-    while ((chip = sensors_get_detected_chips(&chip_nr))) {
 
220
+    while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
 
221
         int             a = 0;
 
222
+        while ((feature = sensors_get_features(chip, &a))) {
 
223
             int             b = 0;
 
224
-
 
225
-            while ((data = sensors_get_all_features(*chip, &a, &b))) {
 
226
+            while ((subfeature = sensors_get_all_subfeatures(chip,
 
227
+                    feature, &b))) {
 
228
                 char           *label = NULL;
 
229
                 double          val;
 
230
 
 
231
-                if ((data->mode & SENSORS_MODE_R) &&
 
232
-                    (data->mapping == SENSORS_NO_MAPPING) &&
 
233
-                    !sensors_get_label(*chip, data->number, &label) &&
 
234
-                    !sensors_get_feature(*chip, data->number, &val)) {
 
235
+                if ((subfeature->flags & SENSORS_MODE_R) &&
 
236
+                    (subfeature->mapping == 0) &&
 
237
+                    (label = sensors_get_label(chip, feature)) &&
 
238
+                    !sensors_get_value(chip, subfeature->number, &val)) {
 
239
                     int             type = -1;
 
240
                     float           mul;
 
241
                     _sensor_array  *array;
 
242
@@ -1033,7 +1026,8 @@ else{
 
243
                     free(label);
 
244
                     label = NULL;
 
245
                 } /* end if label */
 
246
-            } /* end while data */
 
247
+            } /* end while subfeature */
 
248
+        } /* end while feature */
 
249
     } /* end while chip */
 
250
     return rc;
 
251
 #endif  /* end else ie. ifdef everything else */