Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 279423 | Differences between
and this patch

Collapse All | Expand All

(-)/dev/null (+60 lines)
Added Link Here
1
#include <net-snmp/net-snmp-config.h>
2
#include <net-snmp/net-snmp-includes.h>
3
#include <net-snmp/agent/net-snmp-agent-includes.h>
4
#include <net-snmp/agent/hardware/sensors.h>
5
6
7
void netsnmp_sensor_arch_init( void ) {
8
    /* Nothing to do */
9
    DEBUGMSGTL(("sensors:arch", "Initialise Dummy Sensors module\n"));
10
}
11
12
int
13
netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
14
    time_t now;
15
    struct tm                  *tm;
16
    netsnmp_sensor_info        *sp;
17
18
    time(&now);
19
    tm = localtime(&now);
20
21
    DEBUGMSGTL(("sensors:arch", "Reload Dummy Sensors module\n"));
22
23
    /* First pseudo-sensor - slowly-rising temperature */
24
    sp = sensor_by_name( "minute", NETSNMP_SENSOR_TYPE_TEMPERATURE );
25
    sp->value = tm->tm_min;
26
    snprintf( sp->descr, 256, "Minute-based pseudo-sensor - slowly-rising temperature" );
27
    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
28
29
    /* Second pseudo-sensor - quickly-rising temperature */
30
    sp = sensor_by_name( "second", NETSNMP_SENSOR_TYPE_TEMPERATURE );
31
    sp->value = tm->tm_sec;
32
    snprintf( sp->descr, 256, "Second-based pseudo-sensor - quickly-rising temperature" );
33
    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
34
35
    /* Third pseudo-sensor - annual fan speed */
36
    sp = sensor_by_name( "year", NETSNMP_SENSOR_TYPE_RPM );
37
    sp->value = tm->tm_year + 1900;
38
    snprintf( sp->descr, 256, "RPM pseudo-sensor - annual fan speed" );
39
    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
40
41
    /* Fourth pseudo-sensor - daily voltage */
42
    sp = sensor_by_name( "day", NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
43
    sp->value = tm->tm_mday-20;
44
    snprintf( sp->descr, 256, "Day-based pseudo-sensor - positive or negative voltage" );
45
    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
46
47
    /* Fifth pseudo-sensor - monthly voltage */
48
    sp = sensor_by_name( "month", NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
49
    sp->value = tm->tm_mon;
50
    snprintf( sp->descr, 256, "Month-based pseudo-sensor - positive voltage" );
51
    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
52
53
    /* Sixth pseudo-sensor - annual daily something */
54
    sp = sensor_by_name( "yday", NETSNMP_SENSOR_TYPE_OTHER );
55
    sp->value = tm->tm_yday;
56
    snprintf( sp->descr, 256, "Day-based pseudo-sensor - annual something" );
57
    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
58
59
    return 0;
60
}
(-)/dev/null (+1 lines)
Added Link Here
1
config_require(hardware/sensors/hw_sensors)
(-)/dev/null (+13 lines)
Added Link Here
1
config_require(hardware/sensors/hw_sensors)
2
3
#if defined(solaris)
4
# if defined(HAVE_PICL_H)
5
config_require(hardware/sensors/picld_sensors)
6
# else
7
config_require(hardware/sensors/kstat_sensors)
8
# endif
9
#else
10
config_require(hardware/sensors/lmsensors_v3)
11
#endif
12
13
//config_require(hardware/sensors/dummy_sensors)
(-)/dev/null (+183 lines)
Added Link Here
1
#include <net-snmp/net-snmp-config.h>
2
#include <net-snmp/net-snmp-includes.h>
3
#include <net-snmp/agent/net-snmp-agent-includes.h>
4
#include <net-snmp/agent/hardware/sensors.h>
5
6
7
extern NetsnmpCacheLoad netsnmp_sensor_arch_load;
8
extern void             netsnmp_sensor_arch_init( void );
9
static int  _sensor_load( void );
10
static void _sensor_free( void );
11
12
static int _sensorAutoUpdate = 0;   /* 0 means on-demand caching */
13
static void _sensor_update_stats( unsigned int, void* );
14
15
netsnmp_cache     *_sensor_cache     = NULL;
16
netsnmp_container *_sensor_container = NULL;
17
static int         _sensor_idx       = 0;
18
19
void init_hw_sensors( void ) {
20
21
    if ( _sensor_container )
22
        return;   /* Already initialised */
23
24
    DEBUGMSGTL(("sensors", "Initialise Hardware Sensors module\n"));
25
26
    /*
27
     * Define a container to hold the basic list of sensors
28
     * The four LM-SENSOR-MIB containers will be created in
29
     *  the relevant initialisation routine(s)
30
     */
31
    _sensor_container = netsnmp_container_find("sensorTable:table_container");
32
    if ( NULL == _sensor_container ) {
33
        snmp_log( LOG_ERR, "failed to create container for sensorTable");
34
        return;
35
    }
36
    netsnmp_sensor_arch_init( );
37
38
    /*
39
     * If we're sampling the sensor information automatically,
40
     *   then arrange for this to be triggered regularly.
41
     *
42
     * If we're not sampling these values regularly,
43
     *   create a suitable cache handler instead.
44
     */
45
    if ( _sensorAutoUpdate ) {
46
        DEBUGMSGTL(("sensors", "Reloading Hardware Sensors automatically (%d)\n",
47
                               _sensorAutoUpdate));
48
        snmp_alarm_register( _sensorAutoUpdate, SA_REPEAT,
49
                             _sensor_update_stats, NULL );
50
    }
51
    else {
52
        _sensor_cache = netsnmp_cache_create( 5, netsnmp_sensor_load,
53
                                                 netsnmp_sensor_free, NULL, 0 );
54
        DEBUGMSGTL(("sensors", "Reloading Hardware Sensors on-demand (%p)\n",
55
                               _sensor_cache));
56
    }
57
}
58
59
void shutdown_hw_sensors( void ) {
60
    _sensor_free();
61
}
62
63
/*
64
 *  Return the main sensor container
65
 */
66
netsnmp_container *get_sensor_container( void ) { return _sensor_container; }
67
68
/*
69
 *  Return the main sensor cache control structure (if defined)
70
 */
71
netsnmp_cache *get_sensor_cache( void ) { return _sensor_cache; }
72
73
74
/*
75
 * Wrapper routine for automatically updating sensor statistics
76
 */
77
void
78
_sensor_update_stats( unsigned int clientreg, void *data )
79
{
80
    _sensor_free();
81
    _sensor_load();
82
}
83
84
/*
85
 * Wrapper routine for re-loading sensor statistics on demand
86
 */
87
int
88
netsnmp_sensor_load( netsnmp_cache *cache, void *data )
89
{
90
    return _sensor_load();
91
}
92
93
/*
94
 * Wrapper routine for releasing expired sensor statistics
95
 */
96
void
97
netsnmp_sensor_free( netsnmp_cache *cache, void *data )
98
{
99
    _sensor_free();
100
}
101
102
103
/*
104
 * Architecture-independent processing of loading sensor statistics
105
 */
106
static int
107
_sensor_load( void )
108
{
109
    netsnmp_sensor_arch_load( NULL, NULL );
110
}
111
112
/*
113
 * Architecture-independent release of sensor statistics
114
 */
115
static void
116
_sensor_free( void )
117
{
118
    netsnmp_sensor_info *sp;
119
120
    for (sp = CONTAINER_FIRST( _sensor_container );
121
         sp;
122
         sp = CONTAINER_NEXT(  _sensor_container, sp )) {
123
124
         sp->flags &= ~ NETSNMP_SENSOR_FLAG_ACTIVE;
125
    }
126
}
127
128
129
/*
130
 * Retrieve a sensor entry by name,
131
 *  or (optionally) insert a new one into the container
132
 */
133
netsnmp_sensor_info *
134
sensor_by_name( char *name, int create_type )
135
{
136
    netsnmp_sensor_info *sp;
137
138
    DEBUGMSGTL(("sensors:name", "Get sensor entry (%s)\n", name));
139
140
    /*
141
     *  Look through the list for a matching entry
142
     */
143
        /* .. or use a secondary index container ?? */
144
    for (sp = CONTAINER_FIRST( _sensor_container );
145
         sp;
146
         sp = CONTAINER_NEXT(  _sensor_container, sp )) {
147
148
        if ( !strcmp( name, sp->name ))
149
            return sp;
150
    }
151
152
    /*
153
     * Not found...
154
     */
155
    if ( create_type == NETSNMP_SENSOR_FIND_EXIST ) {
156
        DEBUGMSGTL(("sensors:name", "No such sensor entry\n"));
157
        return NULL;
158
    }
159
160
    /*
161
     * ... so let's create a new one, using the type supplied
162
     */
163
    sp = SNMP_MALLOC_TYPEDEF( netsnmp_sensor_info );
164
    if ( sp ) {
165
        strcpy( sp->name, name );
166
        sp->type = create_type;
167
        /*
168
         * Set up the index value.
169
         *  
170
         * All this trouble, just for a simple integer.
171
         * Surely there must be a better way?
172
         */
173
        sp->idx.len  = 1;
174
        sp->idx.oids = SNMP_MALLOC_TYPEDEF( oid );
175
        sp->idx.oids[0] = ++_sensor_idx;
176
    }
177
178
    DEBUGMSGTL(("sensors:name", "Create sensor entry (type = %d, index = %d\n",
179
                                 create_type, _sensor_idx));
180
    CONTAINER_INSERT( _sensor_container, sp );
181
    return sp;
182
}
183
(-)/dev/null (+1 lines)
Added Link Here
1
void init_hw_sensors( void );
(-)/dev/null (+161 lines)
Added Link Here
1
#include <net-snmp/net-snmp-config.h>
2
#include <net-snmp/net-snmp-includes.h>
3
#include <net-snmp/agent/net-snmp-agent-includes.h>
4
#include <net-snmp/agent/hardware/sensors.h>
5
6
#include "util_funcs.h"
7
#include <time.h>
8
9
#include <kstat.h>
10
#include </usr/platform/sun4u/include/sys/envctrl.h>
11
12
void netsnmp_sensor_arch_init( void ) {
13
    DEBUGMSGTL(("sensors:arch", "Initialise KStat Sensors module\n"));
14
}
15
16
17
int
18
netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
19
    netsnmp_sensor_info        *sp;
20
21
    int         i;
22
    const char *fantypes[]={"CPU","PWR","AFB"};
23
    char        name[ 256 ];
24
25
    kstat_ctl_t    *kc;
26
    kstat_t        *kp;
27
    envctrl_fan_t  *fan_info;
28
    envctrl_ps_t   *power_info;
29
    envctrl_encl_t *enc_info;
30
31
32
    DEBUGMSGTL(("sensors:arch", "Reload KStat Sensors module\n"));
33
34
    kc = kstat_open();
35
    if ( kc == 0) {
36
        DEBUGMSGTL(("sensors:arch", "Couldn't open kstat\n"));
37
        return 1;
38
    }
39
    
40
41
    /*
42
     * Retrieve fan information
43
     */
44
    kp = kstat_lookup( kc, ENVCTRL_MODULE_NAME, 0, ENVCTRL_KSTAT_FANSTAT);
45
    if (( kp == 0 ) || (kstat_read( kc, kp, 0 ) == -1 )) {
46
        DEBUGMSGTL(("sensors:arch", "No fan information\n"));
47
    } else {
48
        fan_info = (envctrl_fan_t *)kp->ks_data;        
49
        for (i=0; i<kp->ks_ndata; i++) {
50
            memset( name, 0, 256 );
51
            snprintf( name, 255, "%s%d", fantypes[fan_info->type], fan_info->instance );
52
53
            sp = sensor_by_name( name, NETSNMP_SENSOR_TYPE_RPM );
54
            if ( sp ) {
55
                sp->value = fan_info->fanspeed;
56
                sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
57
                snprintf( sp->descr, 255, "fan type %s number %d",
58
                          fantypes[fan_info->type], fan_info->instance );
59
            }
60
    
61
            fan_info++;
62
        }
63
    }
64
65
66
    /*
67
     * Retrieve Power Supply information
68
     */
69
    kp = kstat_lookup( kc, ENVCTRL_MODULE_NAME, 0, ENVCTRL_KSTAT_PSNAME);
70
    if (( kp == 0 ) || (kstat_read( kc, kp, 0 ) == -1 )) {
71
        DEBUGMSGTL(("sensors:arch", "No PSU information\n"));
72
    } else {
73
        power_info = (envctrl_ps_t *)kp->ks_data;        
74
        for (i=0; i<kp->ks_ndata; i++) {
75
            memset( name, 0, 256 );
76
            snprintf( name, 255, "PSU%d", power_info->instance );
77
78
            sp = sensor_by_name( name, NETSNMP_SENSOR_TYPE_TEMPERATURE);
79
            if ( sp ) {
80
                sp->value = power_info->ps_tempr;
81
                sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
82
                snprintf( sp->descr, 255, "power supply %d", power_info->instance );
83
            }
84
    
85
            power_info++;
86
        }
87
    }
88
89
90
    /*
91
     * Retrieve Enclosure information
92
     */
93
    kp = kstat_lookup( kc, ENVCTRL_MODULE_NAME, 0, ENVCTRL_KSTAT_ENCL);
94
    if (( kp == 0 ) || (kstat_read( kc, kp, 0 ) == -1 )) {
95
        DEBUGMSGTL(("sensors:arch", "No enclosure information\n"));
96
    } else {
97
        enc_info = (envctrl_encl_t *)kp->ks_data;        
98
        for (i=0; i<kp->ks_ndata; i++) {
99
            /*
100
             * The enclosure information covers several different types of sensor
101
             */
102
            switch ( enc_info->type ) {
103
            case ENVCTRL_ENCL_FSP:
104
                DEBUGMSGTL(("sensors:arch:detail", "Enclosure Front Panel\n"));
105
                sp = sensor_by_name( "FSP", NETSNMP_SENSOR_TYPE_OTHER);
106
                if ( sp ) {
107
                    sp->value = enc_info->value;
108
                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
109
                }
110
                break;
111
                
112
            case ENVCTRL_ENCL_AMBTEMPR:
113
                DEBUGMSGTL(("sensors:arch:detail", "Enclosure Ambient Temperature\n"));
114
                sp = sensor_by_name( "Ambient", NETSNMP_SENSOR_TYPE_TEMPERATURE);
115
                if ( sp ) {
116
                    sp->value = enc_info->value;
117
                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
118
                }
119
                break;
120
121
            case ENVCTRL_ENCL_CPUTEMPR:
122
                DEBUGMSGTL(("sensors:arch:detail", "Enclosure CPU Temperature\n"));
123
                memset( name, 0, 256 );
124
                snprintf( name, 255, "CPU%d", enc_info->instance );
125
                sp = sensor_by_name( name, NETSNMP_SENSOR_TYPE_TEMPERATURE);
126
                if ( sp ) {
127
                    sp->value = enc_info->value;
128
                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
129
                    snprintf( sp->descr, 255, "CPU%d temperature", enc_info->instance );
130
                }
131
                break;
132
133
            case ENVCTRL_ENCL_BACKPLANE4:
134
                DEBUGMSGTL(("sensors:arch:detail", "Enclosure Backplane4\n"));
135
                sp = sensor_by_name( "Backplane4", NETSNMP_SENSOR_TYPE_OTHER);
136
                if ( sp ) {
137
                    sp->value = enc_info->value;
138
                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
139
                }
140
                break;
141
                
142
            case ENVCTRL_ENCL_BACKPLANE8:
143
                DEBUGMSGTL(("sensors:arch:detail", "Enclosure Backplane4\n"));
144
                sp = sensor_by_name( "Backplane4", NETSNMP_SENSOR_TYPE_OTHER);
145
                if ( sp ) {
146
                    sp->value = enc_info->value;
147
                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
148
                }
149
                break;
150
151
            default:    
152
                DEBUGMSGTL(("sensors:arch:detail", "Unrecognised Enclosure entry (%d)n",
153
                                                    enc_info->type));
154
            }
155
156
            enc_info++;
157
        }
158
    }
159
160
    return 0;
161
}
(-)/dev/null (+1 lines)
Added Link Here
1
config_require(hardware/sensors/hw_sensors)
(-)/dev/null (+75 lines)
Added Link Here
1
#include <net-snmp/net-snmp-config.h>
2
#include <net-snmp/net-snmp-includes.h>
3
#include <net-snmp/agent/net-snmp-agent-includes.h>
4
#include <net-snmp/agent/hardware/sensors.h>
5
6
#include "util_funcs.h"
7
#include <time.h>
8
#include <sensors/sensors.h>
9
10
void netsnmp_sensor_arch_init( void ) {
11
    FILE *fp = fopen("/etc/sensors.conf", "r");
12
    DEBUGMSGTL(("sensors:arch", "Initialise LM Sensors module\n"));
13
    sensors_init( fp );
14
}
15
16
int
17
netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
18
    netsnmp_sensor_info        *sp;
19
    const sensors_chip_name    *chip;
20
    const sensors_feature_data *data;
21
    int             chip_nr = 0;
22
23
    DEBUGMSGTL(("sensors:arch", "Reload LM Sensors module\n"));
24
    while ((chip = sensors_get_detected_chips(&chip_nr))) {
25
	int             a = 0;
26
	int             b = 0;
27
28
        while ((data = sensors_get_all_features(*chip, &a, &b))) {
29
            DEBUGMSGTL(("sensors:arch:detail", "get_all_features (%d, %d)\n", a, b));
30
            char           *label = NULL;
31
            double          val;
32
            int             type = NETSNMP_SENSOR_TYPE_OTHER;
33
34
            if ((data->mode & SENSORS_MODE_R) &&
35
                (data->mapping == SENSORS_NO_MAPPING) &&
36
                !sensors_get_label(*chip, data->number, &label) &&
37
                !sensors_get_feature(*chip, data->number, &val)) {
38
39
                DEBUGMSGTL(("sensors:arch:detail", "%s = %f\n", label, val));
40
                /*
41
                 * Determine the type of sensor from the description.
42
                 *
43
                 * If the text being looked for below is not in the label of a
44
                 * given sensor (e.g., the temp1 sensor has been labeled 'CPU'
45
                 * rather than 'CPU temp') it will be categorised as OTHER.
46
                 */
47
                if (strstr(label, "V")) {
48
                    type = NETSNMP_SENSOR_TYPE_VOLTAGE_DC;
49
                }
50
                if (strstr(label, "fan") || strstr(label, "Fan")) {
51
                    type = NETSNMP_SENSOR_TYPE_RPM;
52
                }
53
                if (strstr(label, "temp") || strstr(label, "Temp")) {
54
                    type = NETSNMP_SENSOR_TYPE_TEMPERATURE;
55
                }
56
57
                /*
58
                 * Use this type to create a new sensor entry
59
                 *  (inserting it in the appropriate sub-containers)
60
                 */
61
                sp = sensor_by_name( label, type );
62
                if ( sp ) {
63
                    sp->value = val;
64
                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
65
                }
66
            }
67
	    if (label) {
68
		free(label);
69
		label = NULL;
70
	    }
71
        } /* end while data */
72
    } /* end while chip */
73
74
    return 0;
75
}
(-)/dev/null (+1 lines)
Added Link Here
1
config_require(hardware/sensors/hw_sensors)
(-)/dev/null (+101 lines)
Added Link Here
1
#include <net-snmp/net-snmp-config.h>
2
#include <net-snmp/net-snmp-includes.h>
3
#include <net-snmp/agent/net-snmp-agent-includes.h>
4
#include <net-snmp/agent/hardware/sensors.h>
5
6
#include "util_funcs.h"
7
#include <time.h>
8
#include <sensors/sensors.h>
9
10
11
void netsnmp_sensor_arch_init( void ) {
12
    FILE *fp = fopen("/etc/sensors.conf", "r");
13
    DEBUGMSGTL(("sensors:arch", "Initialise v3 LM Sensors module\n"));
14
    sensors_init( fp );
15
}
16
17
int
18
netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
19
    netsnmp_sensor_info        *sp;
20
    const sensors_chip_name    *chip;
21
    const sensors_feature      *data;
22
    const sensors_subfeature   *data2;
23
    int             chip_nr = 0;
24
25
    DEBUGMSGTL(("sensors:arch", "Reload v3 LM Sensors module\n"));
26
    while ((chip = sensors_get_detected_chips( NULL, &chip_nr))) {
27
	int             a = 0;
28
29
        while ((data = sensors_get_features( chip, &a))) {
30
            DEBUGMSGTL(("sensors:arch:detail", "get_features (%s, %d)\n", data->name, data->number));
31
	    int             b = 0;
32
 
33
34
            while ((data2 = sensors_get_all_subfeatures( chip, data, &b))) {
35
                char           *label = NULL;
36
                double          val;
37
                int             type = NETSNMP_SENSOR_TYPE_OTHER;
38
39
                DEBUGMSGTL(("sensors:arch:detail", "  get_subfeatures (%s, %d)\n", data2->name, data2->number));
40
                /*
41
                 * Check the type of this subfeature,
42
                 *   concentrating on the main "input" measurements.
43
                 */
44
                switch ( data2->type ) {
45
                case SENSORS_SUBFEATURE_IN_INPUT:
46
                    type = NETSNMP_SENSOR_TYPE_VOLTAGE_DC;
47
                    break;
48
                case SENSORS_SUBFEATURE_FAN_INPUT:
49
                    type = NETSNMP_SENSOR_TYPE_RPM;
50
                    break;
51
                case SENSORS_SUBFEATURE_TEMP_INPUT:
52
                    type = NETSNMP_SENSOR_TYPE_TEMPERATURE;
53
                    break;
54
                case SENSORS_SUBFEATURE_VID:
55
                    type = NETSNMP_SENSOR_TYPE_VOLTAGE_DC;
56
                    break;
57
                default:
58
                    /* Skip everything other than these basic sensor features - ??? */
59
                    DEBUGMSGTL(("sensors:arch:detail", "  Skip type %x\n", data2->type));
60
                    continue;
61
                }
62
            
63
                /*
64
                 * Get the name and value of this subfeature
65
                 */
66
/*
67
                if (!(label = sensors_get_label(chip, data))) {
68
                    DEBUGMSGTL(("sensors:arch:detail", "  Can't get name (%s)\n", label));
69
                    continue;
70
                }
71
                if (sensors_get_value(chip, data2->number, &val) < 0) {
72
                    DEBUGMSGTL(("sensors:arch:detail", "  Can't get value (%f)\n", val));
73
                    continue;
74
                }
75
*/
76
                if (!(label = sensors_get_label(chip, data)) ||
77
                     (sensors_get_value(chip, data2->number, &val) < 0)) {
78
                    DEBUGMSGTL(("sensors:arch:detail", "  Can't get name/value (%s, %f)\n", label, val));
79
                    continue;
80
                }
81
                DEBUGMSGTL(("sensors:arch:detail", "%s = %f\n", label, val));
82
83
                /*
84
                 * Use this type to create a new sensor entry
85
                 *  (inserting it in the appropriate sub-containers)
86
                 */
87
                sp = sensor_by_name( label, type );
88
                if ( sp ) {
89
                    sp->value = val;
90
                    sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
91
                }
92
	        if (label) {
93
		    free(label);
94
		    label = NULL;
95
	        }
96
            } /* end while data2 */
97
        } /* end while data */
98
    } /* end while chip */
99
100
    return 0;
101
}
(-)/dev/null (+1 lines)
Added Link Here
1
config_require(hardware/sensors/hw_sensors)
(-)/dev/null (+341 lines)
Added Link Here
1
#include <net-snmp/net-snmp-config.h>
2
#include <net-snmp/net-snmp-includes.h>
3
#include <net-snmp/agent/net-snmp-agent-includes.h>
4
#include <net-snmp/agent/hardware/sensors.h>
5
6
#include "util_funcs.h"
7
#include <time.h>
8
9
#include <picl.h>
10
#include </usr/platform/sun4u/include/sys/envctrl.h>
11
12
void netsnmp_sensor_arch_init( void ) {
13
    DEBUGMSGTL(("sensors:arch", "Initialise PICLd Sensors module\n"));
14
    picl_initialize();
15
}
16
17
18
/*
19
 * Handle a numeric-valued sensor
20
 */
21
static int
22
read_num_sensor( picl_nodehdl_t childh, char *propval, float *value )
23
{
24
    picl_nodehdl_t  sensorh;
25
    picl_propinfo_t sensor_info;
26
    picl_errno_t    error_code;
27
28
    union valu {
29
        char buf[PICL_PROPSIZE_MAX];
30
        uint32_t us4;
31
        uint16_t us2;
32
        int32_t is4;
33
        int16_t is2;
34
        float f;
35
    } val;
36
37
    /*
38
     *  Retrieve the specified sensor information and value
39
     */
40
    error_code = picl_get_propinfo_by_name(childh, propval, &sensor_info, &sensorh);
41
    if ( error_code != PICL_SUCCESS ) {
42
        DEBUGMSGTL(("sensors:arch:detail", "sensor info lookup failed (%d)\n",
43
                                            error_code));
44
        return( error_code );
45
    }
46
47
    error_code = picl_get_propval(sensorh, &val.buf, sensor_info.size);
48
    if ( error_code != PICL_SUCCESS ) {
49
        DEBUGMSGTL(("sensors:arch:detail", "sensor value lookup failed (%d)\n",
50
                                            error_code));
51
        return( error_code );
52
    }
53
54
    /*
55
     *  Check the validity (type and size) of this value
56
     */
57
    if ( sensor_info.type == PICL_PTYPE_FLOAT ) {
58
        *value = val.f;
59
    } else if ( sensor_info.type == PICL_PTYPE_UNSIGNED_INT ) {
60
        /* 16-bit or 32-bit unsigned integers */
61
        if ( sensor_info.size == 2 ) {
62
            *value = val.us2;
63
        } else if ( sensor_info.size == 4 ) { 
64
            *value = val.us4;
65
        } else {
66
            DEBUGMSGTL(("sensors:arch:detail", "unsigned integer (%d bit)\n",
67
                                                sensor_info.size * 8));
68
            return PICL_FAILURE;
69
        }
70
    } else if ( sensor_info.type == PICL_PTYPE_INT ) {
71
        /* 16-bit or 32-bit signed integers */
72
        if ( sensor_info.size == 2 ) {
73
            *value = val.is2;
74
        } else if ( sensor_info.size == 4 ) { 
75
            *value = val.is4;
76
        } else {
77
            DEBUGMSGTL(("sensors:arch:detail", "signed integer (%d bit)\n",
78
                                                sensor_info.size * 8));
79
            return PICL_FAILURE;
80
        }
81
    } else {
82
        DEBUGMSGTL(("sensors:arch:detail", "unrecognised type (%d)\n",
83
                                            sensor_info.type));
84
        return PICL_FAILURE;
85
    }
86
87
    return error_code;
88
}
89
90
static int
91
process_num_sensor( picl_nodehdl_t childh, char *propname, char *propval, int typ )
92
{
93
    netsnmp_sensor_info        *sp;
94
    float                       value;
95
    picl_errno_t    error_code;
96
97
    sp = sensor_by_name( propname, typ );
98
    if ( !sp ) {
99
         return -1;
100
    }
101
102
    error_code = read_num_sensor( childh, propval, &value );
103
    if ( error_code == PICL_SUCCESS ) {
104
        sp->value = value;
105
        sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
106
    } else {
107
        DEBUGMSGTL(("sensors:arch:detail", "Failed to read %s sensor value (%d)\n",
108
                                            propname, error_code));
109
        return -1;
110
    }
111
    return 0;
112
}
113
114
115
116
/*
117
 *    Handle an enumeration-valued sensor
118
 */
119
char *switch_settings[] = { "OFF","ON","NORMAL","LOCKED",
120
                            "UNKNOWN","DIAG","SECURE",
121
                            NULL };
122
char *led_settings[]    = { "OFF","ON","BLINK",
123
                            NULL };
124
char *i2c_settings[]    = { "OK",
125
                            NULL };
126
127
static int
128
read_enum_sensor( picl_nodehdl_t childh, float *value, char **options )
129
{
130
    picl_nodehdl_t  sensorh;
131
    picl_propinfo_t sensor_info;
132
    picl_errno_t    error_code;
133
    char            state[PICL_PROPSIZE_MAX];
134
    int             i;
135
136
    /*
137
     *  Retrieve the specified sensor information and value
138
     */
139
    error_code = picl_get_propinfo_by_name(childh, "State", &sensor_info, &sensorh);
140
    if ( error_code != PICL_SUCCESS ) {
141
        DEBUGMSGTL(("sensors:arch:detail", "sensor info lookup failed (%d)\n",
142
                                            error_code));
143
        return( error_code );
144
    }
145
146
    error_code = picl_get_propval(sensorh, state, sensor_info.size);
147
    if ( error_code != PICL_SUCCESS ) {
148
        DEBUGMSGTL(("sensors:arch:detail", "sensor value lookup failed (%d)\n",
149
                                            error_code));
150
        return( error_code );
151
    }
152
153
    /*
154
     * Try to find a matching entry in the list of options.
155
     * Note that some platforms may use upper or lower case
156
     *   versions of these enumeration values
157
     *  (so the checks are case insensitive)
158
     */
159
    *value = 99;    /* Dummy value */
160
    for ( i=0;  options[i] != NULL; i++ ) {
161
        if (strncasecmp(state, options[i], strlen(options[i])) == 0) {
162
            *value = i;
163
            return 0;
164
        }
165
    }
166
    
167
    DEBUGMSGTL(("sensors:arch:detail", "Enumeration state %s not matched\n",
168
                                        state));
169
    return 0;  /* Or an error ? */
170
}
171
172
static int
173
process_enum_sensor( picl_nodehdl_t childh, char *propname, int typ, char **options )
174
{
175
    netsnmp_sensor_info        *sp;
176
    float                       value;
177
    picl_errno_t    error_code;
178
179
    sp = sensor_by_name( propname, typ );
180
    if ( !sp ) {
181
         return -1;
182
    }
183
184
    error_code = read_enum_sensor( childh, &value, options );
185
    if ( error_code == PICL_SUCCESS ) {
186
        sp->value = value;
187
        sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
188
    } else {
189
        DEBUGMSGTL(("sensors:arch:detail", "Failed to read %s sensor value (%d)\n",
190
                                            propname, error_code));
191
        return -1;
192
    }
193
    return 0;
194
}
195
static int
196
process_enum_sensor( picl_nodehdl_t childh, char *propname, int typ, char **options )
197
{
198
    return 0;
199
}
200
201
202
203
/*
204
 *  Recursively walk through the tree of sensors
205
 */
206
static int
207
process_sensors( int level, picl_nodehdl_t nodeh ) {
208
    picl_nodehdl_t childh, nexth;
209
    char           propname[  PICL_PROPNAMELEN_MAX  ];
210
    char           propclass[ PICL_CLASSNAMELEN_MAX ];
211
    picl_errno_t   error_code;
212
213
    level++;
214
    DEBUGMSGTL(("sensors:arch:detail", "process_sensors - level %d\n", level));
215
216
    /* Look up the first child node at this level */
217
    error_code = pick_get_propval_by_name( nodeh, PICL_PROP_CHILD,
218
                                           &childh, sizeof(childh));
219
    if ( error_code != PICL_SUCCESS ) {
220
        DEBUGMSGTL(("sensors:arch:detail", "Failed to get first child node (%d)\n",
221
                                            error_code));
222
        return( error_code );
223
    }
224
225
    /* Step through the child nodes, retrieving the name and class of each one */
226
    while ( error_code == PICL_SUCCESS ) {
227
        error_code = pick_get_propval_by_name( childh, PICL_PROP_NAME,
228
                                               propname, sizeof(propname)-1);
229
        if ( error_code != PICL_SUCCESS ) {
230
            /* The Node With No Name */
231
            DEBUGMSGTL(("sensors:arch:detail", "get property name failed (%d)\n",
232
                                                error_code));
233
            return( error_code );
234
        }
235
236
        error_code = pick_get_propval_by_name( childh, PICL_PROP_CLASSNAME,
237
                                               propclass, sizeof(propclass)-1);
238
        if ( error_code != PICL_SUCCESS ) {
239
            /* The Classless Society */
240
            DEBUGMSGTL(("sensors:arch:detail", "get property class failed (%d)\n",
241
                                                error_code));
242
            return( error_code );
243
        }
244
245
        DEBUGMSGTL(("sensors:arch:detail", "Name: %s, Class %s\n",
246
                                            propname, propclass ));
247
248
249
        /*
250
         *  Three classes represent further groups of sensors, etc.
251
         *  Call 'process_sensors' recursively to handle this next level
252
         */
253
        if (( strstr( propclass, "picl"    )) ||
254
            ( strstr( propclass, "frutree" )) ||
255
            ( strstr( propclass, "obp"     ))) {
256
            process_sensors( level, childh );
257
        }
258
        /*
259
         *  Otherwise retrieve the value appropriately based on the
260
         *     class of the sensor.
261
         *
262
         *  We need to specify the name of the PICL property to retrieve
263
         *     for this class of sensor, and the Net-SNMP sensor type.
264
         */
265
        else if ( strstr( propclass, "fan-tachometer" )) {
266
            process_num_sensor( childh, propname, "AtoDSensorValue",
267
                                                   NETSNMP_SENSOR_TYPE_RPM );
268
        } else if ( strstr( propclass, "fan" )) {
269
            process_num_sensor( childh, propname, "Speed",
270
                                                   NETSNMP_SENSOR_TYPE_RPM );
271
        } else if ( strstr( propclass, "temperature-sensor" )) {
272
            process_num_sensor( childh, propname, "Temperature",
273
                                                   NETSNMP_SENSOR_TYPE_TEMPERATURE );
274
        } else if ( strstr( propclass, "voltage-sensor" )) {
275
            process_num_sensor( childh, propname, "Voltage",
276
                                          /* ?? */ NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
277
        } else if ( strstr( propclass, "digital-sensor" )) {
278
            process_num_sensor( childh, propname, "AtoDSensorValue",
279
                                          /* ?? */ NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
280
            /*
281
             * Enumeration-valued sensors use a fixed PICL property ("State"),
282
             *   but take a list of the values appropriate for that sensor,
283
             *   as well as the Net-SNMP sensor type.
284
             */
285
        } else if ( strstr( propclass, "switch" )) {
286
            process_enum_sensor( childh, propname, NETSNMP_SENSOR_TYPE_OTHER,
287
                                                   switch_settings );
288
        } else if ( strstr( propclass, "led" )) {
289
            process_enum_sensor( childh, propname, NETSNMP_SENSOR_TYPE_OTHER,
290
                                                   led_settings );
291
        } else if ( strstr( propclass, "i2c" )) {
292
            process_enum_sensor( childh, propname, NETSNMP_SENSOR_TYPE_BOOLEAN, /* ?? */
293
                                                   i2c_settings );
294
        } else {
295
            /* Skip other classes of sensor */
296
            DEBUGMSGTL(("sensors:arch:detail", "Skipping class %s\n", propclass ));
297
        }
298
299
        /*
300
         *  Move on to the next child node at the current level (if any)
301
         */
302
        error_code = pick_get_propval_by_name( childh, PICL_PROP_PEER,
303
                                               &nexth, sizeof(nexth));
304
        if ( error_code != PICL_SUCCESS ) {
305
            /* That's All Folks! */
306
            return (( error_code == PICL_PROPNOTFOUND )
307
                          ? PICL_SUCCESS : error_code );
308
        }
309
        childh = nexth;
310
    }
311
    
312
    return error_code;
313
}
314
315
316
int
317
netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
318
    int               error_code;
319
    picl_nodehdl_t    rooth;
320
321
    DEBUGMSGTL(("sensors:arch", "Reload PICLd Sensors module\n"));
322
323
    error_code = picl_get_root(&rooth);
324
    if ( error_code != PICL_SUCCESS) {
325
        DEBUGMSGTL(("sensors:arch", "Couldn't get root node (error %d)\n", error_code));
326
        return 1;
327
    }
328
329
    error_code = process_sensors(0, rooth);
330
    if ( error_code != 255 )
331
        if ( error_code != 7 )  /* ignore PICL_PROPNOTFOUND error */
332
            DEBUGMSGTL(("sensors:arch", "Internal PICLd problem (error %d)\n", error_code));
333
334
    return 0;
335
}
336
337
void netsnmp_sensor_arch_shutdown( void ) {
338
    DEBUGMSGTL(("sensors:arch", "Shutdown PicLD Sensors module\n"));
339
    picl_shutdown();
340
}
341
(-)/dev/null (+1 lines)
Added Link Here
1
config_require(hardware/sensors/hw_sensors)
(-)/dev/null (+205 lines)
Added Link Here
1
#include <net-snmp/net-snmp-config.h>
2
#include <net-snmp/net-snmp-includes.h>
3
#include <net-snmp/agent/net-snmp-agent-includes.h>
4
#include <net-snmp/agent/hardware/sensors.h>
5
#include "ucd-snmp/lmsensorsMib.h"
6
7
netsnmp_container *sensorContainer = NULL;
8
9
void initialize_lmSensorsTable(const char *tableName, oid *tableOID,
10
                               netsnmp_container_op *filter, int mult );
11
12
int _sensor_filter_temp( netsnmp_container *c, const void *v );
13
int _sensor_filter_fan(  netsnmp_container *c, const void *v );
14
int _sensor_filter_volt( netsnmp_container *c, const void *v );
15
int _sensor_filter_misc( netsnmp_container *c, const void *v );
16
17
static oid lmTempSensorsTable_oid[]   = {1,3,6,1,4,1,2021,13,16,2};
18
static oid lmFanSensorsTable_oid[]    = {1,3,6,1,4,1,2021,13,16,3};
19
static oid lmVoltSensorsTable_oid[]   = {1,3,6,1,4,1,2021,13,16,4};
20
static oid lmMiscSensorsTable_oid[]   = {1,3,6,1,4,1,2021,13,16,5};
21
            /* All the tables have the same length root OID */
22
size_t     lmSensorsTables_oid_len = OID_LENGTH(lmMiscSensorsTable_oid);
23
24
25
/* Initialise the LM Sensors MIB module */
26
void
27
init_lmsensorsMib(void)
28
{
29
    DEBUGMSGTL(("ucd-snmp/lmsensorsMib","Initializing LM-SENSORS-MIB tables\n"));
30
31
    /* 
32
     * Initialise the four LM-SENSORS-MIB tables
33
     *
34
     * They are almost identical, so we can use the same registration code.
35
     */
36
    initialize_lmSensorsTable( "lmTempSensorsTable", lmTempSensorsTable_oid,
37
                                _sensor_filter_temp, 1000 );  /* MIB asks for mC */
38
    initialize_lmSensorsTable( "lmFanSensorsTable",  lmFanSensorsTable_oid,
39
                                _sensor_filter_fan,  1);
40
    initialize_lmSensorsTable( "lmVoltSensorsTable", lmVoltSensorsTable_oid,
41
                                _sensor_filter_volt, 1000 );  /* MIB asks for mV */
42
    initialize_lmSensorsTable( "lmMiscSensorsTable", lmMiscSensorsTable_oid,
43
                                _sensor_filter_misc, 1 );
44
}
45
46
/*
47
 * Common initialisation code, used for setting up all four tables
48
 */
49
void
50
initialize_lmSensorsTable(const char *tableName, oid *tableOID,
51
                          netsnmp_container_op *filter, int mult )
52
{
53
    netsnmp_handler_registration    *reg;
54
    netsnmp_table_registration_info *table_info;
55
    netsnmp_cache     *cache;
56
    netsnmp_container *container;
57
58
    /*
59
     * Ensure the HAL sensors module has been initialised,
60
     *   and retrieve the main sensors container.
61
     * This table will then be registered using a filter on this container.
62
     */
63
    sensorContainer = get_sensor_container();
64
    if ( !sensorContainer ) {
65
        init_hw_sensors( );
66
        sensorContainer = get_sensor_container();
67
    }
68
    container = netsnmp_container_find("sensorTable:table_container");
69
    container->insert_filter = filter;
70
    netsnmp_container_add_index( sensorContainer, container );
71
72
73
    /*
74
     * Create a basic registration structure for the table
75
     */
76
    reg = netsnmp_create_handler_registration(
77
               tableName, lmSensorsTables_handler,
78
               tableOID,  lmSensorsTables_oid_len, HANDLER_CAN_RONLY
79
              );
80
81
    /*
82
     * Register the table using the filtered container
83
     * Include an indicator of any scaling to be applied to the sensor value
84
     */
85
    reg->my_reg_void = (void *)mult;
86
    table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
87
    netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, 0);
88
    table_info->min_column = COLUMN_LMSENSORS_INDEX;
89
    table_info->max_column = COLUMN_LMSENSORS_VALUE;
90
    netsnmp_container_table_register( reg, table_info, container, 0 );
91
92
    /*
93
     * If the HAL sensors module was configured as an on-demand caching
94
     *  module (rather than being automatically loaded regularly),
95
     *  then ensure this table makes use of that cache.
96
     */
97
    cache = get_sensor_cache();
98
    if ( cache ) {
99
        netsnmp_inject_handler_before( reg, netsnmp_cache_handler_get( cache ),
100
                                            "table_container");
101
    }
102
103
}
104
105
106
/*
107
 *  Container filters for the four tables
108
 *
109
 *  Used to ensure that sensor entries appear in the appropriate table.
110
 */
111
int _sensor_filter_temp( netsnmp_container *c, const void *v ) {
112
    const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
113
    /* Only matches temperature sensors */
114
    return (( sp->type == NETSNMP_SENSOR_TYPE_TEMPERATURE ) ? 0 : 1 );
115
}
116
117
int _sensor_filter_fan( netsnmp_container *c, const void *v ) {
118
    const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
119
    /* Only matches fan sensors */
120
    return (( sp->type == NETSNMP_SENSOR_TYPE_RPM ) ? 0 : 1 );
121
}
122
123
int _sensor_filter_volt( netsnmp_container *c, const void *v ) {
124
    const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
125
    /* Only matches voltage sensors (AC or DC) */
126
    return ((( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_DC ) ||
127
             ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_AC )) ? 0 : 1 );
128
}
129
130
int _sensor_filter_misc( netsnmp_container *c, const void *v ) {
131
    const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
132
    /* Matches everything except temperature, fan or voltage sensors */
133
    return ((( sp->type == NETSNMP_SENSOR_TYPE_TEMPERATURE ) ||
134
             ( sp->type == NETSNMP_SENSOR_TYPE_RPM         ) ||
135
             ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_DC  ) ||
136
             ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_AC  )) ? 1 : 0 );
137
}
138
139
140
/*
141
 * Handle requests for any of the four lmXxxxSensorsTables 
142
 *
143
 * This is possible because all the table share the
144
 *  same structure and behaviour.
145
 */
146
int
147
lmSensorsTables_handler(
148
    netsnmp_mib_handler               *handler,
149
    netsnmp_handler_registration      *reginfo,
150
    netsnmp_agent_request_info        *reqinfo,
151
    netsnmp_request_info              *requests) {
152
153
    netsnmp_request_info       *request;
154
    netsnmp_table_request_info *table_info;
155
    netsnmp_sensor_info        *sensor_info;
156
    int mult  = (int)reginfo->my_reg_void;
157
158
    DEBUGMSGTL(( "ucd-snmp/lmsensorsMib","lmSensorsTables_handler - root: "));
159
    DEBUGMSGOID(("ucd-snmp/lmsensorsMib", reginfo->rootoid, reginfo->rootoid_len));
160
    DEBUGMSG((   "ucd-snmp/lmsensorsMib",", mode %d\n", reqinfo->mode ));
161
    /*
162
     * This is a read-only table, so we only need to handle GET requests.
163
     *    (The container helper converts GETNEXT->GET requests automatically).
164
     */
165
    switch (reqinfo->mode) {
166
    case MODE_GET:
167
        for (request=requests; request; request=request->next) {
168
            sensor_info = (netsnmp_sensor_info *)
169
                            netsnmp_container_table_extract_context(request);
170
            if ( !sensor_info ) {
171
                netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
172
                continue;
173
            }
174
    
175
            table_info   =  netsnmp_extract_table_info(request);
176
            switch (table_info->colnum) {
177
            case COLUMN_LMSENSORS_INDEX:
178
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
179
                                            sensor_info->idx.oids[0]);
180
                break;
181
            case COLUMN_LMSENSORS_DEVICE:
182
                if ( sensor_info->descr[0] != '\0' ) {
183
                    snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
184
                                              sensor_info->descr, strlen(sensor_info->descr));
185
                } else {
186
                    snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
187
                                              sensor_info->name,  strlen(sensor_info->name));
188
                }
189
                break;
190
            case COLUMN_LMSENSORS_VALUE:
191
                /* Multiply the value by the appropriate scaling factor for this table */
192
                snmp_set_var_typed_integer( request->requestvb, ASN_GAUGE,
193
                                            (int)(mult*sensor_info->value));
194
                break;
195
            default:
196
                netsnmp_set_request_error(reqinfo, request,
197
                                          SNMP_NOSUCHOBJECT);
198
                break;
199
            }
200
        }
201
        break;
202
203
    }
204
    return SNMP_ERR_NOERROR;
205
}
(-)/dev/null (+23 lines)
Added Link Here
1
#ifndef LM_SENSORS_MIB_H
2
#define LM_SENSORS_MIB_H
3
4
config_require(hardware/sensors)
5
config_add_mib(LM-SENSORS-MIB)
6
7
/* function declarations */
8
void init_lmsensorsMib(void);
9
10
/*
11
 * Handler and Column definitions for lmXxxxSensorsTable
12
 *
13
 * Note that the same handler (and hence the same
14
 *  column identifiers) are used for all four tables.
15
 * This is possible because all the table share the
16
 *  same structure and behaviour.
17
 */
18
Netsnmp_Node_Handler lmSensorsTables_handler;
19
#define COLUMN_LMSENSORS_INDEX		1
20
#define COLUMN_LMSENSORS_DEVICE		2
21
#define COLUMN_LMSENSORS_VALUE		3
22
23
#endif /* LM_SENSORS_MIB_H */
(-)net-snmp-5.4.1/configure.backup_patch_15 (-1 / +1 lines)
Lines 31030-31036 fi Link Here
31030
fi
31030
fi
31031
31031
31032
# LM-SENSORS-MIB support
31032
# LM-SENSORS-MIB support
31033
echo " $module_list " | grep " ucd-snmp/lmSensors " > /dev/null
31033
echo " $module_list " | $GREP -i "ucd-snmp/lmsensor" > /dev/null
31034
if test $? -eq 0 ; then
31034
if test $? -eq 0 ; then
31035
        echo "$as_me:$LINENO: checking for sensors support" >&5
31035
        echo "$as_me:$LINENO: checking for sensors support" >&5
31036
echo $ECHO_N "checking for sensors support... $ECHO_C" >&6
31036
echo $ECHO_N "checking for sensors support... $ECHO_C" >&6
(-)net-snmp-5.4.1/configure.in.backup_patch_15 (-1 / +1 lines)
Lines 2880-2886 if test $? -eq 0 ; then Link Here
2880
fi
2880
fi
2881
2881
2882
# LM-SENSORS-MIB support
2882
# LM-SENSORS-MIB support
2883
echo " $module_list " | grep " ucd-snmp/lmSensors " > /dev/null
2883
echo " $module_list " | $GREP -i "ucd-snmp/lmsensor" > /dev/null
2884
if test $? -eq 0 ; then
2884
if test $? -eq 0 ; then
2885
        AC_MSG_CHECKING([for sensors support])
2885
        AC_MSG_CHECKING([for sensors support])
2886
        case $target_os in
2886
        case $target_os in
(-)/dev/null (+48 lines)
Added Link Here
1
/*
2
 * Hardware Abstraction Layer - Sensors module
3
 *
4
 * Public interface
5
 */
6
7
#define NETSNMP_SENSOR_TYPE_OTHER       1
8
#define NETSNMP_SENSOR_TYPE_VOLTAGE_AC  3
9
#define NETSNMP_SENSOR_TYPE_VOLTAGE_DC  4
10
#define NETSNMP_SENSOR_TYPE_CURRENT     5
11
#define NETSNMP_SENSOR_TYPE_POWER       6
12
#define NETSNMP_SENSOR_TYPE_FREQUENCY   7
13
#define NETSNMP_SENSOR_TYPE_TEMPERATURE 8
14
#define NETSNMP_SENSOR_TYPE_HUMIDITY    9
15
#define NETSNMP_SENSOR_TYPE_RPM        10
16
#define NETSNMP_SENSOR_TYPE_VOLUME     11
17
#define NETSNMP_SENSOR_TYPE_BOOLEAN    12
18
19
20
#define NETSNMP_SENSOR_FLAG_ACTIVE     0x01
21
#define NETSNMP_SENSOR_FLAG_NAVAIL     0x02
22
#define NETSNMP_SENSOR_FLAG_BROKEN     0x04
23
#define NETSNMP_SENSOR_FLAG_DISABLE    0x08
24
25
#define NETSNMP_SENSOR_MASK_STATUS     0x06  /* NAVAIL|BROKEN */
26
27
28
#define NETSNMP_SENSOR_FIND_CREATE     1   /* or use one of the sensor type values */
29
#define NETSNMP_SENSOR_FIND_EXIST      0
30
31
typedef struct netsnmp_sensor_info_s netsnmp_sensor_info;
32
struct netsnmp_sensor_info_s {
33
34
    netsnmp_index  idx;
35
    /* int  idx; */
36
    char  name[256];
37
    
38
    int   type;
39
    float value;
40
    char  descr[256];
41
    long  flags;
42
};
43
44
netsnmp_container   *get_sensor_container( void );
45
netsnmp_cache       *get_sensor_cache( void );
46
netsnmp_sensor_info *sensor_by_name( char *, int );
47
NetsnmpCacheLoad     netsnmp_sensor_load;
48
NetsnmpCacheFree     netsnmp_sensor_free;

Return to bug 279423