Esempio n. 1
0
static void
process_i2c(picl_nodehdl_t childh,
                   const char propname[PICL_PROPNAMELEN_MAX])
{
  const char *settings[]={"OK",NULL};
  process_enum_sensor(childh, propname, MISC_TYPE, settings);
}
static int
process_led(picl_nodehdl_t childh,
                   char propname[PICL_PROPNAMELEN_MAX])
{

  char *settings[]={"OFF","ON","BLINK",NULL};
  process_enum_sensor(childh, propname, MISC_TYPE, settings);
}
Esempio n. 3
0
static void
process_switch(picl_nodehdl_t childh,
                   const char propname[PICL_PROPNAMELEN_MAX])
{

  const char *settings[]={"OFF","ON","NORMAL","LOCKED","UNKNOWN",
                   "DIAG","SECURE",NULL};

  process_enum_sensor(childh, propname, MISC_TYPE, settings);
}
Esempio n. 4
0
/*
 *  Recursively walk through the tree of sensors
 */
static int
process_sensors( int level, picl_nodehdl_t nodeh ) {
    picl_nodehdl_t childh, nexth;
    char           propname[  PICL_PROPNAMELEN_MAX  ];
    char           propclass[ PICL_CLASSNAMELEN_MAX ];
    picl_errno_t   error_code;

    level++;
    DEBUGMSGTL(("sensors:arch:detail", "process_sensors - level %d\n", level));

    /* Look up the first child node at this level */
    error_code = picl_get_propval_by_name( nodeh, PICL_PROP_CHILD,
                                           &childh, sizeof(childh));
    if ( error_code != PICL_SUCCESS ) {
        DEBUGMSGTL(("sensors:arch:detail", "Failed to get first child node (%d)\n",
                                            error_code));
        return( error_code );
    }

    /* Step through the child nodes, retrieving the name and class of each one */
    while ( error_code == PICL_SUCCESS ) {
        error_code = picl_get_propval_by_name( childh, PICL_PROP_NAME,
                                               propname, sizeof(propname)-1);
        if ( error_code != PICL_SUCCESS ) {
            /* The Node With No Name */
            DEBUGMSGTL(("sensors:arch:detail", "get property name failed (%d)\n",
                                                error_code));
            return( error_code );
        }

        error_code = picl_get_propval_by_name( childh, PICL_PROP_CLASSNAME,
                                               propclass, sizeof(propclass)-1);
        if ( error_code != PICL_SUCCESS ) {
            /* The Classless Society */
            DEBUGMSGTL(("sensors:arch:detail", "get property class failed (%d)\n",
                                                error_code));
            return( error_code );
        }

        DEBUGMSGTL(("sensors:arch:detail", "Name: %s, Class %s\n",
                                            propname, propclass ));


        /*
         *  Three classes represent further groups of sensors, etc.
         *  Call 'process_sensors' recursively to handle this next level
         */
        if (( strstr( propclass, "picl"    )) ||
            ( strstr( propclass, "frutree" )) ||
            ( strstr( propclass, "obp"     ))) {
            process_sensors( level, childh );
        }
        /*
         *  Otherwise retrieve the value appropriately based on the
         *     class of the sensor.
         *
         *  We need to specify the name of the PICL property to retrieve
         *     for this class of sensor, and the Net-SNMP sensor type.
         */
        else if ( strstr( propclass, "fan-tachometer" )) {
            process_num_sensor( childh, propname, "AtoDSensorValue",
                                                   NETSNMP_SENSOR_TYPE_RPM );
        } else if ( strstr( propclass, "fan" )) {
            process_num_sensor( childh, propname, "Speed",
                                                   NETSNMP_SENSOR_TYPE_RPM );
        } else if ( strstr( propclass, "temperature-sensor" )) {
            process_num_sensor( childh, propname, "Temperature",
                                                   NETSNMP_SENSOR_TYPE_TEMPERATURE );
        } else if ( strstr( propclass, "voltage-sensor" )) {
            process_num_sensor( childh, propname, "Voltage",
                                          /* ?? */ NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
        } else if ( strstr( propclass, "digital-sensor" )) {
            process_num_sensor( childh, propname, "AtoDSensorValue",
                                          /* ?? */ NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
            /*
             * Enumeration-valued sensors use a fixed PICL property ("State"),
             *   but take a list of the values appropriate for that sensor,
             *   as well as the Net-SNMP sensor type.
             */
        } else if ( strstr( propclass, "switch" )) {
            process_enum_sensor( childh, propname, NETSNMP_SENSOR_TYPE_OTHER,
                                                   switch_settings );
        } else if ( strstr( propclass, "led" )) {
            process_enum_sensor( childh, propname, NETSNMP_SENSOR_TYPE_OTHER,
                                                   led_settings );
        } else if ( strstr( propclass, "i2c" )) {
            process_enum_sensor( childh, propname, NETSNMP_SENSOR_TYPE_BOOLEAN, /* ?? */
                                                   i2c_settings );
        } else {
            /* Skip other classes of sensor */
            DEBUGMSGTL(("sensors:arch:detail", "Skipping class %s\n", propclass ));
        }

        /*
         *  Move on to the next child node at the current level (if any)
         */
        error_code = picl_get_propval_by_name( childh, PICL_PROP_PEER,
                                               &nexth, sizeof(nexth));
        if ( error_code != PICL_SUCCESS ) {
            /* That's All Folks! */
            return (( error_code == PICL_PROPNOTFOUND )
                          ? PICL_SUCCESS : error_code );
        }
        childh = nexth;
    }
    
    return error_code;
}