示例#1
0
static void
process_enum_sensor(picl_nodehdl_t childh, 
                  const char propname[PICL_PROPNAMELEN_MAX], 
                  int typ, const char **options)
{
  int value = 0;
  picl_errno_t error_code;
 
  if (sensor_array[typ].n >= MAX_SENSORS){
    DEBUGMSGTL(("ucd-snmp/lmSensors",
               "There are too many sensors of type %d\n",typ));
  } else{
    error_code = read_enum_sensor(childh, options, &value);
    
    if (error_code == PICL_SUCCESS) {
      sensor_array[typ].sensor[sensor_array[typ].n].value = value;
      snprintf(sensor_array[typ].sensor[sensor_array[typ].n].name,
              (PICL_PROPNAMELEN_MAX - 1),"%s",propname);
      sensor_array[typ].sensor[sensor_array[typ].n].
       name[PICL_PROPNAMELEN_MAX - 1] = '\0';
      sensor_array[typ].n++;
    } else
      DEBUGMSGTL(("ucd-snmp/lmSensors",
                 "read of %s in process_enum_sensor returned error code %d\n", propname, error_code));
  }
} /* end process_enum_sensor() */
示例#2
0
static int
process_enum_sensor( picl_nodehdl_t childh, const char *propname, int typ, const char **options )
{
    netsnmp_sensor_info        *sp;
    float                       value;
    picl_errno_t    error_code;

    sp = sensor_by_name( propname, typ );
    if ( !sp ) {
         return -1;
    }

    error_code = read_enum_sensor( childh, &value, options );
    if ( error_code == PICL_SUCCESS ) {
        sp->value = value;
        sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
    } else {
        DEBUGMSGTL(("sensors:arch:detail", "Failed to read %s sensor value (%d)\n",
                                            propname, error_code));
        return -1;
    }
    return 0;
}