### Build and Install Commands Source: http://www.net-snmp.org/docs/README.win32.html Standard commands to compile and install the package. ```shell make ``` ```shell make install ``` -------------------------------- ### Build and Install Net-SNMP Source: http://www.net-snmp.org/docs/README.solaris.html Standard commands to compile and install the software. ```bash make make test (optional) make install /usr/local/net-snmp/bin/perl -V ``` -------------------------------- ### Build and Install Net-SNMP Source: http://www.net-snmp.org/docs/README.solaris.html Standard commands to compile, test, and install the software. ```bash make ``` ```bash make test ``` ```bash make install ``` -------------------------------- ### Build and Install with nmake Source: http://www.net-snmp.org/docs/README.win32.html Execute build, clean, and install targets using nmake after generating configuration files. ```batch nmake clean nmake nmake install ``` ```batch nmake libs_clean nmake libs nmake install ``` ```batch nmake perl_clean nmake perl nmake perl_test nmake perl_install ``` -------------------------------- ### Run snmpconf basic setup Source: http://www.net-snmp.org/docs/man/snmpconf.html Executes the basic setup group to walk the user through initial configuration questions. ```bash snmpconf -g basic_setup ``` -------------------------------- ### Quick Installation Commands Source: http://www.net-snmp.org/docs/INSTALL.html Standard sequence of commands to configure, build, and install the Net-SNMP package. ```bash 1) Run ./configure (type "./configure --help" for a quick usage summary.) (--prefix=PATH will change the default /usr/local installation path.) (see "Compilers and Options" on changing the compiler to use) 2) Optionally edit include/net-snmp/net-snmp-config.h (due to prompting done by the configure script, this is very rarely necessary.) 3) make 4) Run the next command as root: 5) make install 6) configure the agent (either using 'snmpconf' or by crafting an snmpd.conf file manually. The file 'EXAMPLE.conf' may be a suitable starting point) ``` -------------------------------- ### Build Windows Binary Installer Source: http://www.net-snmp.org/docs/README.win32.html Steps to build the Net-SNMP Windows installer from the source directory. ```shell .\build-binary.bat ``` -------------------------------- ### Install ExtUtils-FakeConfig Source: http://www.net-snmp.org/docs/perl-SNMP-README.html Build and install commands for the ExtUtils-FakeConfig module required for MinGW builds. ```shell perl Makefile.PL dmake dmake install ``` -------------------------------- ### Install MinGW dependencies Source: http://www.net-snmp.org/docs/README.win32.html Install required libraries for MinGW build using mingw-get. ```bash mingw-get install msys-libregex msys-libintl msys-libopenssl mingw-get upgrade msys-libregex msys-libintl msys-libopenssl ``` -------------------------------- ### Install agent binary with custom prefixes Source: http://www.net-snmp.org/docs/FAQ.html Use this command to specify target and temporary installation locations during the build process. ```bash make install prefix={target location} INSTALL_PREFIX={temp location} ``` -------------------------------- ### Registry Parameter Value Example Source: http://www.net-snmp.org/docs/README.win32.html Example of how command-line options are stored as ParamX values in the registry. ```text HKLM\SYSTEM\CurrentControlSet\Services\ Net-SNMP Trap Handler\Parameters\Param1 -Lf HKLM\SYSTEM\CurrentControlSet\Services\ Net-SNMP Trap Handler\Parameters\Param2 c:/usr/log/snmptrapd.log ``` -------------------------------- ### Install NetSNMP::OID module Source: http://www.net-snmp.org/docs/perl-OID-README.html Standard commands to build and install the Perl module from source. ```bash perl Makefile.PL make make test make install ``` -------------------------------- ### KeyChange Algorithm Implementation Example Source: http://www.net-snmp.org/docs/mibs/SNMP-USER-BASED-SM-MIB.txt Example logic for calculating the delta component using MD5 as the hash algorithm. ```pseudocode iterations = (lenOfDelta - 1)/16; /* integer division */ temp = keyOld; for (i = 0; i < iterations; i++) { temp = MD5 (temp || random); delta[i*16 .. (i*16)+15] = temp XOR keyNew[i*16 .. (i*16)+15]; } temp = MD5 (temp || random); delta[i*16 .. lenOfDelta-1] = temp XOR keyNew[i*16 .. lenOfDelta-1]; ``` -------------------------------- ### Detailed Compilation Steps Source: http://www.net-snmp.org/docs/INSTALL.html Comprehensive steps for compiling the package, including testing and installation. ```bash 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. When it completes it prints a short message (also available in configure-summary) indicating what functionality will be available when compiled. 2. If necessary, edit include/net-snmp/net-snmp-config.h (see above). 3. Type `make' to compile the package. 4. Type `make test' which runs a variety of tests to see what functionality has been incorporated and if it works. 5. Type `make install' to install the programs and any data files and documentation. ``` -------------------------------- ### Define Installed Software Table Structure Source: http://www.net-snmp.org/docs/mibs/HOST-RESOURCES-MIB.txt Conceptual table and entry definitions for software installed on the host. ```SMIv2 hrSWInstalledTable OBJECT-TYPE SYNTAX SEQUENCE OF HrSWInstalledEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "The (conceptual) table of software installed on this host." ::= { hrSWInstalled 3 } hrSWInstalledEntry OBJECT-TYPE SYNTAX HrSWInstalledEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "A (conceptual) entry for a piece of software installed on this host. As an example of how objects in this table are named, an instance of the hrSWInstalledName object might be named hrSWInstalledName.96" INDEX { hrSWInstalledIndex } ::= { hrSWInstalledTable 1 } HrSWInstalledEntry ::= SEQUENCE { hrSWInstalledIndex Integer32, hrSWInstalledName InternationalDisplayString, hrSWInstalledID ProductID, hrSWInstalledType INTEGER, hrSWInstalledDate DateAndTime } ``` -------------------------------- ### Install Net-SNMP Binary Package Source: http://www.net-snmp.org/docs/README.solaris.html Extract the downloaded tarball to the root directory to install binaries and libraries into /usr/local. ```bash cd / tar -xvf /usr/local/dist/net-snmp-5.0.9-SunOS_5.8_sun4u.tar ``` -------------------------------- ### Install MSYS2 Dependencies Source: http://www.net-snmp.org/docs/README.win32.html Commands to install necessary build tools and libraries for MinGW-w64 on MSYS2. ```shell pacman -S make diffutils ``` ```shell pacman -S mingw-w64-i686-gcc mingw-w64-i686-openssl ``` ```shell pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-openssl ``` -------------------------------- ### Generate SNMPv3 Keys Manually Source: http://www.net-snmp.org/docs/man/snmpd.conf.html Examples of using localized (-l) or master (-m) keys for SNMPv3 user creation. Note that these examples are for demonstration and should not be used in production. ```text [these keys are *not* secure but are easy to visually parse for counting purposes. Please generate random keys instead of using these examples] createUser myuser SHA -l 0x0001020304050607080900010203040506070809 AES -l 0x00010203040506070809000102030405 createUser myuser SHA -m 0x0001020304050607080900010203040506070809 AES -m 0x0001020304050607080900010203040506070809 ``` -------------------------------- ### Start and Query SNMP Daemons Source: http://www.net-snmp.org/docs/README.solaris.html Commands to start Solaris SNMP services and verify the sub-agent integration via snmpget. ```bash /etc/rc3.d/S76snmpdx start /etc/rc3.d/S77dmi start snmpget -v 1 -c whatever localhost sysDescr.0 snmpget -v 1 -c whatever localhost hrSystemUptime.0 ``` -------------------------------- ### Install Perl SNMP Modules from Source Source: http://www.net-snmp.org/docs/FAQ.html Standard procedure for building and installing the Perl SNMP module from the Net-SNMP source tree. ```bash cd perl perl Makefile.PL (press RETURN when prompted for host and community) make make test make install (probably as root) ``` -------------------------------- ### Start snmptrapd for Logging Source: http://www.net-snmp.org/docs/FAQ.html Commands to start the trap daemon for logging purposes. ```bash snmptrapd -Ls 7 ``` ```bash snmptrapd -f -Lo ``` -------------------------------- ### ifStackTable Relationship Example Source: http://www.net-snmp.org/docs/mibs/ifMIBObjects.html Example of how sub-layer relationships are represented in the ifStackTable. ```text ifStackStatus.x.y=active ``` ```text ifStackStatus.0.x=active ifStackStatus.x.0=active ``` -------------------------------- ### Install Custom Net-SNMP Binary Source: http://www.net-snmp.org/docs/README.solaris.html Extract a custom-built tarball on the target machine. ```bash cd / tar -xvf /usr/local/dist/net-snmp-5.4.custom-SunOS_5.8_sun4u.tar ``` -------------------------------- ### Configure Net-SNMP Build Source: http://www.net-snmp.org/docs/README.solaris.html Example command to generate the configuration script for the Net-SNMP build process. ```bash ./configure --with-mib-modules="ucd-snmp/lmSensors ucd-snmp/diskio \ smux mibII/mta_sendmail" --with-cc=gcc ``` -------------------------------- ### Configure Net-SNMP with Kerberos Support Source: http://www.net-snmp.org/docs/README.krb5.html Example ./configure command to enable the Kerberos Security Model with appropriate flags for libraries and headers. ```bash ./configure --with-cflags='-I/usr/krb5/include' \ --with-ldflags='-L/usr/krb5/lib -lkrb5 -lcrypto -lcom_err -R/usr/krb5/lib' ``` -------------------------------- ### Basic mib2c execution Source: http://www.net-snmp.org/docs/man/mib2c.conf.html Example command to run the mib2c utility with a specific configuration file. ```shell % mib2c -c mib2c.test.conf internet ``` -------------------------------- ### Run snmpconf with default settings Source: http://www.net-snmp.org/docs/man/snmpconf.html Starts the interactive configuration tool in its default mode. ```bash snmpconf ``` -------------------------------- ### Start snmpd with Windows extension exclusions Source: http://www.net-snmp.org/docs/README.win32.html Starts the Net-SNMP agent while excluding modules that overlap with default Windows extensions. ```bash snmpd.exe -I-udp,udpTable,tcp,tcpTable,icmp,ip,interfaces,snmp_mib,system_mib,sysORTable ``` -------------------------------- ### Start SNMP Daemon Source: http://www.net-snmp.org/docs/README.Panasonic_AM3X.txt.html Commands to navigate to the binary directory and execute the snmpd daemon. ```bash cd /usr/local/sbin ./snmpd ``` -------------------------------- ### Test SNMP Connectivity Source: http://www.net-snmp.org/docs/README.Panasonic_AM3X.txt.html Use snmpwalk to verify the installation by querying the local agent. ```bash snmpwalk -v 2c -m ALL -c public -t 100 localhost .1.3 > snmpwalk.txt more snmpwalk.txt ``` -------------------------------- ### Register Service with Logging Source: http://www.net-snmp.org/docs/README.win32.html Example of registering the trap daemon with specific logging options. ```shell snmptrapd -register -Lf c:/usr/log/snmptrapd.log ``` -------------------------------- ### Start and Test Net-SNMP Daemon Source: http://www.net-snmp.org/docs/README.solaris.html Launch the daemon and verify functionality using standard SNMP tools. ```bash /usr/local/sbin/snmpd snmpget -v 1 -c whatever localhost sysUpTime.0 snmpwalk -v 2c -c whatever -m ALL localhost .1.3 | more ``` -------------------------------- ### Log SNMP Delta Data to File Source: http://www.net-snmp.org/docs/man/snmpdelta.html Example demonstrating the use of multiple options including file logging with the -Cl flag. ```bash $ snmpdelta -c public -v 1 -Ct -Cs -CS -Cm -Cl -Cp 60 -CP 60 interlink.sw.net.cmu.edu .1.3.6.1.2.1.2.2.1.16.3 .1.3.6.1.2.1.2.2.1.16.4 fi ``` -------------------------------- ### Configure Access Control for Contexts Source: http://www.net-snmp.org/docs/FAQ.html Examples of access control lines for specific or all contexts within the configuration file. ```text access {group} "my_context" any noauth exact ...... ``` ```text access {group} "" any noauth prefix ...... ``` -------------------------------- ### Send Notification with Varbinds Source: http://www.net-snmp.org/docs/FAQ.html Example of sending a notification including additional varbind data. ```bash snmptrap -v 2c -c public localhost "" ucdStart sysContact.0 s "Dave" ``` -------------------------------- ### Manual Perl Module Build Source: http://www.net-snmp.org/docs/INSTALL.html Sequence of commands to build and install Perl modules manually after the main package is installed. ```bash cd perl perl Makefile.PL make make test make install (as root) ``` -------------------------------- ### Start and test the SNMP agent Source: http://www.net-snmp.org/docs/README.snmpv3.html Commands to launch the agent and verify authentication with and without privacy encryption. ```bash /usr/local/sbin/snmpd ``` ```bash snmpget -v 3 -u myuser -l authNoPriv -a MD5 -A my_password localhost sysUpTime.0 ``` ```bash snmpget -v 3 -u myuser -l authPriv -a MD5 -A my_password -x DES -X my_password localhost sysUpTime.0 ``` -------------------------------- ### Define Installed Software Tracking Objects Source: http://www.net-snmp.org/docs/mibs/HOST-RESOURCES-MIB.txt Definitions for tracking the last change and update times of the installed software table. ```SMIv2 hrSWInstalledLastChange OBJECT-TYPE SYNTAX TimeTicks MAX-ACCESS read-only STATUS current DESCRIPTION "The value of sysUpTime when an entry in the hrSWInstalledTable was last added, renamed, or deleted. Because this table is likely to contain many entries, polling of this object allows a management station to determine when re-downloading of the table might be useful." ::= { hrSWInstalled 1 } hrSWInstalledLastUpdateTime OBJECT-TYPE SYNTAX TimeTicks MAX-ACCESS read-only STATUS current DESCRIPTION "The value of sysUpTime when the hrSWInstalledTable was last completely updated. Because caching of this data will be a popular implementation strategy, retrieval of this object allows a management station to obtain a guarantee that no data in this table is older than the indicated time." ::= { hrSWInstalled 2 } ``` -------------------------------- ### Install RPM package ignoring dependencies Source: http://www.net-snmp.org/docs/FAQ.html Use this command to force an RPM installation when dependencies are met manually but not registered in the RPM database. ```bash rpm -i --nodeps {package} ``` -------------------------------- ### DisMan Schedule MIB Configuration Source: http://www.net-snmp.org/docs/man/snmpd.examples.html Examples for scheduling tasks using repeat, cron, or at intervals. ```text repeat 3600 versionUpdateConfig.0 = 1 ``` ```text cron 10 0 * * * versionUpdateConfig.0 = 1 ``` ```text at 13 13 13 * 5 snmpVirus.0 = 1 ``` -------------------------------- ### Install NetSNMP::TrapReceiver Source: http://www.net-snmp.org/docs/perl-TrapReceiver-README.html Commands to configure and build the module within the Net-SNMP source directory. ```bash ./configure --enable-embedded-perl make make install ``` -------------------------------- ### Test Perl Capabilities Source: http://www.net-snmp.org/docs/README.solaris.html Verify the Perl module integration after installation. ```bash /usr/local/bin/snmpwalk -v 2c -c whatever localhost .1.3.6.1.4.1.8072.999 ``` -------------------------------- ### View Help Documentation Source: http://www.net-snmp.org/docs/README.win32.html Access help information for the Configure script and nmake build targets. ```batch perl Configure --help ``` ```batch nmake help ``` -------------------------------- ### Monitor Disks with DISMAN-EVENT-MIB Source: http://www.net-snmp.org/docs/README.solaris.html Example configuration for monitoring disk space thresholds and triggering traps. ```text disk / 10% disk /usr6 90% ``` -------------------------------- ### Define netSnmpPassTable structure Source: http://www.net-snmp.org/docs/mibs/netSnmpPassExamples.html Example table and row definitions. ```text Example table ``` ```text Conceptual row in the example table. ``` -------------------------------- ### void init_scalar_int(void) Source: http://www.net-snmp.org/docs/man/netsnmp_example_scalar_int.html Initializes and registers the example scalar variables for SNMP access. ```APIDOC ## void init_scalar_int(void) ### Description Initializes the example scalar module, creating registrations that allow simple variables to be accessed and modified via SNMP. ### Parameters - None ### Usage Call this function during agent initialization to expose the example scalar variables. ``` -------------------------------- ### Install Perl SNMP Module via CPAN Source: http://www.net-snmp.org/docs/FAQ.html Alternative installation method using the CPAN shell. This method is less reliable and requires a compatible Net-SNMP library version. ```bash perl -MCPAN -e shell ; "install SNMP" ``` -------------------------------- ### SMUX Sub-Agent Configuration Source: http://www.net-snmp.org/docs/man/snmpd.examples.html Setup for SMUX protocol communication. ```text smuxsocket 127.0.0.1 smuxpeer .1.3.6.1.2.1.14 ospf_pass ``` -------------------------------- ### Retrieving and formatting ifTable Source: http://www.net-snmp.org/docs/man/snmptable.html Example of retrieving the ifTable with multiple formatting options including column width and index prepending. ```bash $ snmptable localhost -Cl -CB -Ci -OX -Cb -Cc 16 -Cw 64 ifTable SNMP table: ifTable Index Descr Type Mtu Speed PhysAddress AdminStatus OperStatus LastChange InOctets InUcastPkts InNUcastPkts InDiscards InErrors InUnknownProtos OutOctets OutUcastPkts OutNUcastPkts OutDiscards OutErrors OutQLen Specific index: [1] 1 lo softwareLoopbac 16436 10000000 up up ? 2837283786 3052466 ? 0 0 ? 2837283786 3052466 ? 0 0 0 zeroDotZero index: [2] 2 eth0 ethernetCsmacd 1500 10000000 0:5:5d:d1:f7:cf up up ? 2052604234 44252973 ? 0 0 ? 149778187 65897282 ? 0 0 0 zeroDotZero ``` -------------------------------- ### Example Usage of snmptest Source: http://www.net-snmp.org/docs/man/snmptest.html Demonstrates invoking snmptest and providing a variable to query. ```bash snmptest -c public -v 1 zeus **Variable:** system.sysDescr.0 **Variable:** ``` -------------------------------- ### Querying an SNMP table with custom formatting Source: http://www.net-snmp.org/docs/man/snmptable.html Example of using snmptable with specific flags to format the output for database import. ```bash $ snmptable -v 2c -c public -Cf + localhost at.atTable SNMP table: at.atTable atIfIndex+atPhysAddress+atNetAddress 1+8:0:20:20:0:ab+130.225.243.33 ``` -------------------------------- ### Start snmpd.exe with proxy support Source: http://www.net-snmp.org/docs/README.win32.html Command to launch the Net-SNMP agent with specific modules enabled for proxying to the Microsoft agent. ```bash snmpd.exe -Ivacm_conf,proxy,pass,pass_persist ``` -------------------------------- ### Run Windows Configure Help Source: http://www.net-snmp.org/docs/FAQ.html Displays help information for the Windows-specific configuration script. ```bash Configure --help ``` -------------------------------- ### Define Installed Software Entry Attributes Source: http://www.net-snmp.org/docs/mibs/HOST-RESOURCES-MIB.txt Individual object definitions for software index, name, ID, and type. ```SMIv2 hrSWInstalledIndex OBJECT-TYPE SYNTAX Integer32 (1..2147483647) MAX-ACCESS read-only STATUS current DESCRIPTION "A unique value for each piece of software installed on the host. This value shall be in the range from 1 to the number of pieces of software installed on the host." ::= { hrSWInstalledEntry 1 } hrSWInstalledName OBJECT-TYPE SYNTAX InternationalDisplayString (SIZE (0..64)) MAX-ACCESS read-only STATUS current DESCRIPTION "A textual description of this installed piece of software, including the manufacturer, revision, the name by which it is commonly known, and optionally, its serial number." ::= { hrSWInstalledEntry 2 } hrSWInstalledID OBJECT-TYPE SYNTAX ProductID MAX-ACCESS read-only STATUS current DESCRIPTION "The product ID of this installed piece of software." ::= { hrSWInstalledEntry 3 } hrSWInstalledType OBJECT-TYPE SYNTAX INTEGER { unknown(1), operatingSystem(2), deviceDriver(3), application(4) } MAX-ACCESS read-only STATUS current DESCRIPTION "The type of this software." ::= { hrSWInstalledEntry 4 } ``` -------------------------------- ### Configure and Build Script for AM33 Source: http://www.net-snmp.org/docs/README.Panasonic_AM3X.txt.html A shell script to generate Makefiles and install binaries for the AM33 architecture. ```bash # configure.am33 #-------------------------------------------------------------------------- ./configure --with-cc=am33_2.0-linux-gnu-gcc --host=i686-pc-linux-gnu \ --disable-dlopen --target=am33-linux --disable-dlclose --disable-dlerror \ --with-endianness=little --with-openssl=no --with-cflags="-g -mam33 -O2 -static" \ --oldincludedir=./usr/local --prefix=./usr/local --exec-prefix=./usr/local \ --with-persistent-directory=./usr/local make make install #-------------------------------------------------------------------------- ``` -------------------------------- ### Set OpenSSL Environment Variables Source: http://www.net-snmp.org/docs/README.win32.html Configure the INCLUDE and LIB environment variables to point to the OpenSSL installation directories before building. ```batch set INCLUDE=C:\OpenSSL-Win32\include set LIB=C:\OpenSSL-Win32\lib\VC\static ``` -------------------------------- ### Monitor Processes with DISMAN-EVENT-MIB Source: http://www.net-snmp.org/docs/README.solaris.html Example configuration for monitoring specific processes individually, as global monitors may fail on Solaris. ```text proc smail proc mdlogd monitor -r 30 -i -o prNames.1 -o prErrMessage.1 "Process smail" prErrorFlag.1 !=0 monitor -r 30 -i -o prNames.2 -o prErrMessage.2 "Process Solstice Disksuite SNMP trap" prErrorFlag.2 !=0 ``` -------------------------------- ### Initialize and Run an SNMP Agent Source: http://www.net-snmp.org/docs/man/snmp_agent_api.html Demonstrates the standard lifecycle of an SNMP agent, including initialization, role configuration, and the main processing loop. ```c #include #include #include int main (int argc, char *argv[]) { int agentx_subagent = 1; /* Change this if you're a master agent. */ snmp_enable_stderrlog(); /* If we're an AgentX subagent... */ if (agentx_subagent) { /* ...make us an AgentX client. */ netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1); } init_agent("yourappname"); /* Initialize your MIB code here. */ init_my_mib_code(); /* `yourappname' will be used to read yourappname.conf files. */ init_snmp("yourappname"); /* If we're going to be a SNMP master agent... */ if (!agentx_subagent) init_master_agent(); /* Listen on default port (161). */ /* Your main loop here... */ while (whatever) { /* if you use select(), see snmp_api(3) */ /* --- OR --- */ agent_check_and_process(0); /* 0 == don't block */ } /* At shutdown time: */ snmp_shutdown("yourappname"); } ``` -------------------------------- ### Group MIB Modules in Header Source: http://www.net-snmp.org/docs/FAQ.html Example of a header file used to aggregate multiple MIB modules for easier configuration. ```c config_require(mymib/myObjects) config_require(mymib/myTable) config_require(mymib/myOtherTable) ``` -------------------------------- ### smLaunchStart Definition Source: http://www.net-snmp.org/docs/mibs/scriptMIB.html Defines the mechanism for initiating script execution and the associated validation checks required for the operation. ```text 10 **smLaunchStart** | INTEGER32 Legal values: 0 .. 2147483647 | Create | ``` -------------------------------- ### Define Example Notifications and Payloads Source: http://www.net-snmp.org/docs/mibs/NET-SNMP-EXAMPLES-MIB.txt Defines objects and a notification type for heartbeat signaling examples. ```MIB netSnmpExampleHeartbeatRate OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS accessible-for-notify STATUS current DESCRIPTION "A simple integer object, to act as a payload for the netSnmpExampleHeartbeatNotification. The value has no real meaning, but is nominally the interval (in seconds) between successive heartbeat notifications." ::= { netSnmpExampleNotificationObjects 1 } netSnmpExampleHeartbeatName OBJECT-TYPE SYNTAX SnmpAdminString MAX-ACCESS accessible-for-notify STATUS current DESCRIPTION "A simple string object, to act as an optional payload for the netSnmpExampleHeartbeatNotification. This varbind is not part of the notification definition, so is optional and need not be included in the notification payload. The value has no real meaning, but the romantically inclined may take it to be the object of the sender's affection, and hence the cause of the heart beating faster." ::= { netSnmpExampleNotificationObjects 2 } netSnmpExampleHeartbeatNotification NOTIFICATION-TYPE OBJECTS { netSnmpExampleHeartbeatRate } STATUS current DESCRIPTION "An example notification, used to illustrate the definition and generation of trap and inform PDUs (including the use of both standard and additional varbinds in the notification payload). This notification will typically be sent every 30 seconds, using the code found in the example module agent/mibgroup/examples/notification.c" ::= { netSnmpExampleNotificationPrefix 1 } netSnmpExampleNotification OBJECT-TYPE SYNTAX SnmpAdminString MAX-ACCESS accessible-for-notify STATUS obsolete DESCRIPTION "This object was improperly defined for its original purpose, and should no longer be used." ::= { netSnmpExampleNotifications 1 } END ``` -------------------------------- ### Walk the Enterprise Subtree Source: http://www.net-snmp.org/docs/FAQ.html Use this command to walk a specific enterprise subtree by specifying the root as the starting point. ```bash snmpwalk -v1 -c public localhost UCD-SNMP-MIB::ucdavis ``` -------------------------------- ### Send a generic linkUp trap Source: http://www.net-snmp.org/docs/man/snmptrap.html Example command to send a linkUp trap to a manager for a specific interface. ```bash snmptrap -v 1 -c public manager enterprises.spider test-hub 3 0 '' interfaces.iftable.ifentry.ifindex.1 i 1 ``` -------------------------------- ### Configure Net-SNMP Build Source: http://www.net-snmp.org/docs/README.win32.html Generate make files using the Configure script with specific flags for SDK, SSL, debug mode, and installation path. ```perl perl Configure --with-sdk --with-ssl --config=debug --prefix="c:/usr" ``` ```perl perl Configure --with-sdk --with-ssl --config=debug --linktype=dynamic\ --prefix="c:/usr" ``` -------------------------------- ### Send SNMP GET request Source: http://www.net-snmp.org/docs/man/snmptest.html Demonstrates sending a GET request for specific OIDs using snmptest. ```text Variable: system.sysDescr.0 Variable: system.sysContact.0 Variable: Received Get Response from 128.2.56.220 requestid 0x7D9FCD63 errstat 0x0 errindex 0x0 SNMPv2-MIB::sysDescr.0 = STRING: SunOS testhost 5.9 Generic_112233-02 sun4u SNMPv2-MIB::sysContact.0 = STRING: x1111 ``` -------------------------------- ### void netsnmp_init_mib (void) Source: http://www.net-snmp.org/docs/man/netsnmp_mib_utilities.html Initializes the MIB reader and reads all settings from the environment. ```APIDOC ## void netsnmp_init_mib (void) ### Description Initialises the mib reader. Library API routines concerned with MIB files and objects, and OIDs. Reads in all settings from the environment. ``` -------------------------------- ### Configure Net-SNMP Perl Module on Windows Source: http://www.net-snmp.org/docs/perl-SNMP-README.html Initial configuration command for building the Perl module against an installed Net-SNMP path. ```shell perl Makefile.PL CAPI=TRUE -NET-SNMP-PATH="c:\usr" ``` -------------------------------- ### Configure snmptrapd output format Source: http://www.net-snmp.org/docs/man/snmptrapd.html Examples demonstrating how to use the -F flag to define custom output formats for snmptrapd. ```bash snmptrapd -P -F "%02.2h:%02.2j TRAP%w.%q from %A\n" ``` ```bash snmptrapd -P -F "%#02.2h:%#02.2j TRAP%w.%q from %A\n" ``` -------------------------------- ### Performing SNMP GET Operations Source: http://www.net-snmp.org/docs/perl-SNMP-README.html Retrieves values using SNMP GET, supporting both synchronous and asynchronous modes. ```perl get([,]) ``` -------------------------------- ### Retrieve disk usage with snmpdf Source: http://www.net-snmp.org/docs/man/snmpdf.html Example command to query disk usage statistics from a local SNMP agent using SNMPv2c. ```bash snmpdf -v 2c -c public localhost ``` -------------------------------- ### Win32 Build Error Reference Source: http://www.net-snmp.org/docs/CHANGES.html Example of a build error encountered in winExtDLL.c due to an implicit function declaration. ```c mibgroup/winExtDLL.c:360:14: error: implicit declaration of function 'should_init' [-Wimplicit-function-declaration] 360 | if (!should_init(dll_basename)) { | ^~~~~~~~~~~ ``` -------------------------------- ### Create an initial SNMPv3 user Source: http://www.net-snmp.org/docs/README.snmpv3.html Use the net-snmp-config utility to generate a new user with read/write access. ```bash net-snmp-config --create-snmpv3-user -a "my_password" myuser ``` -------------------------------- ### Define smLaunchTable and smLaunchEntry Source: http://www.net-snmp.org/docs/mibs/DISMAN-SCRIPT-MIB.txt Defines the table structure and entry index for script launch configurations. ```mib smLaunchTable OBJECT-TYPE SYNTAX SEQUENCE OF SmLaunchEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "This table lists and describes scripts that are ready to be executed together with their parameters." ::= { smRunObjects 1 } smLaunchEntry OBJECT-TYPE SYNTAX SmLaunchEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "An entry describing a particular executable script." INDEX { smLaunchOwner, smLaunchName } ::= { smLaunchTable 1 } ``` -------------------------------- ### init_agent Source: http://www.net-snmp.org/docs/man/netsnmp_library.html Initializes the agent and sets the application's configuration file in the default storage space. ```APIDOC ## int init_agent (const char * app) ### Description Initializes the agent. Calls into init_agent_read_config to set the app's configuration file in the appropriate default storage space (NETSNMP_DS_LIB_APPTYPE). This must be called before calling init_snmp. ### Parameters - **app** (const char *) - Required - The configuration file to be read in. ### Returns - **int** - Returns non-zero on failure and zero on success. ``` -------------------------------- ### Manually Initialize Loader Configuration Source: http://www.net-snmp.org/docs/README.solaris.html Create the necessary directory structure and configuration file if crle fails. ```bash mkdir /var/ld cd /var/ld ln -s . 32 mkdir sparcv9 chgrp bin sparcv9 ln -s sparcv9 64 touch ld.config crle -c /var/ld/ld.config -l /usr/lib:/usr/local/ssl/lib ``` -------------------------------- ### Install Perl Tk module via CPAN Source: http://www.net-snmp.org/docs/FAQ.html Use this command to install the required Tk Perl package for tkmib functionality. ```bash perl -MCPAN -e shell ; "install Tk" ``` -------------------------------- ### Performing Formatted SNMP GET Operations Source: http://www.net-snmp.org/docs/perl-SNMP-README.html Retrieves values using SNMP GET and formats them based on session handlers. Asynchronous operation is not supported. ```perl fget([,]) ``` -------------------------------- ### init_snmp(char *name) Source: http://www.net-snmp.org/docs/man/snmp_agent_api.html Initializes the SNMP library and reads configuration files based on the provided application name. ```APIDOC ## init_snmp(char *name) ### Description Initializes the SNMP library and reads configuration files (e.g., snmpd.conf) to configure the application. ### Parameters - **name** (char*) - Required - The application name used to identify configuration files. ``` -------------------------------- ### Define netSnmpPassGauge scalar Source: http://www.net-snmp.org/docs/mibs/netSnmpPassExamples.html Example Gauge object. ```text Example Gauge object. ``` -------------------------------- ### Define netSnmpPassTimeTicks scalar Source: http://www.net-snmp.org/docs/mibs/netSnmpPassExamples.html Example timetick object. ```text Example timetick object. ``` -------------------------------- ### Verify Build Configuration Source: http://www.net-snmp.org/docs/README.solaris.html Check the configuration script for large file support flags. ```bash grep cppsymbols config.sh ``` -------------------------------- ### Define netSnmpPassOID column Source: http://www.net-snmp.org/docs/mibs/netSnmpPassExamples.html Example OID (table) object. ```text Example OID (table) object. ``` -------------------------------- ### Define netSnmpPassInteger column Source: http://www.net-snmp.org/docs/mibs/netSnmpPassExamples.html Example Integer (table) object. ```text Example Integer (table) object. ``` -------------------------------- ### Define netSnmpPassIpAddress scalar Source: http://www.net-snmp.org/docs/mibs/netSnmpPassExamples.html Example IP Address object. ```text Example IP Address object. ``` -------------------------------- ### Utility and inclusion commands Source: http://www.net-snmp.org/docs/man/mib2c.conf.html Commands for printing output and sourcing additional configuration files. ```text @printf expression stuff1, stuff2, ...@ @run FILE@ @include FILE@ ``` -------------------------------- ### Define netSnmpPassString scalar Source: http://www.net-snmp.org/docs/mibs/netSnmpPassExamples.html Example string scalar object. ```text Example string scalar object. ``` -------------------------------- ### Notification: ucdStart Source: http://www.net-snmp.org/docs/mibs/ucdavis.html This notification is sent when the SNMP agent starts. ```APIDOC ## Notification: ucdStart ### Description This trap is sent when the agent starts. ### OID .1.3.6.1.4.1.2021.251.1 ``` -------------------------------- ### netsnmp_baby_steps_handler_init Source: http://www.net-snmp.org/docs/man/netsnmp_baby_steps.html Initializes the baby_steps helper and registers it for run-time use. ```APIDOC ## netsnmp_baby_steps_handler_init ### Description Initializes the baby_steps helper which then registers a baby_steps handler as a run-time injectable handler for configuration file use. ### Signature void netsnmp_baby_steps_handler_init (void) ``` -------------------------------- ### Define netSnmpPassCounter scalar Source: http://www.net-snmp.org/docs/mibs/netSnmpPassExamples.html Example counter object that always returns 42. ```text Example counter object. Note that this object will always return the value '42'. ``` -------------------------------- ### netsnmp_init_bulk_to_next_helper Source: http://www.net-snmp.org/docs/man/netsnmp_bulk_to_next.html Initializes the bulk_to_next helper which then registers a bulk_to_next handler as a run-time injectable handler for configuration file use. ```APIDOC ## void netsnmp_init_bulk_to_next_helper (void) ### Description Initializes the bulk_to_next helper which then registers a bulk_to_next handler as a run-time injectable handler for configuration file use. ``` -------------------------------- ### Initialize custom MIB module in Visual Studio Source: http://www.net-snmp.org/docs/README.win32.html Add the initialization call to the mib_module_inits.h file. ```c if (should_init("my")) init_my(); ``` -------------------------------- ### Define ucdStart Notification Description Source: http://www.net-snmp.org/docs/mibs/ucdavis.html Describes the trap sent when the agent starts. ```text This trap could in principle be sent when the agent start ``` -------------------------------- ### Define UCD-SNMP Agent Traps Source: http://www.net-snmp.org/docs/mibs/UCD-SNMP-MIB.txt Definitions for agent start and shutdown notifications. ```MIB ucdStart NOTIFICATION-TYPE STATUS current DESCRIPTION "This trap could in principle be sent when the agent start" ::= { ucdTraps 1 } ucdShutdown NOTIFICATION-TYPE STATUS current DESCRIPTION "This trap is sent when the agent terminates" ::= { ucdTraps 2 } ``` -------------------------------- ### Define smRunArgument Source: http://www.net-snmp.org/docs/mibs/DISMAN-SCRIPT-MIB.txt Defines the argument supplied to the script at start time. ```SNMP MIB smRunArgument OBJECT-TYPE SYNTAX OCTET STRING MAX-ACCESS read-only STATUS current DESCRIPTION "The argument supplied to the script when it started." DEFVAL { ''H } ::= { smRunEntry 2 } ``` -------------------------------- ### Manage Windows Services Source: http://www.net-snmp.org/docs/README.win32.html Commands to start and stop the registered Net-SNMP services. ```shell net start "Net-SNMP Agent" net start "Net-SNMP Trap Handler" ``` ```shell net stop "Net-SNMP Agent" net stop "Net-SNMP Trap Handler" ``` -------------------------------- ### Definition and macro commands Source: http://www.net-snmp.org/docs/man/mib2c.conf.html Commands for defining and calling reusable blocks of configuration code. ```text @define NAME@ @enddefine@ @calldefine NAME@ ``` -------------------------------- ### init_snmp Source: http://www.net-snmp.org/docs/man/netsnmp_library.html Initializes the SNMP library by loading configuration files and parsing MIB modules. ```APIDOC ## void init_snmp (const char * type) ### Description Calls the functions to do config file loading and MIB module parsing in the correct order. ### Parameters - **type** (const char *) - Required - Label for the config file 'type'. ``` -------------------------------- ### Define Deprecated IP-MIB Objects Source: http://www.net-snmp.org/docs/mibs/IP-MIB.txt Example of an object definition marked as deprecated. ```SNMP MIB ipInReceives OBJECT-TYPE SYNTAX Counter32 MAX-ACCESS read-only STATUS deprecated DESCRIPTION "The total number of input datagrams received from interfaces, including those received in error. ``` -------------------------------- ### Manual Build Configuration for Windows Source: http://www.net-snmp.org/docs/perl-SNMP-README.html Manual compilation commands for Windows using MSVC++, supporting both release and debug versions. ```cmd perl Makefile.PL CAPI=TRUE -NET-SNMP-IN-SOURCE=TRUE perl Makefile.PL CAPI=TRUE -NET-SNMP-IN-SOURCE=TRUE -NET-SNMP-DEBUG=TRUE nmake nmake test nmake install ``` -------------------------------- ### Modify tester program status Source: http://www.net-snmp.org/docs/README.solaris.html Example of modifying the script variable to trigger a trap. ```bash xstatus=1 ``` -------------------------------- ### Auto-comment an existing configuration file Source: http://www.net-snmp.org/docs/man/snmpconf.html Reads a specific configuration file and writes it back with added comments describing each token. ```bash snmpconf -R /usr/local/snmp/snmpd.conf -a -f snmpd.conf ``` -------------------------------- ### Traditional SNMP API Usage Source: http://www.net-snmp.org/docs/README.thread.html Demonstrates session initialization, opening, and error handling using the traditional API structure. ```c #include "snmp_api.h" ... int liberr, syserr; char *errstr; struct snmp_session Session, *sptr; ... snmp_sess_init(&Session); Session.peername = "foo.bar.net"; sptr = snmp_open(&Session); if (sptr == NULL) { /* Error codes found in open calling argument */ snmp_error(&Session, &liberr, &syserr, &errstr); printf("SNMP create error %s.\n", errstr); free(errstr); return 0; } /* Pass sptr to snmp_error from here forward */ ... /* Change the community name */ free(sptr->community); sptr->community = strdup("public"); sptr->community_len = strlen("public"); ... if (0 == snmp_send(sptr, pdu)) { snmp_error(sptr, &liberr, &syserr, &errstr); printf("SNMP write error %s.\n", errstr); free(errstr); return 0; } snmp_close(sptr); ``` -------------------------------- ### SNMP::initMib Source: http://www.net-snmp.org/docs/perl-SNMP-README.html Initializes the MIB library if not already loaded. ```APIDOC ## &SNMP::initMib() ### Description Calls the library netsnmp_init_mib function if the MIB is not already loaded. It parses directories and loads modules according to environment variables (MIBDIRS, MIBS, MIBFILES). ``` -------------------------------- ### Initialization and Lifecycle Source: http://www.net-snmp.org/docs/man/mib_api.html Functions to initialize, configure, and shut down the MIB subsystem. ```APIDOC void init_mib(void); int add_mibdir(const char *dirname); void init_mib_internals(void); void shutdown_mib(void); ``` -------------------------------- ### DisMan Event MIB Setup Source: http://www.net-snmp.org/docs/man/snmpd.examples.html Configure DisMan monitoring credentials and default monitors. ```snmpd.conf # Set up the credentials to retrieve monitored values createUser _internal MD5 "the first sign of madness" iquerySecName _internal rouser _internal # Active the standard monitoring entries defaultMonitors yes linkUpDownNotifications yes # If there's a problem, then tell someone! trap2sink localhost ``` ```snmpd.conf monitor -u me -o hrSWRunName "high process memory" hrSWRunPerfMem > 10000 ``` ```snmpd.conf monitor -D -r 10 "network traffic" ifInOctets 1000000 5000000 ``` ```snmpd.conf monitor -r 10 "network traffic" ifInOctets - - 1000000 5000000 ``` ```snmpd.conf notificationEvent linkUpTrap linkUp ifIndex ifAdminStatus ifOperStatus notificationEvent linkDownTrap linkDown ifIndex ifAdminStatus ifOperStatus monitor -r 60 -e linkUpTrap "Generate linkUp" ifOperStatus != 2 monitor -r 60 -e linkDownTrap "Generate linkDown" ifOperStatus == 2 ``` ```snmpd.conf monitor -o prNames -o prErrMessage "procTable" prErrorFlag != 0 monitor -o memErrorName -o memSwapErrorMsg "memory" memSwapError != 0 monitor -o extNames -o extOutput "extTable" extResult != 0 monitor -o dskPath -o dskErrorMsg "dskTable" dskErrorFlag != 0 monitor -o laNames -o laErrMessage "laTable" laErrorFlag != 0 monitor -o fileName -o fileErrorMsg "fileTable" fileErrorFlag != 0 ``` ```snmpd.conf setEvent prFixIt prErrFix = 1 monitor -e prFixIt "procTable" prErrorFlag != 0 ``` -------------------------------- ### Display mib2c configuration options Source: http://www.net-snmp.org/docs/man/mib2c.html Run mib2c without a configuration file to list available options for MIBNODE. ```bash mib2c ifTable ``` -------------------------------- ### Configure Net-SNMP for MinGW Source: http://www.net-snmp.org/docs/README.win32.html Set the base directory and run the configure script with specific flags. ```bash BASEDIR=c:/usr ./configure --prefix="$BASEDIR" \ --with-mibdirs="$BASEDIR/share/snmp/mibs" \ --with-mib-modules="agentx disman/event-mib winExtDLL examples/example"\ --disable-embedded-perl --without-perl-modules \ ``` -------------------------------- ### Locate OpenSSL Libraries Source: http://www.net-snmp.org/docs/README.solaris.html Find the path to libcrypto files on the system. ```bash find /usr -name "libcrypto*" -print ``` -------------------------------- ### Define bufferControlDownloadOffset object Source: http://www.net-snmp.org/docs/mibs/RMON-MIB.txt Specifies the starting offset for packet data returned during SNMP retrieval. ```mib bufferControlDownloadOffset OBJECT-TYPE SYNTAX Integer32 UNITS "Octets" MAX-ACCESS read-create STATUS current DESCRIPTION "The offset of the first octet of each packet in this capture buffer that will be returned in an SNMP retrieval of that packet. For example, if 500 octets of a packet have been stored in the associated capture buffer and this object is set to 100, then the captureBufferPacket object that contains the packet will contain bytes starting 100 octets into the packet." DEFVAL { 0 } ::= { bufferControlEntry 7 } ``` -------------------------------- ### init_mib Source: http://www.net-snmp.org/docs/man/mib_api.html Convenience function to initialize the MIB framework. ```APIDOC ## void init_mib(void) ### Description Configures the MIB directory search path, sets up internal MIB structures, and loads appropriate MIB modules. Should be called before any other routine that manipulates or accesses the MIB tree. ``` -------------------------------- ### Define ifTestType Source: http://www.net-snmp.org/docs/mibs/ifMIBObjects.html Control variable for starting and stopping interface tests, including the noTest identifier. ```text A control variable used to start and stop operator- initiated interface tests. Most OBJECT IDENTIFIER values assigned to tests are defined elsewhere, in association with specific types of interface. However, this document assigns a value for a full-duplex loopback test, and defines the special meanings of the subject identifier: noTest OBJECT IDENTIFIER ::= { 0 0 } When the value noTest is written to this object, no action is taken unless a test is in progress, in which case the test is aborted. Writing any other value to this object is only valid when no test is currently in progress, in which case the indicated test is initiated. When read, this object always returns the most recent value that ifTestType was set to. If it has not been set since the last initialization of the network management subsystem on the agent, a value of noTest is returned. ``` -------------------------------- ### Basic SNMP Get Request Source: http://www.net-snmp.org/docs/man/snmpcmd.html Standard execution of an snmpget command to retrieve system uptime. ```bash $ snmpget -c public -v 1 localhost sysUpTime.0 SNMPv2-MIB::sysUpTime.0 = Timeticks: (14096763) 1 day, 15:09:27.63 ``` -------------------------------- ### Define hrSWInstalledGroup in SMIv2 Source: http://www.net-snmp.org/docs/mibs/HOST-RESOURCES-MIB.txt Defines the hrSWInstalledGroup object group containing installed software monitoring objects. ```mib hrSWInstalledGroup OBJECT-GROUP OBJECTS { hrSWInstalledLastChange, hrSWInstalledLastUpdateTime, hrSWInstalledIndex, hrSWInstalledName, hrSWInstalledID, hrSWInstalledType, hrSWInstalledDate } STATUS current DESCRIPTION "The Host Resources Installed Software Group." ::= { hrMIBGroups 6 } ``` -------------------------------- ### Configure default SNMPv3 settings Source: http://www.net-snmp.org/docs/README.snmpv3.html Store authentication credentials in the user's local configuration file to simplify command-line usage. ```text defSecurityName wes defContext "" defAuthType MD5 defSecurityLevel authNoPriv defAuthPassphrase new_passphrase defVersion 3 ``` ```bash snmpget localhost sysUpTime.0 ``` -------------------------------- ### Retrieve the next SNMP variable Source: http://www.net-snmp.org/docs/man/snmpgetnext.html Example usage of snmpgetnext to fetch the variable following the specified OID. ```bash snmpgetnext -c public zeus interfaces.ifTable.ifEntry.ifType.1 ```