Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

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

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.

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:

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.