961
953
sensor_array[i].current_len = DEFAULT_SENSORS;
964
while ((chip = sensors_get_detected_chips(&chip_nr))) {
968
while ((data = sensors_get_all_features(*chip, &a, &b))) {
972
if ((data->mode & SENSORS_MODE_R) &&
973
(data->mapping == SENSORS_NO_MAPPING) &&
974
!sensors_get_label(*chip, data->number, &label) &&
975
!sensors_get_feature(*chip, data->number, &val)) {
978
_sensor_array *array;
980
/* The label, as determined for a given chip in sensors.conf,
981
* is used to place each sensor in the appropriate bucket.
982
* Volt, Fan, Temp, and Misc. If the text being looked for below
983
* is not in the label of a given sensor (e.g., the temp1 sensor
984
* has been labeled 'CPU' and not 'CPU temp') it will end up being
985
* lumped in the MISC bucket. */
987
if (strstr(label, "V")) {
991
if (strstr(label, "fan") || strstr(label, "Fan")) {
995
if (strstr(label, "temp") || strstr(label, "Temp")) {
1004
array = &sensor_array[type];
1005
if ( array->current_len <= array->n) {
1006
_sensor* old_buffer = array->sensor;
1007
size_t new_size = (sizeof(_sensor) * array->current_len) + (sizeof(_sensor) * DEFAULT_SENSORS);
1008
array->sensor = (_sensor*)realloc(array->sensor, new_size);
1009
if (array->sensor == NULL)
1011
/* Continuing would be unsafe */
1012
snmp_log(LOG_ERR, "too many sensors to fit, and failed to alloc more, failing on %s\n", label);
1018
} /* end if label */
1020
} /* end if array->sensor */
1021
array->current_len = new_size / sizeof(_sensor);
1022
DEBUGMSG(("ucd-snmp/lmSensors", "type #%d increased to %d elements\n", type, array->current_len));
1023
} /* end if array->current */
1024
strncpy(array->sensor[array->n].name, label, MAX_NAME);
1025
array->sensor[array->n].value = (int) (val * mul);
1026
DEBUGMSGTL(("sensors","sensor %d, value %d\n",
1027
array->sensor[array->n].name,
1028
array->sensor[array->n].value));
1030
} /* end if data-mode */
1034
} /* end if label */
1035
} /* end while data */
956
while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
958
while ((feature = sensors_get_features(chip, &a))) {
960
while ((subfeature = sensors_get_all_subfeatures(chip,
965
if ((subfeature->flags & SENSORS_MODE_R) &&
966
(label = sensors_get_label(chip, feature)) &&
967
!sensors_get_value(chip, subfeature->number, &val)) {
970
_sensor_array *array;
972
/* The label, as determined for a given chip in
973
* sensors.conf, is used to place each sensor in the
974
* appropriate bucket. Volt, Fan, Temp, and Misc.
975
* If the text being looked for below is not in the
976
* label of a given sensor (e.g., the temp1 sensor
977
* has been labeled 'CPU' and not 'CPU temp') it
978
* will end up being lumped in the MISC bucket. */
980
if (strstr(label, "V")) {
984
if (strstr(label, "fan") || strstr(label, "Fan")) {
988
if (strstr(label, "temp") || strstr(label, "Temp")) {
997
array = &sensor_array[type];
998
if ( array->current_len <= array->n) {
999
_sensor* old_buffer = array->sensor;
1000
size_t new_size = (sizeof(_sensor) * array->current_len) + (sizeof(_sensor) * DEFAULT_SENSORS);
1001
array->sensor = (_sensor*)realloc(array->sensor, new_size);
1002
if (array->sensor == NULL)
1004
/* Continuing would be unsafe */
1005
snmp_log(LOG_ERR, "too many sensors to fit, and failed to alloc more, failing on %s\n", label);
1011
} /* end if label */
1013
} /* end if array->sensor */
1014
array->current_len = new_size / sizeof(_sensor);
1015
DEBUGMSG(("ucd-snmp/lmSensors", "type #%d increased to %d elements\n", type, array->current_len));
1016
} /* end if array->current */
1017
strncpy(array->sensor[array->n].name, label, MAX_NAME);
1018
array->sensor[array->n].value = (int) (val * mul);
1019
DEBUGMSGTL(("sensors","sensor %d, value %d\n",
1020
array->sensor[array->n].name,
1021
array->sensor[array->n].value));
1023
} /* end if data-mode */
1027
} /* end if label */
1028
} /* end while subfeature */
1029
} /* end while feature */
1036
1030
} /* end while chip */
1038
1032
#endif /* end else ie. ifdef everything else */