tclnetsnmp 4.1

The tclnetsnmp is TCL package based on Net-SNMP to inquity snmp agents. Routines are similar to Net-SNMP utilities (snmpget, snmpset, snmpwalk, ...). tclnetsnmp(n) LOCAL tclnetsnmp(n) NAME netsnmp::session, netsnmp::session.peername, netsnmp::session.timeout, netsnmp::get, netsnmp::bulkget, netsnmp::walk, netsnmp::bulkwalk, netsnmp::bulkwalk_ex, netsnmp::set, netsnmp::add_mibdir, netsnmp::read_module, netsnmp::read_mib, netsnmp::read_all_mibs, netsnmp::oid, netsnmp::name – the tcl procedures based on a netsnmp package for work with snmp devices. SYNOPSIS package require tclnetsnmp 4.1 netsnmp::session [-version snmpVersion] [-community snmpCommunity] [-timeout timeout] [-] addr netsnmp::session.peername $sess netsnmp::session.timeout $sess [timeout] netsnmp::get $sess oidlst netsnmp::bulkget $sess [-non-repeaters|-n non_repeaters] [-max-repetitions|-r max_repetitions] [-] oidlst netsnmp::walk $sess oid netsnmp::bulkwalk $sess [-non-repeaters|-n non_repeaters] [-max-repetitions|-r max_repetitions] [-] oidlst netsnmp::bulkwalk_ex $sess [-non-repeaters|-n non_repeaters] [-max-repetitions|-r max_repetitions] [-] oidlst netsnmp::set $sess oid type value [oid type value ...] netsnmp::add_mibdir mib_directory netsnmp::read_module moduleName netsnmp::read_mib filename netsnmp::read_all_mibs netsnmp::oid oid netsnmp::name oid DESCRIPTION netsnmp::session [-version snmpVersion] [-community snmpCommunity] [-timeout timeout] [-] addr Create and return snmp session variable. netsnmp::session.peername $sess The function returns peername of snmp session. netsnmp::session.timeout $sess [timeout] Returns a timeout of snmp session or sets it. netsnmp::get $sess oidlst The function uses the SNMP GET request to query for information on a network entity. netsnmp::bulkget $sess [-non-repeaters|-n non_repeaters] [-max-repetitions|-r max_repetitions] [-] oidlst The function uses the SNMP GETBULK request to query a network entity efficiently for information. netsnmp::walk $sess oid The netsnmp::walk is routine that uses SNMP GETNEXT requests to query a network entity for a tree of information. All variables in the subtree below the given OID are queried and their values pre- sented to the user. netsnmp::bulkwalk $sess [-non-repeaters|-n non_repeaters] [-max-repetitions|-r max_repetitions] [-] oidlst1 netsnmp::bulkwalk_ex $sess [-non-repeaters|-n non_repeaters] [-max-repetitions|-r max_repetitions] [-] oidlstN The netsnmp::bulkwalk is routine that uses SNMP GETBULK requests to query a network entity efficiently for a tree of information. netsnmp::set $sess oid type value [oid type value ...] The netsnmp::set is an function that uses the SNMP SET request to set information on a network entity. One or more object identifiers ( oid ) must be given as arguments on the command line. A type and a value to be set must accompany each object identifier. The type is a single character, one of: i INTEGER u UNSIGNED s STRING x HEX STRING d DECIMAL STRING n NULLOBJ o OBJID t TIMETICKS a IPADDRESS b BITS Most of these will use the obvious corresponding ASN.1 type. `s', `x', `d' and `b' are all different ways of specifying an OCTET STRING value, and the `u' unsigned type is also used for handling Gauge32 values. If you have the proper MIB file loaded, you can, in most cases, replace the type with an `=' sign. For an object of type OCTET STRING this will assume a string like the `s' type notation. For other types it will do "The Right Thing". netsnmp::add_mibdir dirname netsnmp::add_mibdir is used to add the specified directory to the path of locations which are searched for files containing MIB mod- ules. Note that this does not actually load the MIB modules located in that directory, but is simply an initialisation step to make them available to netsnmp::read_module. netsnmp::read_module name netsnmp::read_mib filename netsnmp::read_module takes the name of a MIB module (which need not be the same as the name of the file that contains the module), locates this within the configured list of MIB directories, and loads the definitions from the module into the active MIB tree. It also loads any MIB modules listed in the IMPORTS clause of this module. netsnmp::oid oid netsnmp::oid takes a string containing a textual version of an object identifier (in either numeric or descriptor form), and trans- forms this into the corresponding list of sub-identifiers. netsnmp::name oid netsnmp::name is similar, but return descriptor form of oid. EXAMPLES package require Tcl 8.6 package require tclnetsnmp 4.1 set sd [netsnmp::session [lindex $argv 0]] set rd [netsnmp::bulkwalk_ex $sd [list IF-MIB::ifName IF-MIB::ifAlias]] netsnmp_dump_result $rd rd unset sd EXAMPLES package require Tcl 8.6 package require tclnetsnmp 4.1 dict for {indexAsOIDLst data} \ [netsnmp::bulkwalk_ex [netsnmp::session [lindex $argv 0]] \ [list IF-MIB::ifName IF-MIB::ifAlias]] \ { puts "\[[llength $indexAsOIDLst]] $indexAsOIDLst := $data" } NOTES SEE ALSO tclnetsnmp(n) FreeBSD 11.1 January 28, 2019 FreeBSD 11.1 Tcl8.6 patches /usr/ports/lang/tcl86/files: patch-generic-tclInt.h patch-generic-tclObj.c My FreeBSD's /etc/make.conf: OPTIONS_SET= OPENSSL OPTIONS_UNSET= CUPS IPV6 NLS HAL AVAHI DBUS GNOME GNOMEVFS GCONF FAM GSTREAMER KDE4 QT4 GNUTLS .if ${.CURDIR:M${WRKDIRPREFIX}/usr/ports/lang/tcl86/*} EXTRA_CFLAGS= -UUSE_THREAD_ALLOC -UUSE_TCLALLOC -UTCL_MEM_DEBUG #EXTRA_CFLAGS+= -DTCL_THREAD_STACK_MIN=33554432L .endif Sources: tclnetsnmp-4.1-freebsd.tar.gz foo-libs-20191212-freebsd.tar.gz MIBs: mibs-20190511.tar.bz2 swpfoo _at_ mail.ru