107.1. net-snmp-5.9.5.2
SNMP library, tools and agent — read network UPS cards, switches and printers (snmpget, snmpwalk, snmpd)
| Version | 5.9.5.2, release 1 |
| Shelf | net-diag — Network diagnostics, capture, measurement and low-level socket tools |
| Phase | 41_system (System), 670 of 1047 in build order |
| Licence | Net-SNMP |
| Homepage | https://www.net-snmp.org/ |
| Build time | 3.6 SBU |
| Installed size | 6.4 MiB in 430 files |
| Recipe | ports/core/net-diag/net-snmp/kpkgbuild |
About
Net-SNMP is the SNMP toolkit: the libnetsnmp library, the command-line tools (snmpget, snmpwalk, snmpset, snmptrap and the rest), the agent snmpd, the trap receiver snmptrapd, and the MIB files. On KDOS it is how a network UPS card, a managed switch or a printer is read; nut’s SNMP driver, hplip and powerman link the library.
Sources
net-snmp-5.9.5.2.tar.gz(6.5 MiB)
sha25616707719f833184a4b72835dac359ae188123b06b5e42817c00790d7dc1384bf
upstream: https://downloads.sourceforge.net/net-snmp/net-snmp-5.9.5.2.tar.gz
archive copy: sources-3/net-diag--net-snmp-5.9.5.2.tar.gz
Dependencies
Depends on: pkgconf, openssl, libnl, pciutils, libpcap.
Required by (3): hplip, nut, powerman.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
--without-pcre, line 29: pcre2 (explained with the switches below)--without-elf, line 31: elfutils (explained with the switches below)
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install net-snmp'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/net-diag/net-snmp.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/net-diag/net-snmp
echo '16707719f833184a4b72835dac359ae188123b06b5e42817c00790d7dc1384bf net-snmp-5.9.5.2.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/net-snmp
SRC=$SRC_ROOT/net-snmp-5.9.5.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf net-snmp-5.9.5.2.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
LDFLAGS= ./configure \
--prefix=/usr \
--libdir=/usr/lib \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--disable-static \
--enable-shared \
--with-defaults \
--with-default-snmp-version=3 \
--with-sys-contact=root@localhost \
--with-sys-location=unknown \
--with-logfile=/var/log/snmpd.log \
--with-persistent-directory=/var/lib/net-snmp \
--with-openssl \
--enable-blumenthal-aes \
--enable-ipv6 \
--with-nl \
--without-pcre \
--without-rpm \
--without-elf \
--without-mysql \
--without-libwrap \
--without-systemd \
--without-perl-modules \
--disable-embedded-perl \
--without-python-modules \
--disable-scripts
grep -q '^#define HAVE_LIBCRYPTO 1' include/net-snmp/net-snmp-config.h
grep -q '^#define HAVE_LIBNL3 1' include/net-snmp/net-snmp-config.h
make LDFLAGS="$LDFLAGS"
make -j1 LDFLAGS="$LDFLAGS" DESTDIR=$PKG install
install -d -m 700 "$PKG/var/lib/net-snmp"
install -d "$PKG/etc/init.d"
cat > "$PKG/etc/init.d/71_snmpd.sh" <<'KDOS_SH'
#!/bin/bash
. /etc/init.d/service_helper
NAME="snmpd"
DAEMON="/usr/sbin/snmpd"
CONF="/etc/snmp/snmpd.conf"
case "$1" in
start)
[ ! -x "$DAEMON" ] && { echo "[SKIP] $NAME: $DAEMON not found"; exit 0; }
[ -s "$CONF" ] || { echo "[SKIP] $NAME: no $CONF"; exit 0; }
echo "[KDOS] Starting $NAME..."
supervise "$NAME" "$DAEMON" -f -Lsd
;;
stop) stop_service "$NAME" ;;
status) check_status "$NAME" ;;
*) echo "Usage: $0 {start|stop|status}"; exit 1 ;;
esac
KDOS_SH
chmod 755 "$PKG/etc/init.d/71_snmpd.sh"
The switches, and why each is set:
LDFLAGS=— Run configure with an emptyLDFLAGS, and pass the tree’s flags to bothmakecalls instead. The configure script writes itsLDFLAGSintonet-snmp-config --ldflagsand--libsand into theLibs.privatelines ofnetsnmp.pcandnetsnmp-agent.pc, so a program built against the installed library would inherit the tree’s linker flags; given tomake, they apply to this build alone.--with-defaults— Take the default for every value configure would otherwise prompt for at the terminal, which an unattended build cannot answer. The prompted values the recipe does set are given beside it:--with-default-snmp-version=3,--with-sys-contact=root@localhost,--with-sys-location=unknown,--with-logfile=/var/log/snmpd.logand--with-persistent-directory=/var/lib/net-snmp.--with-openssl— Do the USM authentication and encryption of SNMPv3 with OpenSSL’s libcrypto.--enable-blumenthal-aes— Offer AES-192 and AES-256 privacy as well as AES-128, following the Blumenthal draft.--enable-ipv6— Build the IPv6 transports.--with-nl— Build the netlink code that depends on libnl. Of the default MIB modules, IP-MIB’sipDefaultRouterTableis read from the kernel’s routing table this way; without libnl,snmpdanswers that table empty.--without-pcre— Build without PCRE.snmpd.conf’sprocdirective then takes no regular expression, and the interface and filesystem filters fall back to the C library’s POSIXregex.h. The configure script looks for PCRE1’spcre.h, which is not a port; pcre2 installspcre2.h, which Net-SNMP does not use.--without-elf— Link no libelf. On Linux configure’s ELF check does nothing anyway: Linux is among the hosts that do not usenlist(), the one thing it would link libelf for.--without-rpm— With--without-mysql,--without-libwrapand--without-systemd, build no RPM package table in the host MIB, no MySQL trap storage, no TCP wrappers and no systemd notification. None of those is a port, and KDOS has no systemd; see No systemd.--without-perl-modules— With--disable-embedded-perl,--without-python-modulesand--disable-scripts, build no Perl or Python binding, no Perl interpreter insidesnmpd, and none of the Perl scripts (mib2c,snmpconf,tkmiband others).
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/net-snmp, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf net-snmp-5.9.5.2-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/net-snmp, and runs the triggers its paths call for.
Contents
Installed programs: agentxtrap, encode_keychange, net-snmp-config, net-snmp-create-v3-user, snmpbulkget, snmpbulkwalk, snmpd, snmpdelta, snmpdf, snmpget, snmpgetnext, snmpinform, snmpnetstat, snmppcap, snmpping, snmpps, snmpset, snmpstatus, snmptable, snmptest, snmptop, snmptranslate, snmptrap, snmptrapd, snmpusm, snmpvacm, snmpwalk.
Installed libraries: libnetsnmp.so, libnetsnmpagent.so, libnetsnmphelpers.so, libnetsnmpmibs.so, libnetsnmptrapd.so.
Installed directories: /usr/include/net-snmp, /usr/share/licenses/net-snmp, /var/lib/net-snmp.
Short descriptions
agentxtrap |
send an AgentX NotifyPDU to an AgentX master agent |
encode_keychange |
produce the KeyChange string for SNMPv3 |
net-snmp-config |
returns information about installed net-snmp libraries and binaries |
net-snmp-create-v3-user |
create a SNMPv3 user in net-snmp configuration file |
snmpbulkget |
communicates with a network entity using SNMP GETBULK requests. |
snmpbulkwalk |
retrieve a subtree of management values using SNMP GETBULK requests |
snmpd |
daemon to respond to SNMP request packets. |
snmpdelta |
Monitor delta differences in SNMP Counter values |
snmpdf |
display disk space usage on a network entity via SNMP |
snmpget |
communicates with a network entity using SNMP GET requests |
snmpgetnext |
communicates with a network entity using SNMP GETNEXT requests |
snmpnetstat |
display networking status and configuration information from a network entity via SNMP |
snmpps |
display process table on a network entity via SNMP |
snmpset |
communicates with a network entity using SNMP SET requests |
snmpstatus |
retrieves a fixed set of management information from a network entity |
snmptable |
retrieve an SNMP table and display it in tabular form |
snmptest |
communicates with a network entity using SNMP requests |
snmptranslate |
translate MIB OID names between numeric and textual forms |
snmptrap |
sends an SNMP notification to a manager |
snmptrapd |
Receive and log SNMP trap messages. |
snmpusm |
creates and maintains SNMPv3 users on a network entity |
snmpvacm |
creates and maintains SNMPv3 View-based Access Control entries on a network entity |
snmpwalk |
retrieve a subtree of management values using SNMP GETNEXT requests |
netsnmp.pc |
SNMP (Simple Network Management Protocol) daemon and applications. |
netsnmp-agent.pc |
SNMP (Simple Network Management Protocol) sub-agent SDK. |
Notes
build.sh checks net-snmp-config.h after configure for HAVE_LIBCRYPTO and HAVE_LIBNL3, so a build that silently lost OpenSSL or libnl stops there. The install runs with make -j1: its rules race each other under a parallel make.
The recipe writes a service script, /etc/init.d/71_snmpd.sh. It skips the agent until /etc/snmp/snmpd.conf exists and is not empty, because the file is not shipped and an agent with no access lines answers nobody. Started, snmpd runs in the foreground (-f) under the supervisor and logs to syslog’s daemon facility (-Lsd); see rcS and the service scripts. snmptrapd has no script.