SOURCES: net-snmp-lm_sensors_3.patch (NEW) - patch to allow buildi...

hawk hawk at pld-linux.org
Sat May 3 23:13:06 CEST 2008


Author: hawk                         Date: Sat May  3 21:13:06 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- patch to allow building with lm_sensors 3.x library

---- Files affected:
SOURCES:
   net-snmp-lm_sensors_3.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/net-snmp-lm_sensors_3.patch
diff -u /dev/null SOURCES/net-snmp-lm_sensors_3.patch:1.1
--- /dev/null	Sat May  3 23:13:06 2008
+++ SOURCES/net-snmp-lm_sensors_3.patch	Sat May  3 23:13:01 2008
@@ -0,0 +1,1326 @@
+351991: Port net-snmp to lm_sensors-3.x.x
+Source: upstream, svn diff -r 16736:16739
+Reviewed-By: Jan Safranek <jsafrane at redhat.com>
+
+Index: configure
+===================================================================
+--- configure	(revision 16736)
++++ configure	(revision 16739)
+@@ -32628,7 +32628,7 @@
+ fi
+ 
+ # LM-SENSORS-MIB support
+-echo " $module_list " | grep " ucd-snmp/lmSensors " > /dev/null
++echo " $module_list " | $GREP -i "ucd-snmp/lmsensor" > /dev/null
+ if test $? -eq 0 ; then
+         { echo "$as_me:$LINENO: checking for sensors support" >&5
+ echo $ECHO_N "checking for sensors support... $ECHO_C" >&6; }
+Index: include/net-snmp/agent/hardware/sensors.h
+===================================================================
+--- include/net-snmp/agent/hardware/sensors.h	(revision 0)
++++ include/net-snmp/agent/hardware/sensors.h	(revision 16739)
+@@ -0,0 +1,48 @@
++/*
++ * Hardware Abstraction Layer - Sensors module
++ *
++ * Public interface
++ */
++
++#define NETSNMP_SENSOR_TYPE_OTHER       1
++#define NETSNMP_SENSOR_TYPE_VOLTAGE_AC  3
++#define NETSNMP_SENSOR_TYPE_VOLTAGE_DC  4
++#define NETSNMP_SENSOR_TYPE_CURRENT     5
++#define NETSNMP_SENSOR_TYPE_POWER       6
++#define NETSNMP_SENSOR_TYPE_FREQUENCY   7
++#define NETSNMP_SENSOR_TYPE_TEMPERATURE 8
++#define NETSNMP_SENSOR_TYPE_HUMIDITY    9
++#define NETSNMP_SENSOR_TYPE_RPM        10
++#define NETSNMP_SENSOR_TYPE_VOLUME     11
++#define NETSNMP_SENSOR_TYPE_BOOLEAN    12
++
++
++#define NETSNMP_SENSOR_FLAG_ACTIVE     0x01
++#define NETSNMP_SENSOR_FLAG_NAVAIL     0x02
++#define NETSNMP_SENSOR_FLAG_BROKEN     0x04
++#define NETSNMP_SENSOR_FLAG_DISABLE    0x08
++
++#define NETSNMP_SENSOR_MASK_STATUS     0x06  /* NAVAIL|BROKEN */
++
++
++#define NETSNMP_SENSOR_FIND_CREATE     1   /* or use one of the sensor type values */
++#define NETSNMP_SENSOR_FIND_EXIST      0
++
++typedef struct netsnmp_sensor_info_s netsnmp_sensor_info;
++struct netsnmp_sensor_info_s {
++
++    netsnmp_index  idx;
++    /* int  idx; */
++    char  name[256];
++    
++    int   type;
++    float value;
++    char  descr[256];
++    long  flags;
++};
++
++netsnmp_container   *get_sensor_container( void );
++netsnmp_cache       *get_sensor_cache( void );
++netsnmp_sensor_info *sensor_by_name( char *, int );
++NetsnmpCacheLoad     netsnmp_sensor_load;
++NetsnmpCacheFree     netsnmp_sensor_free;
+Index: configure.in
+===================================================================
+--- configure.in	(revision 16736)
++++ configure.in	(revision 16739)
+@@ -2885,7 +2885,7 @@
+ fi
+ 
+ # LM-SENSORS-MIB support
+-echo " $module_list " | grep " ucd-snmp/lmSensors " > /dev/null
++echo " $module_list " | $GREP -i "ucd-snmp/lmsensor" > /dev/null
+ if test $? -eq 0 ; then
+         AC_MSG_CHECKING([for sensors support])
+         case $target_os in
+Index: agent/mibgroup/ucd-snmp/lmsensorsMib.c
+===================================================================
+--- agent/mibgroup/ucd-snmp/lmsensorsMib.c	(revision 0)
++++ agent/mibgroup/ucd-snmp/lmsensorsMib.c	(revision 16739)
+@@ -0,0 +1,205 @@
++#include <net-snmp/net-snmp-config.h>
++#include <net-snmp/net-snmp-includes.h>
++#include <net-snmp/agent/net-snmp-agent-includes.h>
++#include <net-snmp/agent/hardware/sensors.h>
++#include "ucd-snmp/lmsensorsMib.h"
++
++netsnmp_container *sensorContainer = NULL;
++
++void initialize_lmSensorsTable(const char *tableName, oid *tableOID,
++                               netsnmp_container_op *filter, int mult );
++
++int _sensor_filter_temp( netsnmp_container *c, const void *v );
++int _sensor_filter_fan(  netsnmp_container *c, const void *v );
++int _sensor_filter_volt( netsnmp_container *c, const void *v );
++int _sensor_filter_misc( netsnmp_container *c, const void *v );
++
++static oid lmTempSensorsTable_oid[]   = {1,3,6,1,4,1,2021,13,16,2};
++static oid lmFanSensorsTable_oid[]    = {1,3,6,1,4,1,2021,13,16,3};
++static oid lmVoltSensorsTable_oid[]   = {1,3,6,1,4,1,2021,13,16,4};
++static oid lmMiscSensorsTable_oid[]   = {1,3,6,1,4,1,2021,13,16,5};
++            /* All the tables have the same length root OID */
++size_t     lmSensorsTables_oid_len = OID_LENGTH(lmMiscSensorsTable_oid);
++
++
++/* Initialise the LM Sensors MIB module */
++void
++init_lmsensorsMib(void)
++{
++    DEBUGMSGTL(("ucd-snmp/lmsensorsMib","Initializing LM-SENSORS-MIB tables\n"));
++
++    /* 
++     * Initialise the four LM-SENSORS-MIB tables
++     *
++     * They are almost identical, so we can use the same registration code.
++     */
++    initialize_lmSensorsTable( "lmTempSensorsTable", lmTempSensorsTable_oid,
++                                _sensor_filter_temp, 1000 );  /* MIB asks for mC */
++    initialize_lmSensorsTable( "lmFanSensorsTable",  lmFanSensorsTable_oid,
++                                _sensor_filter_fan,  1);
++    initialize_lmSensorsTable( "lmVoltSensorsTable", lmVoltSensorsTable_oid,
++                                _sensor_filter_volt, 1000 );  /* MIB asks for mV */
++    initialize_lmSensorsTable( "lmMiscSensorsTable", lmMiscSensorsTable_oid,
++                                _sensor_filter_misc, 1 );
++}
++
++/*
++ * Common initialisation code, used for setting up all four tables
++ */
++void
++initialize_lmSensorsTable(const char *tableName, oid *tableOID,
++                          netsnmp_container_op *filter, int mult )
++{
++    netsnmp_handler_registration    *reg;
++    netsnmp_table_registration_info *table_info;
++    netsnmp_cache     *cache;
++    netsnmp_container *container;
++
++    /*
++     * Ensure the HAL sensors module has been initialised,
++     *   and retrieve the main sensors container.
++     * This table will then be registered using a filter on this container.
++     */
++    sensorContainer = get_sensor_container();
++    if ( !sensorContainer ) {
++        init_hw_sensors( );
++        sensorContainer = get_sensor_container();
++    }
++    container = netsnmp_container_find("sensorTable:table_container");
++    container->insert_filter = filter;
++    netsnmp_container_add_index( sensorContainer, container );
++
++
++    /*
++     * Create a basic registration structure for the table
++     */
++    reg = netsnmp_create_handler_registration(
++               tableName, lmSensorsTables_handler,
++               tableOID,  lmSensorsTables_oid_len, HANDLER_CAN_RONLY
++              );
++
++    /*
++     * Register the table using the filtered container
++     * Include an indicator of any scaling to be applied to the sensor value
++     */
++    reg->my_reg_void = (void *)mult;
++    table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
++    netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, 0);
++    table_info->min_column = COLUMN_LMSENSORS_INDEX;
++    table_info->max_column = COLUMN_LMSENSORS_VALUE;
++    netsnmp_container_table_register( reg, table_info, container, 0 );
++
++    /*
++     * If the HAL sensors module was configured as an on-demand caching
++     *  module (rather than being automatically loaded regularly),
++     *  then ensure this table makes use of that cache.
++     */
++    cache = get_sensor_cache();
++    if ( cache ) {
++        netsnmp_inject_handler_before( reg, netsnmp_cache_handler_get( cache ),
++                                            "table_container");
++    }
++
++}
++
++
++/*
++ *  Container filters for the four tables
++ *
++ *  Used to ensure that sensor entries appear in the appropriate table.
++ */
++int _sensor_filter_temp( netsnmp_container *c, const void *v ) {
++    const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
++    /* Only matches temperature sensors */
++    return (( sp->type == NETSNMP_SENSOR_TYPE_TEMPERATURE ) ? 0 : 1 );
++}
++
++int _sensor_filter_fan( netsnmp_container *c, const void *v ) {
++    const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
++    /* Only matches fan sensors */
++    return (( sp->type == NETSNMP_SENSOR_TYPE_RPM ) ? 0 : 1 );
++}
++
++int _sensor_filter_volt( netsnmp_container *c, const void *v ) {
++    const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
++    /* Only matches voltage sensors (AC or DC) */
++    return ((( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_DC ) ||
++             ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_AC )) ? 0 : 1 );
++}
++
++int _sensor_filter_misc( netsnmp_container *c, const void *v ) {
++    const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
++    /* Matches everything except temperature, fan or voltage sensors */
++    return ((( sp->type == NETSNMP_SENSOR_TYPE_TEMPERATURE ) ||
++             ( sp->type == NETSNMP_SENSOR_TYPE_RPM         ) ||
++             ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_DC  ) ||
++             ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_AC  )) ? 1 : 0 );
++}
++
++
++/*
++ * Handle requests for any of the four lmXxxxSensorsTables 
++ *
++ * This is possible because all the table share the
++ *  same structure and behaviour.
++ */
++int
++lmSensorsTables_handler(
++    netsnmp_mib_handler               *handler,
++    netsnmp_handler_registration      *reginfo,
++    netsnmp_agent_request_info        *reqinfo,
++    netsnmp_request_info              *requests) {
++
++    netsnmp_request_info       *request;
++    netsnmp_table_request_info *table_info;
++    netsnmp_sensor_info        *sensor_info;
++    int mult  = (int)reginfo->my_reg_void;
++
++    DEBUGMSGTL(( "ucd-snmp/lmsensorsMib","lmSensorsTables_handler - root: "));
++    DEBUGMSGOID(("ucd-snmp/lmsensorsMib", reginfo->rootoid, reginfo->rootoid_len));
++    DEBUGMSG((   "ucd-snmp/lmsensorsMib",", mode %d\n", reqinfo->mode ));
++    /*
++     * This is a read-only table, so we only need to handle GET requests.
++     *    (The container helper converts GETNEXT->GET requests automatically).
++     */
++    switch (reqinfo->mode) {
++    case MODE_GET:
++        for (request=requests; request; request=request->next) {
++            sensor_info = (netsnmp_sensor_info *)
++                            netsnmp_container_table_extract_context(request);
++            if ( !sensor_info ) {
++                netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
++                continue;
++            }
++    
++            table_info   =  netsnmp_extract_table_info(request);
++            switch (table_info->colnum) {
++            case COLUMN_LMSENSORS_INDEX:
++                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
++                                            sensor_info->idx.oids[0]);
++                break;
++            case COLUMN_LMSENSORS_DEVICE:
++                if ( sensor_info->descr[0] != '\0' ) {
++                    snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
++                                              sensor_info->descr, strlen(sensor_info->descr));
++                } else {
++                    snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
++                                              sensor_info->name,  strlen(sensor_info->name));
++                }
++                break;
++            case COLUMN_LMSENSORS_VALUE:
++                /* Multiply the value by the appropriate scaling factor for this table */
++                snmp_set_var_typed_integer( request->requestvb, ASN_GAUGE,
++                                            (int)(mult*sensor_info->value));
++                break;
++            default:
++                netsnmp_set_request_error(reqinfo, request,
++                                          SNMP_NOSUCHOBJECT);
++                break;
++            }
++        }
++        break;
++
++    }
++    return SNMP_ERR_NOERROR;
++}
+Index: agent/mibgroup/ucd-snmp/lmsensorsMib.h
+===================================================================
+--- agent/mibgroup/ucd-snmp/lmsensorsMib.h	(revision 0)
++++ agent/mibgroup/ucd-snmp/lmsensorsMib.h	(revision 16739)
+@@ -0,0 +1,23 @@
++#ifndef LM_SENSORS_MIB_H
++#define LM_SENSORS_MIB_H
++
++config_require(hardware/sensors)
++config_add_mib(LM-SENSORS-MIB)
++
++/* function declarations */
++void init_lmsensorsMib(void);
++
++/*
++ * Handler and Column definitions for lmXxxxSensorsTable
++ *
++ * Note that the same handler (and hence the same
++ *  column identifiers) are used for all four tables.
++ * This is possible because all the table share the
++ *  same structure and behaviour.
++ */
++Netsnmp_Node_Handler lmSensorsTables_handler;
++#define COLUMN_LMSENSORS_INDEX		1
++#define COLUMN_LMSENSORS_DEVICE		2
++#define COLUMN_LMSENSORS_VALUE		3
++
++#endif /* LM_SENSORS_MIB_H */
+Index: agent/mibgroup/hardware/sensors.h
+===================================================================
+--- agent/mibgroup/hardware/sensors.h	(revision 0)
++++ agent/mibgroup/hardware/sensors.h	(revision 16739)
+@@ -0,0 +1,13 @@
++config_require(hardware/sensors/hw_sensors)
++
++#if defined(solaris)
++# if defined(HAVE_PICL_H)
++config_require(hardware/sensors/picld_sensors)
++# else
++config_require(hardware/sensors/kstat_sensors)
++# endif
++#else
++config_require(hardware/sensors/lmsensors_v3)
++#endif
++
++//config_require(hardware/sensors/dummy_sensors)
+Index: agent/mibgroup/hardware/sensors/hw_sensors.h
+===================================================================
+--- agent/mibgroup/hardware/sensors/hw_sensors.h	(revision 0)
++++ agent/mibgroup/hardware/sensors/hw_sensors.h	(revision 16739)
+@@ -0,0 +1 @@
++void init_hw_sensors( void );
+Index: agent/mibgroup/hardware/sensors/lmsensors_v2.h
+===================================================================
+--- agent/mibgroup/hardware/sensors/lmsensors_v2.h	(revision 0)
++++ agent/mibgroup/hardware/sensors/lmsensors_v2.h	(revision 16739)
+@@ -0,0 +1 @@
++config_require(hardware/sensors/hw_sensors)
+Index: agent/mibgroup/hardware/sensors/kstat_sensors.c
+===================================================================
+--- agent/mibgroup/hardware/sensors/kstat_sensors.c	(revision 0)
++++ agent/mibgroup/hardware/sensors/kstat_sensors.c	(revision 16739)
+@@ -0,0 +1,161 @@
++#include <net-snmp/net-snmp-config.h>
++#include <net-snmp/net-snmp-includes.h>
++#include <net-snmp/agent/net-snmp-agent-includes.h>
++#include <net-snmp/agent/hardware/sensors.h>
++
++#include "util_funcs.h"
++#include <time.h>
++
++#include <kstat.h>
++#include </usr/platform/sun4u/include/sys/envctrl.h>
++
++void netsnmp_sensor_arch_init( void ) {
++    DEBUGMSGTL(("sensors:arch", "Initialise KStat Sensors module\n"));
++}
++
++
++int
++netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
++    netsnmp_sensor_info        *sp;
++
++    int         i;
++    const char *fantypes[]={"CPU","PWR","AFB"};
++    char        name[ 256 ];
++
++    kstat_ctl_t    *kc;
++    kstat_t        *kp;
++    envctrl_fan_t  *fan_info;
++    envctrl_ps_t   *power_info;
++    envctrl_encl_t *enc_info;
++
++
++    DEBUGMSGTL(("sensors:arch", "Reload KStat Sensors module\n"));
++
++    kc = kstat_open();
++    if ( kc == 0) {
++        DEBUGMSGTL(("sensors:arch", "Couldn't open kstat\n"));
++        return 1;
++    }
++    
++
++    /*
++     * Retrieve fan information
++     */
++    kp = kstat_lookup( kc, ENVCTRL_MODULE_NAME, 0, ENVCTRL_KSTAT_FANSTAT);
++    if (( kp == 0 ) || (kstat_read( kc, kp, 0 ) == -1 )) {
++        DEBUGMSGTL(("sensors:arch", "No fan information\n"));
++    } else {
++        fan_info = (envctrl_fan_t *)kp->ks_data;        
++        for (i=0; i<kp->ks_ndata; i++) {
++            memset( name, 0, 256 );
++            snprintf( name, 255, "%s%d", fantypes[fan_info->type], fan_info->instance );
++
++            sp = sensor_by_name( name, NETSNMP_SENSOR_TYPE_RPM );
++            if ( sp ) {
++                sp->value = fan_info->fanspeed;
++                sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++                snprintf( sp->descr, 255, "fan type %s number %d",
++                          fantypes[fan_info->type], fan_info->instance );
++            }
++    
++            fan_info++;
++        }
++    }
++
++
++    /*
++     * Retrieve Power Supply information
++     */
++    kp = kstat_lookup( kc, ENVCTRL_MODULE_NAME, 0, ENVCTRL_KSTAT_PSNAME);
++    if (( kp == 0 ) || (kstat_read( kc, kp, 0 ) == -1 )) {
++        DEBUGMSGTL(("sensors:arch", "No PSU information\n"));
++    } else {
++        power_info = (envctrl_ps_t *)kp->ks_data;        
++        for (i=0; i<kp->ks_ndata; i++) {
++            memset( name, 0, 256 );
++            snprintf( name, 255, "PSU%d", power_info->instance );
++
++            sp = sensor_by_name( name, NETSNMP_SENSOR_TYPE_TEMPERATURE);
++            if ( sp ) {
++                sp->value = power_info->ps_tempr;
++                sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++                snprintf( sp->descr, 255, "power supply %d", power_info->instance );
++            }
++    
++            power_info++;
++        }
++    }
++
++
++    /*
++     * Retrieve Enclosure information
++     */
++    kp = kstat_lookup( kc, ENVCTRL_MODULE_NAME, 0, ENVCTRL_KSTAT_ENCL);
++    if (( kp == 0 ) || (kstat_read( kc, kp, 0 ) == -1 )) {
++        DEBUGMSGTL(("sensors:arch", "No enclosure information\n"));
++    } else {
++        enc_info = (envctrl_encl_t *)kp->ks_data;        
++        for (i=0; i<kp->ks_ndata; i++) {
++            /*
++             * The enclosure information covers several different types of sensor
++             */
++            switch ( enc_info->type ) {
++            case ENVCTRL_ENCL_FSP:
++                DEBUGMSGTL(("sensors:arch:detail", "Enclosure Front Panel\n"));
++                sp = sensor_by_name( "FSP", NETSNMP_SENSOR_TYPE_OTHER);
++                if ( sp ) {
++                    sp->value = enc_info->value;
++                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++                }
++                break;
++                
++            case ENVCTRL_ENCL_AMBTEMPR:
++                DEBUGMSGTL(("sensors:arch:detail", "Enclosure Ambient Temperature\n"));
++                sp = sensor_by_name( "Ambient", NETSNMP_SENSOR_TYPE_TEMPERATURE);
++                if ( sp ) {
++                    sp->value = enc_info->value;
++                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++                }
++                break;
++
++            case ENVCTRL_ENCL_CPUTEMPR:
++                DEBUGMSGTL(("sensors:arch:detail", "Enclosure CPU Temperature\n"));
++                memset( name, 0, 256 );
++                snprintf( name, 255, "CPU%d", enc_info->instance );
++                sp = sensor_by_name( name, NETSNMP_SENSOR_TYPE_TEMPERATURE);
++                if ( sp ) {
++                    sp->value = enc_info->value;
++                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++                    snprintf( sp->descr, 255, "CPU%d temperature", enc_info->instance );
++                }
++                break;
++
++            case ENVCTRL_ENCL_BACKPLANE4:
++                DEBUGMSGTL(("sensors:arch:detail", "Enclosure Backplane4\n"));
++                sp = sensor_by_name( "Backplane4", NETSNMP_SENSOR_TYPE_OTHER);
++                if ( sp ) {
++                    sp->value = enc_info->value;
++                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++                }
++                break;
++                
++            case ENVCTRL_ENCL_BACKPLANE8:
++                DEBUGMSGTL(("sensors:arch:detail", "Enclosure Backplane4\n"));
++                sp = sensor_by_name( "Backplane4", NETSNMP_SENSOR_TYPE_OTHER);
++                if ( sp ) {
++                    sp->value = enc_info->value;
++                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++                }
++                break;
++
++            default:    
++                DEBUGMSGTL(("sensors:arch:detail", "Unrecognised Enclosure entry (%d)n",
++                                                    enc_info->type));
++            }
++
++            enc_info++;
++        }
++    }
++
++    return 0;
++}
+Index: agent/mibgroup/hardware/sensors/lmsensors_v3.h
+===================================================================
+--- agent/mibgroup/hardware/sensors/lmsensors_v3.h	(revision 0)
++++ agent/mibgroup/hardware/sensors/lmsensors_v3.h	(revision 16739)
+@@ -0,0 +1 @@
++config_require(hardware/sensors/hw_sensors)
+Index: agent/mibgroup/hardware/sensors/dummy_sensors.c
+===================================================================
+--- agent/mibgroup/hardware/sensors/dummy_sensors.c	(revision 0)
++++ agent/mibgroup/hardware/sensors/dummy_sensors.c	(revision 16739)
+@@ -0,0 +1,60 @@
++#include <net-snmp/net-snmp-config.h>
++#include <net-snmp/net-snmp-includes.h>
++#include <net-snmp/agent/net-snmp-agent-includes.h>
++#include <net-snmp/agent/hardware/sensors.h>
++
++
++void netsnmp_sensor_arch_init( void ) {
++    /* Nothing to do */
++    DEBUGMSGTL(("sensors:arch", "Initialise Dummy Sensors module\n"));
++}
++
++int
++netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
++    time_t now;
++    struct tm                  *tm;
++    netsnmp_sensor_info        *sp;
++
++    time(&now);
++    tm = localtime(&now);
++
++    DEBUGMSGTL(("sensors:arch", "Reload Dummy Sensors module\n"));
++
++    /* First pseudo-sensor - slowly-rising temperature */
++    sp = sensor_by_name( "minute", NETSNMP_SENSOR_TYPE_TEMPERATURE );
++    sp->value = tm->tm_min;
++    snprintf( sp->descr, 256, "Minute-based pseudo-sensor - slowly-rising temperature" );
++    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++
++    /* Second pseudo-sensor - quickly-rising temperature */
++    sp = sensor_by_name( "second", NETSNMP_SENSOR_TYPE_TEMPERATURE );
++    sp->value = tm->tm_sec;
++    snprintf( sp->descr, 256, "Second-based pseudo-sensor - quickly-rising temperature" );
++    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++
++    /* Third pseudo-sensor - annual fan speed */
++    sp = sensor_by_name( "year", NETSNMP_SENSOR_TYPE_RPM );
++    sp->value = tm->tm_year + 1900;
++    snprintf( sp->descr, 256, "RPM pseudo-sensor - annual fan speed" );
++    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++
++    /* Fourth pseudo-sensor - daily voltage */
++    sp = sensor_by_name( "day", NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
++    sp->value = tm->tm_mday-20;
++    snprintf( sp->descr, 256, "Day-based pseudo-sensor - positive or negative voltage" );
++    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++
++    /* Fifth pseudo-sensor - monthly voltage */
++    sp = sensor_by_name( "month", NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
++    sp->value = tm->tm_mon;
++    snprintf( sp->descr, 256, "Month-based pseudo-sensor - positive voltage" );
++    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++
++    /* Sixth pseudo-sensor - annual daily something */
++    sp = sensor_by_name( "yday", NETSNMP_SENSOR_TYPE_OTHER );
++    sp->value = tm->tm_yday;
++    snprintf( sp->descr, 256, "Day-based pseudo-sensor - annual something" );
++    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
++
++    return 0;
++}
+Index: agent/mibgroup/hardware/sensors/kstat_sensors.h
+===================================================================
+--- agent/mibgroup/hardware/sensors/kstat_sensors.h	(revision 0)
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list