Version 2 (modified by ChrisJohns, on Dec 1, 2005 at 2:42:33 PM) (diff)

Updated the info.



The NetSNMP package can be used with RTEMS to provide a full agent implementation. The NetSNMP project can be found at the following link

NetSNMP implements the V1, V2 and V3 versions of the protocol which can be accessed through the SNMP library API. The package also implements a full agent and included in the agent is a MIB-II standard mib. RTEMS used the FreeBSD networking stack and part of this is the sysctl interface. NetSNMP can use this interface to obtain data about interfaces and networking stack.

Building NetSNMP

These instruction have been tested using RTEMS 4.6.x for the M68K Coldfire processor.

# Download the NetSNMP package from the RTEMS FTP site ( # Unpack the source code. # Create a build directory. # Configure, name and install.

$ wget $ tar zxf rtems-net-snmp-5-0-8.tar.gz $ mkdir rtems-m68k $ cd rtems-m68k $ ../rtems-net-snmp-5-0-8/configure --target=m68k-rtems --prefix=/opt/rtems $ make $ make install

I have only tested v1 and V2.

Starting NetSNMP

The NetSNMP agent runs as a single task under RTEMS. The agents main is compiled specifically for RTEMS and is involked by calling the function:

int snmpd_init (rtems_task_priority priority, char* cmdline);

The command line is the documented in the snmpd man page ( Select the priority that suites your application. SNMP will use your processing resources and as it is typically used for monitoring a priority lower than your important real-time tasks as well as the networking stack is recommended.

This document will refer to snmpd as the NetSNMP agent running as an RTEMS task.

The NetSNMP uses a number of files. The most important of these is the /etc/snmpd.conf. You need to arrange to have this file created before you start snmpd. Many ways exist in RTEMS to create this file. For example code to write the file, coping directly from non-volatile storage to the IFMS, reading from a disk drive, or using the untar call.

The standard NetSNMP configure script creates a list of modules that the agent supports. The modules active when snmpd is running is controlled by command line options. This makes sense on a Unix or Windows host. Here you build into the agent all that is supported by the host and the system administrator enables what is needed. On an embedded system this approach results in an executable that is much larger than required. To keep the image size to what you need a function called by the agent that specifies the list of agent modules you require needs to be provided. An RTEMS application may look like:

#include <stdio.h> #include <rtems.h> #include <rtems/untar.h> /

  • NetSNMP MIBS. */

void init_system_mib(); void init_sysORTable(); void init_at(); void init_interfaces(); void init_snmp_mib(); void init_tcp(); void init_icmp(); void init_ip(); void init_udp(); void init_vacm_vars(); void init_setSerialNo(); void init_snmpEngine(); void init_snmpMPDStats(); void init_usmStats(); void init_usmUser(); void init_snmpNotifyTable(); void init_snmpNotifyFilterTable(); void init_snmpNotifyFilterProfileTable(); void init_snmpTargetAddrEntry(); void init_snmpTargetParamsEntry(); void init_target_counters(); void init_nsTransactionTable(); void init_nsModuleTable(); void init_override(); void init_var_route(); void init_vacm_context(); void init_mib_modules (); int snmpd_init (rtems_task_priority priority, char* cmdline); /*

  • These are created by the linker when linking a binary file. */

extern int _binary_net_snmp_files_tar_start; extern int _binary_net_snmp_files_tar_size; /*

  • We need to supply this function. It is call by the
  • the snmpd agent. List the modules we need. They will
  • be linked from the NetSNMP library. */

void init_mib_modules () {

init_system_mib(); init_sysORTable(); init_at(); init_interfaces(); init_snmp_mib(); init_tcp(); init_icmp(); init_ip(); init_udp();


init_vacm_vars(); init_setSerialNo(); init_snmpEngine(); init_snmpMPDStats(); init_usmStats(); init_usmUser(); init_snmpNotifyTable(); init_snmpNotifyFilterTable(); init_snmpNotifyFilterProfileTable(); init_snmpTargetAddrEntry(); init_snmpTargetParamsEntry(); init_target_counters(); init_nsTransactionTable(); init_nsModuleTable(); init_override(); init_var_route(); init_vacm_context();

#endif } /

  • Main line. */

int Init () {


  • Place the snmpd files into the IMFS. */

Untar_FromMemory ((unsigned char *) (&_binary_net_snmp_files_tar_start),

(int) &_binary_net_snmp_files_tar_size);


  • Start the BSD TCP/IP stack. */

rtems_bsdnet_initialize_network (); /*

  • Start the Net SNMP server. */

if (!snmpd_init (150, "-f -L")) {

printf ("Net SNMP did not start\n")

return 1;

} rtems_task_delete (RTEMS_SELF);