/[pkgs]/devel/net-snmp/net-snmp-5.4.1-sensors3.patch
ViewVC logotype

Diff of /devel/net-snmp/net-snmp-5.4.1-sensors3.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.2
2Source: upstream, svn diff -r 16736:16739 2Source: upstream, svn diff -r 16736:16739
3Reviewed-By: Jan Safranek <jsafrane@redhat.com> 3Reviewed-By: Jan Safranek <jsafrane@redhat.com>
4 4
5Index: configure 5Index: configure
6=================================================================== 6===================================================================
7--- configure (revision 16736) 7diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/dummy_sensors.c
8+++ configure (revision 16739) 8--- /dev/null 2008-07-23 14:59:56.660004489 +0200
9@@ -32628,7 +32628,7 @@ 9+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/dummy_sensors.c 2008-07-25 12:53:46.000000000 +0200
10 fi
11
12 # LM-SENSORS-MIB support
13-echo " $module_list " | grep " ucd-snmp/lmSensors " > /dev/null
14+echo " $module_list " | $GREP -i "ucd-snmp/lmsensor" > /dev/null
15 if test $? -eq 0 ; then
16 { echo "$as_me:$LINENO: checking for sensors support" >&5
17 echo $ECHO_N "checking for sensors support... $ECHO_C" >&6; }
18Index: include/net-snmp/agent/hardware/sensors.h
19===================================================================
20--- include/net-snmp/agent/hardware/sensors.h (revision 0)
21+++ include/net-snmp/agent/hardware/sensors.h (revision 16739)
22@@ -0,0 +1,48 @@
23+/*
24+ * Hardware Abstraction Layer - Sensors module
25+ *
26+ * Public interface
27+ */
28+
29+#define NETSNMP_SENSOR_TYPE_OTHER 1
30+#define NETSNMP_SENSOR_TYPE_VOLTAGE_AC 3
31+#define NETSNMP_SENSOR_TYPE_VOLTAGE_DC 4
32+#define NETSNMP_SENSOR_TYPE_CURRENT 5
33+#define NETSNMP_SENSOR_TYPE_POWER 6
34+#define NETSNMP_SENSOR_TYPE_FREQUENCY 7
35+#define NETSNMP_SENSOR_TYPE_TEMPERATURE 8
36+#define NETSNMP_SENSOR_TYPE_HUMIDITY 9
37+#define NETSNMP_SENSOR_TYPE_RPM 10
38+#define NETSNMP_SENSOR_TYPE_VOLUME 11
39+#define NETSNMP_SENSOR_TYPE_BOOLEAN 12
40+
41+
42+#define NETSNMP_SENSOR_FLAG_ACTIVE 0x01
43+#define NETSNMP_SENSOR_FLAG_NAVAIL 0x02
44+#define NETSNMP_SENSOR_FLAG_BROKEN 0x04
45+#define NETSNMP_SENSOR_FLAG_DISABLE 0x08
46+
47+#define NETSNMP_SENSOR_MASK_STATUS 0x06 /* NAVAIL|BROKEN */
48+
49+
50+#define NETSNMP_SENSOR_FIND_CREATE 1 /* or use one of the sensor type values */
51+#define NETSNMP_SENSOR_FIND_EXIST 0
52+
53+typedef struct netsnmp_sensor_info_s netsnmp_sensor_info;
54+struct netsnmp_sensor_info_s {
55+
56+ netsnmp_index idx;
57+ /* int idx; */
58+ char name[256];
59+
60+ int type;
61+ float value;
62+ char descr[256];
63+ long flags;
64+};
65+
66+netsnmp_container *get_sensor_container( void );
67+netsnmp_cache *get_sensor_cache( void );
68+netsnmp_sensor_info *sensor_by_name( char *, int );
69+NetsnmpCacheLoad netsnmp_sensor_load;
70+NetsnmpCacheFree netsnmp_sensor_free;
71Index: configure.in
72===================================================================
73--- configure.in (revision 16736)
74+++ configure.in (revision 16739)
75@@ -2885,7 +2885,7 @@
76 fi
77
78 # LM-SENSORS-MIB support
79-echo " $module_list " | grep " ucd-snmp/lmSensors " > /dev/null
80+echo " $module_list " | $GREP -i "ucd-snmp/lmsensor" > /dev/null
81 if test $? -eq 0 ; then
82 AC_MSG_CHECKING([for sensors support])
83 case $target_os in
84Index: agent/mibgroup/ucd-snmp/lmsensorsMib.c
85===================================================================
86--- agent/mibgroup/ucd-snmp/lmsensorsMib.c (revision 0)
87+++ agent/mibgroup/ucd-snmp/lmsensorsMib.c (revision 16739)
88@@ -0,0 +1,205 @@ 10@@ -0,0 +1,60 @@
89+#include <net-snmp/net-snmp-config.h> 11+#include <net-snmp/net-snmp-config.h>
90+#include <net-snmp/net-snmp-includes.h> 12+#include <net-snmp/net-snmp-includes.h>
91+#include <net-snmp/agent/net-snmp-agent-includes.h> 13+#include <net-snmp/agent/net-snmp-agent-includes.h>
92+#include <net-snmp/agent/hardware/sensors.h> 14+#include <net-snmp/agent/hardware/sensors.h>
93+#include "ucd-snmp/lmsensorsMib.h"
94+ 15+
95+netsnmp_container *sensorContainer = NULL;
96+ 16+
97+void initialize_lmSensorsTable(const char *tableName, oid *tableOID, 17+void netsnmp_sensor_arch_init( void ) {
98+ netsnmp_container_op *filter, int mult ); 18+ /* Nothing to do */
99+ 19+ DEBUGMSGTL(("sensors:arch", "Initialise Dummy Sensors module\n"));
100+int _sensor_filter_temp( netsnmp_container *c, const void *v );
101+int _sensor_filter_fan( netsnmp_container *c, const void *v );
102+int _sensor_filter_volt( netsnmp_container *c, const void *v );
103+int _sensor_filter_misc( netsnmp_container *c, const void *v );
104+
105+static oid lmTempSensorsTable_oid[] = {1,3,6,1,4,1,2021,13,16,2};
106+static oid lmFanSensorsTable_oid[] = {1,3,6,1,4,1,2021,13,16,3};
107+static oid lmVoltSensorsTable_oid[] = {1,3,6,1,4,1,2021,13,16,4};
108+static oid lmMiscSensorsTable_oid[] = {1,3,6,1,4,1,2021,13,16,5};
109+ /* All the tables have the same length root OID */
110+size_t lmSensorsTables_oid_len = OID_LENGTH(lmMiscSensorsTable_oid);
111+
112+
113+/* Initialise the LM Sensors MIB module */
114+void
115+init_lmsensorsMib(void)
116+{
117+ DEBUGMSGTL(("ucd-snmp/lmsensorsMib","Initializing LM-SENSORS-MIB tables\n"));
118+
119+ /*
120+ * Initialise the four LM-SENSORS-MIB tables
121+ *
122+ * They are almost identical, so we can use the same registration code.
123+ */
124+ initialize_lmSensorsTable( "lmTempSensorsTable", lmTempSensorsTable_oid,
125+ _sensor_filter_temp, 1000 ); /* MIB asks for mC */
126+ initialize_lmSensorsTable( "lmFanSensorsTable", lmFanSensorsTable_oid,
127+ _sensor_filter_fan, 1);
128+ initialize_lmSensorsTable( "lmVoltSensorsTable", lmVoltSensorsTable_oid,
129+ _sensor_filter_volt, 1000 ); /* MIB asks for mV */
130+ initialize_lmSensorsTable( "lmMiscSensorsTable", lmMiscSensorsTable_oid,
131+ _sensor_filter_misc, 1 );
132+} 20+}
133+ 21+
134+/*
135+ * Common initialisation code, used for setting up all four tables
136+ */
137+void
138+initialize_lmSensorsTable(const char *tableName, oid *tableOID,
139+ netsnmp_container_op *filter, int mult )
140+{
141+ netsnmp_handler_registration *reg;
142+ netsnmp_table_registration_info *table_info;
143+ netsnmp_cache *cache;
144+ netsnmp_container *container;
145+
146+ /*
147+ * Ensure the HAL sensors module has been initialised,
148+ * and retrieve the main sensors container.
149+ * This table will then be registered using a filter on this container.
150+ */
151+ sensorContainer = get_sensor_container();
152+ if ( !sensorContainer ) {
153+ init_hw_sensors( );
154+ sensorContainer = get_sensor_container();
155+ }
156+ container = netsnmp_container_find("sensorTable:table_container");
157+ container->insert_filter = filter;
158+ netsnmp_container_add_index( sensorContainer, container );
159+
160+
161+ /*
162+ * Create a basic registration structure for the table
163+ */
164+ reg = netsnmp_create_handler_registration(
165+ tableName, lmSensorsTables_handler,
166+ tableOID, lmSensorsTables_oid_len, HANDLER_CAN_RONLY
167+ );
168+
169+ /*
170+ * Register the table using the filtered container
171+ * Include an indicator of any scaling to be applied to the sensor value
172+ */
173+ reg->my_reg_void = (void *)mult;
174+ table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
175+ netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, 0);
176+ table_info->min_column = COLUMN_LMSENSORS_INDEX;
177+ table_info->max_column = COLUMN_LMSENSORS_VALUE;
178+ netsnmp_container_table_register( reg, table_info, container, 0 );
179+
180+ /*
181+ * If the HAL sensors module was configured as an on-demand caching
182+ * module (rather than being automatically loaded regularly),
183+ * then ensure this table makes use of that cache.
184+ */
185+ cache = get_sensor_cache();
186+ if ( cache ) {
187+ netsnmp_inject_handler_before( reg, netsnmp_cache_handler_get( cache ),
188+ "table_container");
189+ }
190+
191+}
192+
193+
194+/*
195+ * Container filters for the four tables
196+ *
197+ * Used to ensure that sensor entries appear in the appropriate table.
198+ */
199+int _sensor_filter_temp( netsnmp_container *c, const void *v ) {
200+ const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
201+ /* Only matches temperature sensors */
202+ return (( sp->type == NETSNMP_SENSOR_TYPE_TEMPERATURE ) ? 0 : 1 );
203+}
204+
205+int _sensor_filter_fan( netsnmp_container *c, const void *v ) {
206+ const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
207+ /* Only matches fan sensors */
208+ return (( sp->type == NETSNMP_SENSOR_TYPE_RPM ) ? 0 : 1 );
209+}
210+
211+int _sensor_filter_volt( netsnmp_container *c, const void *v ) {
212+ const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
213+ /* Only matches voltage sensors (AC or DC) */
214+ return ((( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_DC ) ||
215+ ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_AC )) ? 0 : 1 );
216+}
217+
218+int _sensor_filter_misc( netsnmp_container *c, const void *v ) {
219+ const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
220+ /* Matches everything except temperature, fan or voltage sensors */
221+ return ((( sp->type == NETSNMP_SENSOR_TYPE_TEMPERATURE ) ||
222+ ( sp->type == NETSNMP_SENSOR_TYPE_RPM ) ||
223+ ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_DC ) ||
224+ ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_AC )) ? 1 : 0 );
225+}
226+
227+
228+/*
229+ * Handle requests for any of the four lmXxxxSensorsTables
230+ *
231+ * This is possible because all the table share the
232+ * same structure and behaviour.
233+ */
234+int 22+int
235+lmSensorsTables_handler( 23+netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
236+ netsnmp_mib_handler *handler, 24+ time_t now;
237+ netsnmp_handler_registration *reginfo, 25+ struct tm *tm;
238+ netsnmp_agent_request_info *reqinfo,
239+ netsnmp_request_info *requests) {
240+
241+ netsnmp_request_info *request;
242+ netsnmp_table_request_info *table_info;
243+ netsnmp_sensor_info *sensor_info; 26+ netsnmp_sensor_info *sp;
244+ int mult = (int)reginfo->my_reg_void;
245+ 27+
246+ DEBUGMSGTL(( "ucd-snmp/lmsensorsMib","lmSensorsTables_handler - root: ")); 28+ time(&now);
247+ DEBUGMSGOID(("ucd-snmp/lmsensorsMib", reginfo->rootoid, reginfo->rootoid_len)); 29+ tm = localtime(&now);
248+ DEBUGMSG(( "ucd-snmp/lmsensorsMib",", mode %d\n", reqinfo->mode ));
249+ /*
250+ * This is a read-only table, so we only need to handle GET requests.
251+ * (The container helper converts GETNEXT->GET requests automatically).
252+ */
253+ switch (reqinfo->mode) {
254+ case MODE_GET:
255+ for (request=requests; request; request=request->next) {
256+ sensor_info = (netsnmp_sensor_info *)
257+ netsnmp_container_table_extract_context(request);
258+ if ( !sensor_info ) {
259+ netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
260+ continue;
261+ }
262+
263+ table_info = netsnmp_extract_table_info(request);
264+ switch (table_info->colnum) {
265+ case COLUMN_LMSENSORS_INDEX:
266+ snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
267+ sensor_info->idx.oids[0]);
268+ break;
269+ case COLUMN_LMSENSORS_DEVICE:
270+ if ( sensor_info->descr[0] != '\0' ) {
271+ snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
272+ sensor_info->descr, strlen(sensor_info->descr));
273+ } else {
274+ snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
275+ sensor_info->name, strlen(sensor_info->name));
276+ }
277+ break;
278+ case COLUMN_LMSENSORS_VALUE:
279+ /* Multiply the value by the appropriate scaling factor for this table */
280+ snmp_set_var_typed_integer( request->requestvb, ASN_GAUGE,
281+ (int)(mult*sensor_info->value));
282+ break;
283+ default:
284+ netsnmp_set_request_error(reqinfo, request,
285+ SNMP_NOSUCHOBJECT);
286+ break;
287+ }
288+ }
289+ break;
290+ 30+
291+ } 31+ DEBUGMSGTL(("sensors:arch", "Reload Dummy Sensors module\n"));
292+ return SNMP_ERR_NOERROR; 32+
33+ /* First pseudo-sensor - slowly-rising temperature */
34+ sp = sensor_by_name( "minute", NETSNMP_SENSOR_TYPE_TEMPERATURE );
35+ sp->value = tm->tm_min;
36+ snprintf( sp->descr, 256, "Minute-based pseudo-sensor - slowly-rising temperature" );
37+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
38+
39+ /* Second pseudo-sensor - quickly-rising temperature */
40+ sp = sensor_by_name( "second", NETSNMP_SENSOR_TYPE_TEMPERATURE );
41+ sp->value = tm->tm_sec;
42+ snprintf( sp->descr, 256, "Second-based pseudo-sensor - quickly-rising temperature" );
43+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
44+
45+ /* Third pseudo-sensor - annual fan speed */
46+ sp = sensor_by_name( "year", NETSNMP_SENSOR_TYPE_RPM );
47+ sp->value = tm->tm_year + 1900;
48+ snprintf( sp->descr, 256, "RPM pseudo-sensor - annual fan speed" );
49+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
50+
51+ /* Fourth pseudo-sensor - daily voltage */
52+ sp = sensor_by_name( "day", NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
53+ sp->value = tm->tm_mday-20;
54+ snprintf( sp->descr, 256, "Day-based pseudo-sensor - positive or negative voltage" );
55+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
56+
57+ /* Fifth pseudo-sensor - monthly voltage */
58+ sp = sensor_by_name( "month", NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
59+ sp->value = tm->tm_mon;
60+ snprintf( sp->descr, 256, "Month-based pseudo-sensor - positive voltage" );
61+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
62+
63+ /* Sixth pseudo-sensor - annual daily something */
64+ sp = sensor_by_name( "yday", NETSNMP_SENSOR_TYPE_OTHER );
65+ sp->value = tm->tm_yday;
66+ snprintf( sp->descr, 256, "Day-based pseudo-sensor - annual something" );
67+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
68+
69+ return 0;
293+} 70+}
294Index: agent/mibgroup/ucd-snmp/lmsensorsMib.h 71diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/dummy_sensors.h
295=================================================================== 72--- /dev/null 2008-07-23 14:59:56.660004489 +0200
296--- agent/mibgroup/ucd-snmp/lmsensorsMib.h (revision 0) 73+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/dummy_sensors.h 2008-07-25 12:53:46.000000000 +0200
297+++ agent/mibgroup/ucd-snmp/lmsensorsMib.h (revision 16739)
298@@ -0,0 +1,23 @@ 74@@ -0,0 +1 @@
299+#ifndef LM_SENSORS_MIB_H
300+#define LM_SENSORS_MIB_H
301+
302+config_require(hardware/sensors) 75+config_require(hardware/sensors/hw_sensors)
303+config_add_mib(LM-SENSORS-MIB) 76diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors.h
304+ 77--- /dev/null 2008-07-23 14:59:56.660004489 +0200
305+/* function declarations */ 78+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors.h 2008-07-25 12:53:46.000000000 +0200
306+void init_lmsensorsMib(void);
307+
308+/*
309+ * Handler and Column definitions for lmXxxxSensorsTable
310+ *
311+ * Note that the same handler (and hence the same
312+ * column identifiers) are used for all four tables.
313+ * This is possible because all the table share the
314+ * same structure and behaviour.
315+ */
316+Netsnmp_Node_Handler lmSensorsTables_handler;
317+#define COLUMN_LMSENSORS_INDEX 1
318+#define COLUMN_LMSENSORS_DEVICE 2
319+#define COLUMN_LMSENSORS_VALUE 3
320+
321+#endif /* LM_SENSORS_MIB_H */
322Index: agent/mibgroup/hardware/sensors.h
323===================================================================
324--- agent/mibgroup/hardware/sensors.h (revision 0)
325+++ agent/mibgroup/hardware/sensors.h (revision 16739)
326@@ -0,0 +1,13 @@ 79@@ -0,0 +1,13 @@
327+config_require(hardware/sensors/hw_sensors) 80+config_require(hardware/sensors/hw_sensors)
328+ 81+
329+#if defined(solaris) 82+#if defined(solaris)
330+# if defined(HAVE_PICL_H) 83+# if defined(HAVE_PICL_H)
335+#else 88+#else
336+config_require(hardware/sensors/lmsensors_v3) 89+config_require(hardware/sensors/lmsensors_v3)
337+#endif 90+#endif
338+ 91+
339+//config_require(hardware/sensors/dummy_sensors) 92+//config_require(hardware/sensors/dummy_sensors)
340Index: agent/mibgroup/hardware/sensors/hw_sensors.h 93diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/hw_sensors.c
341=================================================================== 94--- /dev/null 2008-07-23 14:59:56.660004489 +0200
342--- agent/mibgroup/hardware/sensors/hw_sensors.h (revision 0) 95+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/hw_sensors.c 2008-07-25 12:53:46.000000000 +0200
343+++ agent/mibgroup/hardware/sensors/hw_sensors.h (revision 16739) 96@@ -0,0 +1,183 @@
97+#include <net-snmp/net-snmp-config.h>
98+#include <net-snmp/net-snmp-includes.h>
99+#include <net-snmp/agent/net-snmp-agent-includes.h>
100+#include <net-snmp/agent/hardware/sensors.h>
101+
102+
103+extern NetsnmpCacheLoad netsnmp_sensor_arch_load;
104+extern void netsnmp_sensor_arch_init( void );
105+static int _sensor_load( void );
106+static void _sensor_free( void );
107+
108+static int _sensorAutoUpdate = 0; /* 0 means on-demand caching */
109+static void _sensor_update_stats( unsigned int, void* );
110+
111+netsnmp_cache *_sensor_cache = NULL;
112+netsnmp_container *_sensor_container = NULL;
113+static int _sensor_idx = 0;
114+
115+void init_hw_sensors( void ) {
116+
117+ if ( _sensor_container )
118+ return; /* Already initialised */
119+
120+ DEBUGMSGTL(("sensors", "Initialise Hardware Sensors module\n"));
121+
122+ /*
123+ * Define a container to hold the basic list of sensors
124+ * The four LM-SENSOR-MIB containers will be created in
125+ * the relevant initialisation routine(s)
126+ */
127+ _sensor_container = netsnmp_container_find("sensorTable:table_container");
128+ if ( NULL == _sensor_container ) {
129+ snmp_log( LOG_ERR, "failed to create container for sensorTable");
130+ return;
131+ }
132+ netsnmp_sensor_arch_init( );
133+
134+ /*
135+ * If we're sampling the sensor information automatically,
136+ * then arrange for this to be triggered regularly.
137+ *
138+ * If we're not sampling these values regularly,
139+ * create a suitable cache handler instead.
140+ */
141+ if ( _sensorAutoUpdate ) {
142+ DEBUGMSGTL(("sensors", "Reloading Hardware Sensors automatically (%d)\n",
143+ _sensorAutoUpdate));
144+ snmp_alarm_register( _sensorAutoUpdate, SA_REPEAT,
145+ _sensor_update_stats, NULL );
146+ }
147+ else {
148+ _sensor_cache = netsnmp_cache_create( 5, netsnmp_sensor_load,
149+ netsnmp_sensor_free, NULL, 0 );
150+ DEBUGMSGTL(("sensors", "Reloading Hardware Sensors on-demand (%p)\n",
151+ _sensor_cache));
152+ }
153+}
154+
155+void shutdown_hw_sensors( void ) {
156+ _sensor_free();
157+}
158+
159+/*
160+ * Return the main sensor container
161+ */
162+netsnmp_container *get_sensor_container( void ) { return _sensor_container; }
163+
164+/*
165+ * Return the main sensor cache control structure (if defined)
166+ */
167+netsnmp_cache *get_sensor_cache( void ) { return _sensor_cache; }
168+
169+
170+/*
171+ * Wrapper routine for automatically updating sensor statistics
172+ */
173+void
174+_sensor_update_stats( unsigned int clientreg, void *data )
175+{
176+ _sensor_free();
177+ _sensor_load();
178+}
179+
180+/*
181+ * Wrapper routine for re-loading sensor statistics on demand
182+ */
183+int
184+netsnmp_sensor_load( netsnmp_cache *cache, void *data )
185+{
186+ return _sensor_load();
187+}
188+
189+/*
190+ * Wrapper routine for releasing expired sensor statistics
191+ */
192+void
193+netsnmp_sensor_free( netsnmp_cache *cache, void *data )
194+{
195+ _sensor_free();
196+}
197+
198+
199+/*
200+ * Architecture-independent processing of loading sensor statistics
201+ */
202+static int
203+_sensor_load( void )
204+{
205+ netsnmp_sensor_arch_load( NULL, NULL );
206+}
207+
208+/*
209+ * Architecture-independent release of sensor statistics
210+ */
211+static void
212+_sensor_free( void )
213+{
214+ netsnmp_sensor_info *sp;
215+
216+ for (sp = CONTAINER_FIRST( _sensor_container );
217+ sp;
218+ sp = CONTAINER_NEXT( _sensor_container, sp )) {
219+
220+ sp->flags &= ~ NETSNMP_SENSOR_FLAG_ACTIVE;
221+ }
222+}
223+
224+
225+/*
226+ * Retrieve a sensor entry by name,
227+ * or (optionally) insert a new one into the container
228+ */
229+netsnmp_sensor_info *
230+sensor_by_name( char *name, int create_type )
231+{
232+ netsnmp_sensor_info *sp;
233+
234+ DEBUGMSGTL(("sensors:name", "Get sensor entry (%s)\n", name));
235+
236+ /*
237+ * Look through the list for a matching entry
238+ */
239+ /* .. or use a secondary index container ?? */
240+ for (sp = CONTAINER_FIRST( _sensor_container );
241+ sp;
242+ sp = CONTAINER_NEXT( _sensor_container, sp )) {
243+
244+ if ( !strcmp( name, sp->name ))
245+ return sp;
246+ }
247+
248+ /*
249+ * Not found...
250+ */
251+ if ( create_type == NETSNMP_SENSOR_FIND_EXIST ) {
252+ DEBUGMSGTL(("sensors:name", "No such sensor entry\n"));
253+ return NULL;
254+ }
255+
256+ /*
257+ * ... so let's create a new one, using the type supplied
258+ */
259+ sp = SNMP_MALLOC_TYPEDEF( netsnmp_sensor_info );
260+ if ( sp ) {
261+ strcpy( sp->name, name );
262+ sp->type = create_type;
263+ /*
264+ * Set up the index value.
265+ *
266+ * All this trouble, just for a simple integer.
267+ * Surely there must be a better way?
268+ */
269+ sp->idx.len = 1;
270+ sp->idx.oids = SNMP_MALLOC_TYPEDEF( oid );
271+ sp->idx.oids[0] = ++_sensor_idx;
272+ }
273+
274+ DEBUGMSGTL(("sensors:name", "Create sensor entry (type = %d, index = %d\n",
275+ create_type, _sensor_idx));
276+ CONTAINER_INSERT( _sensor_container, sp );
277+ return sp;
278+}
279+
280diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/hw_sensors.h
281--- /dev/null 2008-07-23 14:59:56.660004489 +0200
282+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/hw_sensors.h 2008-07-25 12:53:46.000000000 +0200
344@@ -0,0 +1 @@ 283@@ -0,0 +1 @@
345+void init_hw_sensors( void ); 284+void init_hw_sensors( void );
346Index: agent/mibgroup/hardware/sensors/lmsensors_v2.h 285diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/kstat_sensors.c
347=================================================================== 286--- /dev/null 2008-07-23 14:59:56.660004489 +0200
348--- agent/mibgroup/hardware/sensors/lmsensors_v2.h (revision 0) 287+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/kstat_sensors.c 2008-07-25 12:53:46.000000000 +0200
349+++ agent/mibgroup/hardware/sensors/lmsensors_v2.h (revision 16739)
350@@ -0,0 +1 @@
351+config_require(hardware/sensors/hw_sensors)
352Index: agent/mibgroup/hardware/sensors/kstat_sensors.c
353===================================================================
354--- agent/mibgroup/hardware/sensors/kstat_sensors.c (revision 0)
355+++ agent/mibgroup/hardware/sensors/kstat_sensors.c (revision 16739)
356@@ -0,0 +1,161 @@ 288@@ -0,0 +1,161 @@
357+#include <net-snmp/net-snmp-config.h> 289+#include <net-snmp/net-snmp-config.h>
358+#include <net-snmp/net-snmp-includes.h> 290+#include <net-snmp/net-snmp-includes.h>
359+#include <net-snmp/agent/net-snmp-agent-includes.h> 291+#include <net-snmp/agent/net-snmp-agent-includes.h>
360+#include <net-snmp/agent/hardware/sensors.h> 292+#include <net-snmp/agent/hardware/sensors.h>
513+ } 445+ }
514+ } 446+ }
515+ 447+
516+ return 0; 448+ return 0;
517+} 449+}
518Index: agent/mibgroup/hardware/sensors/lmsensors_v3.h 450diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/kstat_sensors.h
519=================================================================== 451--- /dev/null 2008-07-23 14:59:56.660004489 +0200
520--- agent/mibgroup/hardware/sensors/lmsensors_v3.h (revision 0) 452+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/kstat_sensors.h 2008-07-25 12:53:46.000000000 +0200
521+++ agent/mibgroup/hardware/sensors/lmsensors_v3.h (revision 16739)
522@@ -0,0 +1 @@ 453@@ -0,0 +1 @@
523+config_require(hardware/sensors/hw_sensors) 454+config_require(hardware/sensors/hw_sensors)
524Index: agent/mibgroup/hardware/sensors/dummy_sensors.c 455diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/lmsensors_v2.c
525=================================================================== 456--- /dev/null 2008-07-23 14:59:56.660004489 +0200
526--- agent/mibgroup/hardware/sensors/dummy_sensors.c (revision 0) 457+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/lmsensors_v2.c 2008-07-25 12:53:46.000000000 +0200
527+++ agent/mibgroup/hardware/sensors/dummy_sensors.c (revision 16739)
528@@ -0,0 +1,60 @@ 458@@ -0,0 +1,75 @@
529+#include <net-snmp/net-snmp-config.h> 459+#include <net-snmp/net-snmp-config.h>
530+#include <net-snmp/net-snmp-includes.h> 460+#include <net-snmp/net-snmp-includes.h>
531+#include <net-snmp/agent/net-snmp-agent-includes.h> 461+#include <net-snmp/agent/net-snmp-agent-includes.h>
532+#include <net-snmp/agent/hardware/sensors.h> 462+#include <net-snmp/agent/hardware/sensors.h>
533+ 463+
464+#include "util_funcs.h"
465+#include <time.h>
466+#include <sensors/sensors.h>
534+ 467+
535+void netsnmp_sensor_arch_init( void ) { 468+void netsnmp_sensor_arch_init( void ) {
536+ /* Nothing to do */ 469+ FILE *fp = fopen("/etc/sensors.conf", "r");
537+ DEBUGMSGTL(("sensors:arch", "Initialise Dummy Sensors module\n")); 470+ DEBUGMSGTL(("sensors:arch", "Initialise LM Sensors module\n"));
471+ sensors_init( fp );
538+} 472+}
539+ 473+
540+int 474+int
541+netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) { 475+netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
542+ time_t now;
543+ struct tm *tm;
544+ netsnmp_sensor_info *sp; 476+ netsnmp_sensor_info *sp;
477+ const sensors_chip_name *chip;
478+ const sensors_feature_data *data;
479+ int chip_nr = 0;
545+ 480+
546+ time(&now);
547+ tm = localtime(&now);
548+
549+ DEBUGMSGTL(("sensors:arch", "Reload Dummy Sensors module\n")); 481+ DEBUGMSGTL(("sensors:arch", "Reload LM Sensors module\n"));
482+ while ((chip = sensors_get_detected_chips(&chip_nr))) {
483+ int a = 0;
484+ int b = 0;
550+ 485+
551+ /* First pseudo-sensor - slowly-rising temperature */ 486+ while ((data = sensors_get_all_features(*chip, &a, &b))) {
552+ sp = sensor_by_name( "minute", NETSNMP_SENSOR_TYPE_TEMPERATURE ); 487+ DEBUGMSGTL(("sensors:arch:detail", "get_all_features (%d, %d)\n", a, b));
553+ sp->value = tm->tm_min; 488+ char *label = NULL;
554+ snprintf( sp->descr, 256, "Minute-based pseudo-sensor - slowly-rising temperature" ); 489+ double val;
490+ int type = NETSNMP_SENSOR_TYPE_OTHER;
491+
492+ if ((data->mode & SENSORS_MODE_R) &&
493+ (data->mapping == SENSORS_NO_MAPPING) &&
494+ !sensors_get_label(*chip, data->number, &label) &&
495+ !sensors_get_feature(*chip, data->number, &val)) {
496+
497+ DEBUGMSGTL(("sensors:arch:detail", "%s = %f\n", label, val));
498+ /*
499+ * Determine the type of sensor from the description.
500+ *
501+ * If the text being looked for below is not in the label of a
502+ * given sensor (e.g., the temp1 sensor has been labeled 'CPU'
503+ * rather than 'CPU temp') it will be categorised as OTHER.
504+ */
505+ if (strstr(label, "V")) {
506+ type = NETSNMP_SENSOR_TYPE_VOLTAGE_DC;
507+ }
508+ if (strstr(label, "fan") || strstr(label, "Fan")) {
509+ type = NETSNMP_SENSOR_TYPE_RPM;
510+ }
511+ if (strstr(label, "temp") || strstr(label, "Temp")) {
512+ type = NETSNMP_SENSOR_TYPE_TEMPERATURE;
513+ }
514+
515+ /*
516+ * Use this type to create a new sensor entry
517+ * (inserting it in the appropriate sub-containers)
518+ */
519+ sp = sensor_by_name( label, type );
520+ if ( sp ) {
521+ sp->value = val;
555+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE; 522+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
556+ 523+ }
557+ /* Second pseudo-sensor - quickly-rising temperature */ 524+ }
558+ sp = sensor_by_name( "second", NETSNMP_SENSOR_TYPE_TEMPERATURE ); 525+ if (label) {
559+ sp->value = tm->tm_sec; 526+ free(label);
560+ snprintf( sp->descr, 256, "Second-based pseudo-sensor - quickly-rising temperature" ); 527+ label = NULL;
561+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE; 528+ }
562+ 529+ } /* end while data */
563+ /* Third pseudo-sensor - annual fan speed */ 530+ } /* end while chip */
564+ sp = sensor_by_name( "year", NETSNMP_SENSOR_TYPE_RPM );
565+ sp->value = tm->tm_year + 1900;
566+ snprintf( sp->descr, 256, "RPM pseudo-sensor - annual fan speed" );
567+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
568+
569+ /* Fourth pseudo-sensor - daily voltage */
570+ sp = sensor_by_name( "day", NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
571+ sp->value = tm->tm_mday-20;
572+ snprintf( sp->descr, 256, "Day-based pseudo-sensor - positive or negative voltage" );
573+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
574+
575+ /* Fifth pseudo-sensor - monthly voltage */
576+ sp = sensor_by_name( "month", NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
577+ sp->value = tm->tm_mon;
578+ snprintf( sp->descr, 256, "Month-based pseudo-sensor - positive voltage" );
579+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
580+
581+ /* Sixth pseudo-sensor - annual daily something */
582+ sp = sensor_by_name( "yday", NETSNMP_SENSOR_TYPE_OTHER );
583+ sp->value = tm->tm_yday;
584+ snprintf( sp->descr, 256, "Day-based pseudo-sensor - annual something" );
585+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
586+ 531+
587+ return 0; 532+ return 0;
588+} 533+}
589Index: agent/mibgroup/hardware/sensors/kstat_sensors.h 534diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/lmsensors_v2.h
590=================================================================== 535--- /dev/null 2008-07-23 14:59:56.660004489 +0200
591--- agent/mibgroup/hardware/sensors/kstat_sensors.h (revision 0) 536+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/lmsensors_v2.h 2008-07-25 12:53:46.000000000 +0200
592+++ agent/mibgroup/hardware/sensors/kstat_sensors.h (revision 16739)
593@@ -0,0 +1 @@ 537@@ -0,0 +1 @@
594+config_require(hardware/sensors/hw_sensors) 538+config_require(hardware/sensors/hw_sensors)
595Index: agent/mibgroup/hardware/sensors/picld_sensors.c 539diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/lmsensors_v3.c
596=================================================================== 540--- /dev/null 2008-07-23 14:59:56.660004489 +0200
597--- agent/mibgroup/hardware/sensors/picld_sensors.c (revision 0) 541+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/lmsensors_v3.c 2008-07-25 12:53:46.000000000 +0200
598+++ agent/mibgroup/hardware/sensors/picld_sensors.c (revision 16739) 542@@ -0,0 +1,101 @@
543+#include <net-snmp/net-snmp-config.h>
544+#include <net-snmp/net-snmp-includes.h>
545+#include <net-snmp/agent/net-snmp-agent-includes.h>
546+#include <net-snmp/agent/hardware/sensors.h>
547+
548+#include "util_funcs.h"
549+#include <time.h>
550+#include <sensors/sensors.h>
551+
552+
553+void netsnmp_sensor_arch_init( void ) {
554+ FILE *fp = fopen("/etc/sensors.conf", "r");
555+ DEBUGMSGTL(("sensors:arch", "Initialise v3 LM Sensors module\n"));
556+ sensors_init( fp );
557+}
558+
559+int
560+netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
561+ netsnmp_sensor_info *sp;
562+ const sensors_chip_name *chip;
563+ const sensors_feature *data;
564+ const sensors_subfeature *data2;
565+ int chip_nr = 0;
566+
567+ DEBUGMSGTL(("sensors:arch", "Reload v3 LM Sensors module\n"));
568+ while ((chip = sensors_get_detected_chips( NULL, &chip_nr))) {
569+ int a = 0;
570+
571+ while ((data = sensors_get_features( chip, &a))) {
572+ DEBUGMSGTL(("sensors:arch:detail", "get_features (%s, %d)\n", data->name, data->number));
573+ int b = 0;
574+
575+
576+ while ((data2 = sensors_get_all_subfeatures( chip, data, &b))) {
577+ char *label = NULL;
578+ double val;
579+ int type = NETSNMP_SENSOR_TYPE_OTHER;
580+
581+ DEBUGMSGTL(("sensors:arch:detail", " get_subfeatures (%s, %d)\n", data2->name, data2->number));
582+ /*
583+ * Check the type of this subfeature,
584+ * concentrating on the main "input" measurements.
585+ */
586+ switch ( data2->type ) {
587+ case SENSORS_SUBFEATURE_IN_INPUT:
588+ type = NETSNMP_SENSOR_TYPE_VOLTAGE_DC;
589+ break;
590+ case SENSORS_SUBFEATURE_FAN_INPUT:
591+ type = NETSNMP_SENSOR_TYPE_RPM;
592+ break;
593+ case SENSORS_SUBFEATURE_TEMP_INPUT:
594+ type = NETSNMP_SENSOR_TYPE_TEMPERATURE;
595+ break;
596+ case SENSORS_SUBFEATURE_VID:
597+ type = NETSNMP_SENSOR_TYPE_VOLTAGE_DC;
598+ break;
599+ default:
600+ /* Skip everything other than these basic sensor features - ??? */
601+ DEBUGMSGTL(("sensors:arch:detail", " Skip type %x\n", data2->type));
602+ continue;
603+ }
604+
605+ /*
606+ * Get the name and value of this subfeature
607+ */
608+/*
609+ if (!(label = sensors_get_label(chip, data))) {
610+ DEBUGMSGTL(("sensors:arch:detail", " Can't get name (%s)\n", label));
611+ continue;
612+ }
613+ if (sensors_get_value(chip, data2->number, &val) < 0) {
614+ DEBUGMSGTL(("sensors:arch:detail", " Can't get value (%f)\n", val));
615+ continue;
616+ }
617+*/
618+ if (!(label = sensors_get_label(chip, data)) ||
619+ (sensors_get_value(chip, data2->number, &val) < 0)) {
620+ DEBUGMSGTL(("sensors:arch:detail", " Can't get name/value (%s, %f)\n", label, val));
621+ continue;
622+ }
623+ DEBUGMSGTL(("sensors:arch:detail", "%s = %f\n", label, val));
624+
625+ /*
626+ * Use this type to create a new sensor entry
627+ * (inserting it in the appropriate sub-containers)
628+ */
629+ sp = sensor_by_name( label, type );
630+ if ( sp ) {
631+ sp->value = val;
632+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
633+ }
634+ if (label) {
635+ free(label);
636+ label = NULL;
637+ }
638+ } /* end while data2 */
639+ } /* end while data */
640+ } /* end while chip */
641+
642+ return 0;
643+}
644diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/lmsensors_v3.h
645--- /dev/null 2008-07-23 14:59:56.660004489 +0200
646+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/lmsensors_v3.h 2008-07-25 12:53:46.000000000 +0200
647@@ -0,0 +1 @@
648+config_require(hardware/sensors/hw_sensors)
649diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/picld_sensors.c
650--- /dev/null 2008-07-23 14:59:56.660004489 +0200
651+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/picld_sensors.c 2008-07-25 12:53:46.000000000 +0200
599@@ -0,0 +1,341 @@ 652@@ -0,0 +1,341 @@
600+#include <net-snmp/net-snmp-config.h> 653+#include <net-snmp/net-snmp-config.h>
601+#include <net-snmp/net-snmp-includes.h> 654+#include <net-snmp/net-snmp-includes.h>
602+#include <net-snmp/agent/net-snmp-agent-includes.h> 655+#include <net-snmp/agent/net-snmp-agent-includes.h>
603+#include <net-snmp/agent/hardware/sensors.h> 656+#include <net-snmp/agent/hardware/sensors.h>
936+void netsnmp_sensor_arch_shutdown( void ) { 989+void netsnmp_sensor_arch_shutdown( void ) {
937+ DEBUGMSGTL(("sensors:arch", "Shutdown PicLD Sensors module\n")); 990+ DEBUGMSGTL(("sensors:arch", "Shutdown PicLD Sensors module\n"));
938+ picl_shutdown(); 991+ picl_shutdown();
939+} 992+}
940+ 993+
941Index: agent/mibgroup/hardware/sensors/hw_sensors.c 994diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/hardware/sensors/picld_sensors.h
942=================================================================== 995--- /dev/null 2008-07-23 14:59:56.660004489 +0200
943--- agent/mibgroup/hardware/sensors/hw_sensors.c (revision 0) 996+++ net-snmp-5.4.1/agent/mibgroup/hardware/sensors/picld_sensors.h 2008-07-25 12:53:46.000000000 +0200
944+++ agent/mibgroup/hardware/sensors/hw_sensors.c (revision 16739)
945@@ -0,0 +1,183 @@ 997@@ -0,0 +1 @@
998+config_require(hardware/sensors/hw_sensors)
999diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/ucd-snmp/lmsensorsMib.c
1000--- /dev/null 2008-07-23 14:59:56.660004489 +0200
1001+++ net-snmp-5.4.1/agent/mibgroup/ucd-snmp/lmsensorsMib.c 2008-07-25 12:53:46.000000000 +0200
1002@@ -0,0 +1,205 @@
946+#include <net-snmp/net-snmp-config.h> 1003+#include <net-snmp/net-snmp-config.h>
947+#include <net-snmp/net-snmp-includes.h> 1004+#include <net-snmp/net-snmp-includes.h>
948+#include <net-snmp/agent/net-snmp-agent-includes.h> 1005+#include <net-snmp/agent/net-snmp-agent-includes.h>
949+#include <net-snmp/agent/hardware/sensors.h> 1006+#include <net-snmp/agent/hardware/sensors.h>
1007+#include "ucd-snmp/lmsensorsMib.h"
950+ 1008+
951+
952+extern NetsnmpCacheLoad netsnmp_sensor_arch_load;
953+extern void netsnmp_sensor_arch_init( void );
954+static int _sensor_load( void );
955+static void _sensor_free( void );
956+
957+static int _sensorAutoUpdate = 0; /* 0 means on-demand caching */
958+static void _sensor_update_stats( unsigned int, void* );
959+
960+netsnmp_cache *_sensor_cache = NULL;
961+netsnmp_container *_sensor_container = NULL; 1009+netsnmp_container *sensorContainer = NULL;
962+static int _sensor_idx = 0;
963+ 1010+
964+void init_hw_sensors( void ) { 1011+void initialize_lmSensorsTable(const char *tableName, oid *tableOID,
1012+ netsnmp_container_op *filter, int mult );
965+ 1013+
966+ if ( _sensor_container ) 1014+int _sensor_filter_temp( netsnmp_container *c, const void *v );
967+ return; /* Already initialised */ 1015+int _sensor_filter_fan( netsnmp_container *c, const void *v );
1016+int _sensor_filter_volt( netsnmp_container *c, const void *v );
1017+int _sensor_filter_misc( netsnmp_container *c, const void *v );
968+ 1018+
969+ DEBUGMSGTL(("sensors", "Initialise Hardware Sensors module\n")); 1019+static oid lmTempSensorsTable_oid[] = {1,3,6,1,4,1,2021,13,16,2};
1020+static oid lmFanSensorsTable_oid[] = {1,3,6,1,4,1,2021,13,16,3};
1021+static oid lmVoltSensorsTable_oid[] = {1,3,6,1,4,1,2021,13,16,4};
1022+static oid lmMiscSensorsTable_oid[] = {1,3,6,1,4,1,2021,13,16,5};
1023+ /* All the tables have the same length root OID */
1024+size_t lmSensorsTables_oid_len = OID_LENGTH(lmMiscSensorsTable_oid);
970+ 1025+
1026+
1027+/* Initialise the LM Sensors MIB module */
1028+void
1029+init_lmsensorsMib(void)
1030+{
1031+ DEBUGMSGTL(("ucd-snmp/lmsensorsMib","Initializing LM-SENSORS-MIB tables\n"));
1032+
971+ /* 1033+ /*
972+ * Define a container to hold the basic list of sensors 1034+ * Initialise the four LM-SENSORS-MIB tables
973+ * The four LM-SENSOR-MIB containers will be created in
974+ * the relevant initialisation routine(s)
975+ */
976+ _sensor_container = netsnmp_container_find("sensorTable:table_container");
977+ if ( NULL == _sensor_container ) {
978+ snmp_log( LOG_ERR, "failed to create container for sensorTable");
979+ return;
980+ }
981+ netsnmp_sensor_arch_init( );
982+
983+ /*
984+ * If we're sampling the sensor information automatically,
985+ * then arrange for this to be triggered regularly.
986+ * 1035+ *
987+ * If we're not sampling these values regularly, 1036+ * They are almost identical, so we can use the same registration code.
988+ * create a suitable cache handler instead.
989+ */ 1037+ */
990+ if ( _sensorAutoUpdate ) { 1038+ initialize_lmSensorsTable( "lmTempSensorsTable", lmTempSensorsTable_oid,
991+ DEBUGMSGTL(("sensors", "Reloading Hardware Sensors automatically (%d)\n", 1039+ _sensor_filter_temp, 1000 ); /* MIB asks for mC */
992+ _sensorAutoUpdate)); 1040+ initialize_lmSensorsTable( "lmFanSensorsTable", lmFanSensorsTable_oid,
993+ snmp_alarm_register( _sensorAutoUpdate, SA_REPEAT,
994+ _sensor_update_stats, NULL );
995+ }
996+ else {
997+ _sensor_cache = netsnmp_cache_create( 5, netsnmp_sensor_load,
998+ netsnmp_sensor_free, NULL, 0 );
999+ DEBUGMSGTL(("sensors", "Reloading Hardware Sensors on-demand (%p)\n",
1000+ _sensor_cache)); 1041+ _sensor_filter_fan, 1);
1001+ } 1042+ initialize_lmSensorsTable( "lmVoltSensorsTable", lmVoltSensorsTable_oid,
1043+ _sensor_filter_volt, 1000 ); /* MIB asks for mV */
1044+ initialize_lmSensorsTable( "lmMiscSensorsTable", lmMiscSensorsTable_oid,
1045+ _sensor_filter_misc, 1 );
1002+} 1046+}
1003+ 1047+
1004+void shutdown_hw_sensors( void ) {
1005+ _sensor_free();
1006+}
1007+
1008+/* 1048+/*
1009+ * Return the main sensor container 1049+ * Common initialisation code, used for setting up all four tables
1010+ */
1011+netsnmp_container *get_sensor_container( void ) { return _sensor_container; }
1012+
1013+/*
1014+ * Return the main sensor cache control structure (if defined)
1015+ */
1016+netsnmp_cache *get_sensor_cache( void ) { return _sensor_cache; }
1017+
1018+
1019+/*
1020+ * Wrapper routine for automatically updating sensor statistics
1021+ */ 1050+ */
1022+void 1051+void
1023+_sensor_update_stats( unsigned int clientreg, void *data ) 1052+initialize_lmSensorsTable(const char *tableName, oid *tableOID,
1053+ netsnmp_container_op *filter, int mult )
1024+{ 1054+{
1025+ _sensor_free(); 1055+ netsnmp_handler_registration *reg;
1026+ _sensor_load(); 1056+ netsnmp_table_registration_info *table_info;
1027+} 1057+ netsnmp_cache *cache;
1058+ netsnmp_container *container;
1028+ 1059+
1060+ /*
1061+ * Ensure the HAL sensors module has been initialised,
1062+ * and retrieve the main sensors container.
1063+ * This table will then be registered using a filter on this container.
1064+ */
1065+ sensorContainer = get_sensor_container();
1066+ if ( !sensorContainer ) {
1067+ init_hw_sensors( );
1068+ sensorContainer = get_sensor_container();
1069+ }
1070+ container = netsnmp_container_find("sensorTable:table_container");
1071+ container->insert_filter = filter;
1072+ netsnmp_container_add_index( sensorContainer, container );
1073+
1074+
1075+ /*
1076+ * Create a basic registration structure for the table
1077+ */
1078+ reg = netsnmp_create_handler_registration(
1079+ tableName, lmSensorsTables_handler,
1080+ tableOID, lmSensorsTables_oid_len, HANDLER_CAN_RONLY
1081+ );
1082+
1083+ /*
1084+ * Register the table using the filtered container
1085+ * Include an indicator of any scaling to be applied to the sensor value
1086+ */
1087+ reg->my_reg_void = (void *)mult;
1088+ table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
1089+ netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, 0);
1090+ table_info->min_column = COLUMN_LMSENSORS_INDEX;
1091+ table_info->max_column = COLUMN_LMSENSORS_VALUE;
1092+ netsnmp_container_table_register( reg, table_info, container, 0 );
1093+
1094+ /*
1095+ * If the HAL sensors module was configured as an on-demand caching
1096+ * module (rather than being automatically loaded regularly),
1097+ * then ensure this table makes use of that cache.
1098+ */
1099+ cache = get_sensor_cache();
1100+ if ( cache ) {
1101+ netsnmp_inject_handler_before( reg, netsnmp_cache_handler_get( cache ),
1102+ "table_container");
1103+ }
1104+
1105+}
1106+
1107+
1029+/* 1108+/*
1030+ * Wrapper routine for re-loading sensor statistics on demand 1109+ * Container filters for the four tables
1110+ *
1111+ * Used to ensure that sensor entries appear in the appropriate table.
1112+ */
1113+int _sensor_filter_temp( netsnmp_container *c, const void *v ) {
1114+ const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
1115+ /* Only matches temperature sensors */
1116+ return (( sp->type == NETSNMP_SENSOR_TYPE_TEMPERATURE ) ? 0 : 1 );
1117+}
1118+
1119+int _sensor_filter_fan( netsnmp_container *c, const void *v ) {
1120+ const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
1121+ /* Only matches fan sensors */
1122+ return (( sp->type == NETSNMP_SENSOR_TYPE_RPM ) ? 0 : 1 );
1123+}
1124+
1125+int _sensor_filter_volt( netsnmp_container *c, const void *v ) {
1126+ const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
1127+ /* Only matches voltage sensors (AC or DC) */
1128+ return ((( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_DC ) ||
1129+ ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_AC )) ? 0 : 1 );
1130+}
1131+
1132+int _sensor_filter_misc( netsnmp_container *c, const void *v ) {
1133+ const netsnmp_sensor_info *sp = (const netsnmp_sensor_info *)v;
1134+ /* Matches everything except temperature, fan or voltage sensors */
1135+ return ((( sp->type == NETSNMP_SENSOR_TYPE_TEMPERATURE ) ||
1136+ ( sp->type == NETSNMP_SENSOR_TYPE_RPM ) ||
1137+ ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_DC ) ||
1138+ ( sp->type == NETSNMP_SENSOR_TYPE_VOLTAGE_AC )) ? 1 : 0 );
1139+}
1140+
1141+
1142+/*
1143+ * Handle requests for any of the four lmXxxxSensorsTables
1144+ *
1145+ * This is possible because all the table share the
1146+ * same structure and behaviour.
1031+ */ 1147+ */
1032+int 1148+int
1033+netsnmp_sensor_load( netsnmp_cache *cache, void *data ) 1149+lmSensorsTables_handler(
1034+{ 1150+ netsnmp_mib_handler *handler,
1035+ return _sensor_load(); 1151+ netsnmp_handler_registration *reginfo,
1036+} 1152+ netsnmp_agent_request_info *reqinfo,
1153+ netsnmp_request_info *requests) {
1037+ 1154+
1038+/* 1155+ netsnmp_request_info *request;
1039+ * Wrapper routine for releasing expired sensor statistics 1156+ netsnmp_table_request_info *table_info;
1040+ */
1041+void
1042+netsnmp_sensor_free( netsnmp_cache *cache, void *data )
1043+{
1044+ _sensor_free();
1045+}
1046+
1047+
1048+/*
1049+ * Architecture-independent processing of loading sensor statistics
1050+ */
1051+static int
1052+_sensor_load( void )
1053+{
1054+ netsnmp_sensor_arch_load( NULL, NULL );
1055+}
1056+
1057+/*
1058+ * Architecture-independent release of sensor statistics
1059+ */
1060+static void
1061+_sensor_free( void )
1062+{
1063+ netsnmp_sensor_info *sp;
1064+
1065+ for (sp = CONTAINER_FIRST( _sensor_container );
1066+ sp;
1067+ sp = CONTAINER_NEXT( _sensor_container, sp )) {
1068+
1069+ sp->flags &= ~ NETSNMP_SENSOR_FLAG_ACTIVE;
1070+ }
1071+}
1072+
1073+
1074+/*
1075+ * Retrieve a sensor entry by name,
1076+ * or (optionally) insert a new one into the container
1077+ */
1078+netsnmp_sensor_info *
1079+sensor_by_name( char *name, int create_type )
1080+{
1081+ netsnmp_sensor_info *sp;
1082+
1083+ DEBUGMSGTL(("sensors:name", "Get sensor entry (%s)\n", name));
1084+
1085+ /*
1086+ * Look through the list for a matching entry
1087+ */
1088+ /* .. or use a secondary index container ?? */
1089+ for (sp = CONTAINER_FIRST( _sensor_container );
1090+ sp;
1091+ sp = CONTAINER_NEXT( _sensor_container, sp )) {
1092+
1093+ if ( !strcmp( name, sp->name ))
1094+ return sp;
1095+ }
1096+
1097+ /*
1098+ * Not found...
1099+ */
1100+ if ( create_type == NETSNMP_SENSOR_FIND_EXIST ) {
1101+ DEBUGMSGTL(("sensors:name", "No such sensor entry\n"));
1102+ return NULL;
1103+ }
1104+
1105+ /*
1106+ * ... so let's create a new one, using the type supplied
1107+ */
1108+ sp = SNMP_MALLOC_TYPEDEF( netsnmp_sensor_info );
1109+ if ( sp ) {
1110+ strcpy( sp->name, name );
1111+ sp->type = create_type;
1112+ /*
1113+ * Set up the index value.
1114+ *
1115+ * All this trouble, just for a simple integer.
1116+ * Surely there must be a better way?
1117+ */
1118+ sp->idx.len = 1;
1119+ sp->idx.oids = SNMP_MALLOC_TYPEDEF( oid );
1120+ sp->idx.oids[0] = ++_sensor_idx;
1121+ }
1122+
1123+ DEBUGMSGTL(("sensors:name", "Create sensor entry (type = %d, index = %d\n",
1124+ create_type, _sensor_idx));
1125+ CONTAINER_INSERT( _sensor_container, sp );
1126+ return sp;
1127+}
1128+
1129Index: agent/mibgroup/hardware/sensors/dummy_sensors.h
1130===================================================================
1131--- agent/mibgroup/hardware/sensors/dummy_sensors.h (revision 0)
1132+++ agent/mibgroup/hardware/sensors/dummy_sensors.h (revision 16739)
1133@@ -0,0 +1 @@
1134+config_require(hardware/sensors/hw_sensors)
1135Index: agent/mibgroup/hardware/sensors/lmsensors_v2.c
1136===================================================================
1137--- agent/mibgroup/hardware/sensors/lmsensors_v2.c (revision 0)
1138+++ agent/mibgroup/hardware/sensors/lmsensors_v2.c (revision 16739)
1139@@ -0,0 +1,75 @@
1140+#include <net-snmp/net-snmp-config.h>
1141+#include <net-snmp/net-snmp-includes.h>
1142+#include <net-snmp/agent/net-snmp-agent-includes.h>
1143+#include <net-snmp/agent/hardware/sensors.h>
1144+
1145+#include "util_funcs.h"
1146+#include <time.h>
1147+#include <sensors/sensors.h>
1148+
1149+void netsnmp_sensor_arch_init( void ) {
1150+ FILE *fp = fopen("/etc/sensors.conf", "r");
1151+ DEBUGMSGTL(("sensors:arch", "Initialise LM Sensors module\n"));
1152+ sensors_init( fp );
1153+}
1154+
1155+int
1156+netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
1157+ netsnmp_sensor_info *sp; 1157+ netsnmp_sensor_info *sensor_info;
1158+ const sensors_chip_name *chip; 1158+ int mult = (int)reginfo->my_reg_void;
1159+ const sensors_feature_data *data;
1160+ int chip_nr = 0;
1161+ 1159+
1162+ DEBUGMSGTL(("sensors:arch", "Reload LM Sensors module\n")); 1160+ DEBUGMSGTL(( "ucd-snmp/lmsensorsMib","lmSensorsTables_handler - root: "));
1163+ while ((chip = sensors_get_detected_chips(&chip_nr))) { 1161+ DEBUGMSGOID(("ucd-snmp/lmsensorsMib", reginfo->rootoid, reginfo->rootoid_len));
1164+ int a = 0; 1162+ DEBUGMSG(( "ucd-snmp/lmsensorsMib",", mode %d\n", reqinfo->mode ));
1165+ int b = 0; 1163+ /*
1166+ 1164+ * This is a read-only table, so we only need to handle GET requests.
1167+ while ((data = sensors_get_all_features(*chip, &a, &b))) { 1165+ * (The container helper converts GETNEXT->GET requests automatically).
1168+ DEBUGMSGTL(("sensors:arch:detail", "get_all_features (%d, %d)\n", a, b)); 1166+ */
1169+ char *label = NULL; 1167+ switch (reqinfo->mode) {
1170+ double val; 1168+ case MODE_GET:
1171+ int type = NETSNMP_SENSOR_TYPE_OTHER; 1169+ for (request=requests; request; request=request->next) {
1172+ 1170+ sensor_info = (netsnmp_sensor_info *)
1173+ if ((data->mode & SENSORS_MODE_R) && 1171+ netsnmp_container_table_extract_context(request);
1174+ (data->mapping == SENSORS_NO_MAPPING) && 1172+ if ( !sensor_info ) {
1175+ !sensors_get_label(*chip, data->number, &label) && 1173+ netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
1176+ !sensors_get_feature(*chip, data->number, &val)) {
1177+
1178+ DEBUGMSGTL(("sensors:arch:detail", "%s = %f\n", label, val));
1179+ /*
1180+ * Determine the type of sensor from the description.
1181+ *
1182+ * If the text being looked for below is not in the label of a
1183+ * given sensor (e.g., the temp1 sensor has been labeled 'CPU'
1184+ * rather than 'CPU temp') it will be categorised as OTHER.
1185+ */
1186+ if (strstr(label, "V")) {
1187+ type = NETSNMP_SENSOR_TYPE_VOLTAGE_DC;
1188+ } 1174+ continue;
1189+ if (strstr(label, "fan") || strstr(label, "Fan")) {
1190+ type = NETSNMP_SENSOR_TYPE_RPM;
1191+ }
1192+ if (strstr(label, "temp") || strstr(label, "Temp")) {
1193+ type = NETSNMP_SENSOR_TYPE_TEMPERATURE;
1194+ }
1195+
1196+ /*
1197+ * Use this type to create a new sensor entry
1198+ * (inserting it in the appropriate sub-containers)
1199+ */
1200+ sp = sensor_by_name( label, type );
1201+ if ( sp ) {
1202+ sp->value = val;
1203+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
1204+ }
1205+ } 1175+ }
1206+ if (label) { 1176+
1207+ free(label); 1177+ table_info = netsnmp_extract_table_info(request);
1208+ label = NULL; 1178+ switch (table_info->colnum) {
1209+ } 1179+ case COLUMN_LMSENSORS_INDEX:
1210+ } /* end while data */ 1180+ snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
1211+ } /* end while chip */ 1181+ sensor_info->idx.oids[0]);
1212+
1213+ return 0;
1214+}
1215Index: agent/mibgroup/hardware/sensors/picld_sensors.h
1216===================================================================
1217--- agent/mibgroup/hardware/sensors/picld_sensors.h (revision 0)
1218+++ agent/mibgroup/hardware/sensors/picld_sensors.h (revision 16739)
1219@@ -0,0 +1 @@
1220+config_require(hardware/sensors/hw_sensors)
1221Index: agent/mibgroup/hardware/sensors/lmsensors_v3.c
1222===================================================================
1223--- agent/mibgroup/hardware/sensors/lmsensors_v3.c (revision 0)
1224+++ agent/mibgroup/hardware/sensors/lmsensors_v3.c (revision 16739)
1225@@ -0,0 +1,101 @@
1226+#include <net-snmp/net-snmp-config.h>
1227+#include <net-snmp/net-snmp-includes.h>
1228+#include <net-snmp/agent/net-snmp-agent-includes.h>
1229+#include <net-snmp/agent/hardware/sensors.h>
1230+
1231+#include "util_funcs.h"
1232+#include <time.h>
1233+#include <sensors/sensors.h>
1234+
1235+
1236+void netsnmp_sensor_arch_init( void ) {
1237+ FILE *fp = fopen("/etc/sensors.conf", "r");
1238+ DEBUGMSGTL(("sensors:arch", "Initialise v3 LM Sensors module\n"));
1239+ sensors_init( fp );
1240+}
1241+
1242+int
1243+netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
1244+ netsnmp_sensor_info *sp;
1245+ const sensors_chip_name *chip;
1246+ const sensors_feature *data;
1247+ const sensors_subfeature *data2;
1248+ int chip_nr = 0;
1249+
1250+ DEBUGMSGTL(("sensors:arch", "Reload v3 LM Sensors module\n"));
1251+ while ((chip = sensors_get_detected_chips( NULL, &chip_nr))) {
1252+ int a = 0;
1253+
1254+ while ((data = sensors_get_features( chip, &a))) {
1255+ DEBUGMSGTL(("sensors:arch:detail", "get_features (%s, %d)\n", data->name, data->number));
1256+ int b = 0;
1257+
1258+
1259+ while ((data2 = sensors_get_all_subfeatures( chip, data, &b))) {
1260+ char *label = NULL;
1261+ double val;
1262+ int type = NETSNMP_SENSOR_TYPE_OTHER;
1263+
1264+ DEBUGMSGTL(("sensors:arch:detail", " get_subfeatures (%s, %d)\n", data2->name, data2->number));
1265+ /*
1266+ * Check the type of this subfeature,
1267+ * concentrating on the main "input" measurements.
1268+ */
1269+ switch ( data2->type ) {
1270+ case SENSORS_SUBFEATURE_IN_INPUT:
1271+ type = NETSNMP_SENSOR_TYPE_VOLTAGE_DC;
1272+ break; 1182+ break;
1273+ case SENSORS_SUBFEATURE_FAN_INPUT: 1183+ case COLUMN_LMSENSORS_DEVICE:
1274+ type = NETSNMP_SENSOR_TYPE_RPM; 1184+ if ( sensor_info->descr[0] != '\0' ) {
1185+ snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
1186+ sensor_info->descr, strlen(sensor_info->descr));
1187+ } else {
1188+ snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
1189+ sensor_info->name, strlen(sensor_info->name));
1190+ }
1275+ break; 1191+ break;
1276+ case SENSORS_SUBFEATURE_TEMP_INPUT: 1192+ case COLUMN_LMSENSORS_VALUE:
1277+ type = NETSNMP_SENSOR_TYPE_TEMPERATURE; 1193+ /* Multiply the value by the appropriate scaling factor for this table */
1194+ snmp_set_var_typed_integer( request->requestvb, ASN_GAUGE,
1195+ (int)(mult*sensor_info->value));
1278+ break; 1196+ break;
1279+ case SENSORS_SUBFEATURE_VID: 1197+ default:
1280+ type = NETSNMP_SENSOR_TYPE_VOLTAGE_DC; 1198+ netsnmp_set_request_error(reqinfo, request,
1199+ SNMP_NOSUCHOBJECT);
1281+ break; 1200+ break;
1282+ default:
1283+ /* Skip everything other than these basic sensor features - ??? */
1284+ DEBUGMSGTL(("sensors:arch:detail", " Skip type %x\n", data2->type));
1285+ continue;
1286+ }
1287+ 1201+ }
1288+ /*
1289+ * Get the name and value of this subfeature
1290+ */
1291+/*
1292+ if (!(label = sensors_get_label(chip, data))) {
1293+ DEBUGMSGTL(("sensors:arch:detail", " Can't get name (%s)\n", label));
1294+ continue;
1295+ }
1296+ if (sensors_get_value(chip, data2->number, &val) < 0) {
1297+ DEBUGMSGTL(("sensors:arch:detail", " Can't get value (%f)\n", val));
1298+ continue;
1299+ }
1300+*/
1301+ if (!(label = sensors_get_label(chip, data)) ||
1302+ (sensors_get_value(chip, data2->number, &val) < 0)) {
1303+ DEBUGMSGTL(("sensors:arch:detail", " Can't get name/value (%s, %f)\n", label, val));
1304+ continue;
1305+ }
1306+ DEBUGMSGTL(("sensors:arch:detail", "%s = %f\n", label, val));
1307+
1308+ /*
1309+ * Use this type to create a new sensor entry
1310+ * (inserting it in the appropriate sub-containers)
1311+ */
1312+ sp = sensor_by_name( label, type );
1313+ if ( sp ) {
1314+ sp->value = val;
1315+ sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
1316+ }
1317+ if (label) {
1318+ free(label);
1319+ label = NULL;
1320+ } 1202+ }
1321+ } /* end while data2 */ 1203+ break;
1322+ } /* end while data */
1323+ } /* end while chip */
1324+ 1204+
1325+ return 0; 1205+ }
1206+ return SNMP_ERR_NOERROR;
1207+}
1208diff -up /dev/null net-snmp-5.4.1/agent/mibgroup/ucd-snmp/lmsensorsMib.h
1209--- /dev/null 2008-07-23 14:59:56.660004489 +0200
1210+++ net-snmp-5.4.1/agent/mibgroup/ucd-snmp/lmsensorsMib.h 2008-07-25 12:53:46.000000000 +0200
1211@@ -0,0 +1,23 @@
1212+#ifndef LM_SENSORS_MIB_H
1213+#define LM_SENSORS_MIB_H
1214+
1215+config_require(hardware/sensors)
1216+config_add_mib(LM-SENSORS-MIB)
1217+
1218+/* function declarations */
1219+void init_lmsensorsMib(void);
1220+
1221+/*
1222+ * Handler and Column definitions for lmXxxxSensorsTable
1223+ *
1224+ * Note that the same handler (and hence the same
1225+ * column identifiers) are used for all four tables.
1226+ * This is possible because all the table share the
1227+ * same structure and behaviour.
1228+ */
1229+Netsnmp_Node_Handler lmSensorsTables_handler;
1230+#define COLUMN_LMSENSORS_INDEX 1
1231+#define COLUMN_LMSENSORS_DEVICE 2
1232+#define COLUMN_LMSENSORS_VALUE 3
1233+
1234+#endif /* LM_SENSORS_MIB_H */
1235diff -up net-snmp-5.4.1/configure.backup_patch_15 net-snmp-5.4.1/configure
1236--- net-snmp-5.4.1/configure.backup_patch_15 2008-07-25 12:53:39.000000000 +0200
1237+++ net-snmp-5.4.1/configure 2008-07-25 12:53:46.000000000 +0200
1238@@ -31030,7 +31030,7 @@ fi
1239 fi
1240
1241 # LM-SENSORS-MIB support
1242-echo " $module_list " | grep " ucd-snmp/lmSensors " > /dev/null
1243+echo " $module_list " | $GREP -i "ucd-snmp/lmsensor" > /dev/null
1244 if test $? -eq 0 ; then
1245 echo "$as_me:$LINENO: checking for sensors support" >&5
1246 echo $ECHO_N "checking for sensors support... $ECHO_C" >&6
1247diff -up net-snmp-5.4.1/configure.in.backup_patch_15 net-snmp-5.4.1/configure.in
1248--- net-snmp-5.4.1/configure.in.backup_patch_15 2008-07-25 12:53:39.000000000 +0200
1249+++ net-snmp-5.4.1/configure.in 2008-07-25 12:53:46.000000000 +0200
1250@@ -2880,7 +2880,7 @@ if test $? -eq 0 ; then
1251 fi
1252
1253 # LM-SENSORS-MIB support
1254-echo " $module_list " | grep " ucd-snmp/lmSensors " > /dev/null
1255+echo " $module_list " | $GREP -i "ucd-snmp/lmsensor" > /dev/null
1256 if test $? -eq 0 ; then
1257 AC_MSG_CHECKING([for sensors support])
1258 case $target_os in
1259diff -up /dev/null net-snmp-5.4.1/include/net-snmp/agent/hardware/sensors.h
1260--- /dev/null 2008-07-23 14:59:56.660004489 +0200
1261+++ net-snmp-5.4.1/include/net-snmp/agent/hardware/sensors.h 2008-07-25 12:53:46.000000000 +0200
1262@@ -0,0 +1,48 @@
1263+/*
1264+ * Hardware Abstraction Layer - Sensors module
1265+ *
1266+ * Public interface
1267+ */
1268+
1269+#define NETSNMP_SENSOR_TYPE_OTHER 1
1270+#define NETSNMP_SENSOR_TYPE_VOLTAGE_AC 3
1271+#define NETSNMP_SENSOR_TYPE_VOLTAGE_DC 4
1272+#define NETSNMP_SENSOR_TYPE_CURRENT 5
1273+#define NETSNMP_SENSOR_TYPE_POWER 6
1274+#define NETSNMP_SENSOR_TYPE_FREQUENCY 7
1275+#define NETSNMP_SENSOR_TYPE_TEMPERATURE 8
1276+#define NETSNMP_SENSOR_TYPE_HUMIDITY 9
1277+#define NETSNMP_SENSOR_TYPE_RPM 10
1278+#define NETSNMP_SENSOR_TYPE_VOLUME 11
1279+#define NETSNMP_SENSOR_TYPE_BOOLEAN 12
1280+
1281+
1282+#define NETSNMP_SENSOR_FLAG_ACTIVE 0x01
1283+#define NETSNMP_SENSOR_FLAG_NAVAIL 0x02
1284+#define NETSNMP_SENSOR_FLAG_BROKEN 0x04
1285+#define NETSNMP_SENSOR_FLAG_DISABLE 0x08
1286+
1287+#define NETSNMP_SENSOR_MASK_STATUS 0x06 /* NAVAIL|BROKEN */
1288+
1289+
1290+#define NETSNMP_SENSOR_FIND_CREATE 1 /* or use one of the sensor type values */
1291+#define NETSNMP_SENSOR_FIND_EXIST 0
1292+
1293+typedef struct netsnmp_sensor_info_s netsnmp_sensor_info;
1294+struct netsnmp_sensor_info_s {
1295+
1296+ netsnmp_index idx;
1297+ /* int idx; */
1298+ char name[256];
1299+
1300+ int type;
1301+ float value;
1302+ char descr[256];
1303+ long flags;
1326+} 1304+};
1305+
1306+netsnmp_container *get_sensor_container( void );
1307+netsnmp_cache *get_sensor_cache( void );
1308+netsnmp_sensor_info *sensor_by_name( char *, int );
1309+NetsnmpCacheLoad netsnmp_sensor_load;
1310+NetsnmpCacheFree netsnmp_sensor_free;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

admin@fedoraproject.org
ViewVC Help
Powered by ViewVC 1.1.2