Compare commits

...

4 Commits

11 changed files with 231 additions and 5 deletions

10
.gitignore vendored
View File

@ -1,2 +1,12 @@
govpp-snmp-agentx
vppcfg.yaml
# Debian packaging artifacts
debian/.debhelper/
debian/.gocache/
debian/go/
debian/govpp-snmp-agentx/
debian/files
debian/*.substvars
debian/debhelper-build-stamp
debian/*.debhelper

20
Makefile Normal file
View File

@ -0,0 +1,20 @@
.PHONY: build test clean pkg-deb
# Build the govpp-snmp-agentx binary
build:
go build -o govpp-snmp-agentx .
# Run all tests
test:
go test ./...
# Clean build artifacts
clean:
rm -f govpp-snmp-agentx
[ -d debian/go ] && chmod -R +w debian/go || true
rm -rf debian/.debhelper debian/.gocache debian/go debian/govpp-snmp-agentx debian/files debian/*.substvars debian/debhelper-build-stamp
rm -f ../govpp-snmp-agentx_*
# Build Debian package
pkg-deb:
fakeroot dpkg-buildpackage -us -uc -b

17
debian/changelog vendored Normal file
View File

@ -0,0 +1,17 @@
govpp-snmp-agentx (1.0.1-1) bookworm; urgency=medium
* Add manual page for govpp-snmp-agentx(1)
* Make VPP config file optional - log warning and continue if missing
* Fix Debian package build reproducibility issues
* Improve build system with proper cleanup targets
-- Pim van Pelt <pim@ipng.ch> Tue, 17 Jun 2025 00:35:00 +0000
govpp-snmp-agentx (1.0.0-1) bookworm; urgency=medium
* Initial release
* SNMP AgentX daemon for VPP statistics
* Interface MIB support
* Systemd service integration
-- Pim van Pelt <pim@ipng.ch> Mon, 16 Jun 2025 00:00:00 +0000

23
debian/control vendored Normal file
View File

@ -0,0 +1,23 @@
Source: govpp-snmp-agentx
Section: net
Priority: optional
Maintainer: Pim van Pelt <pim@ipng.ch>
Build-Depends: debhelper-compat (= 13), golang-go (>= 1.21)
Standards-Version: 4.6.2
Homepage: https://git.ipng.ch/ipng/govpp-agentx-snmp
Vcs-Git: https://git.ipng.ch/ipng/govpp-agentx-snmp
Vcs-Browser: https://git.ipng.ch/ipng/govpp-agentx-snmp
Package: govpp-snmp-agentx
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, snmp, snmpd, adduser
Description: GoVPP SNMP AgentX Daemon
A SNMP AgentX daemon that provides SNMP access to VPP (Vector Packet Processing)
statistics and interface information. This daemon acts as a subagent that
connects to the main SNMP daemon via the AgentX protocol.
.
Features:
- Interface MIB support
- VPP statistics exposure
- AgentX protocol implementation
- Systemd integration

View File

@ -0,0 +1,12 @@
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge 'govpp-snmp-agentx.service' >/dev/null || true
fi
fi
# End automatically added section

23
debian/postinst vendored Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
case "$1" in
configure)
# Enable and start the service
systemctl daemon-reload
systemctl enable govpp-snmp-agentx.service
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0

22
debian/prerm vendored Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
set -e
case "$1" in
remove|upgrade|deconfigure)
systemctl stop govpp-snmp-agentx.service || true
systemctl disable govpp-snmp-agentx.service || true
;;
failed-upgrade)
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0

29
debian/rules vendored Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
export GO111MODULE = on
export GOPROXY = direct
export GOCACHE = $(CURDIR)/debian/.gocache
export GOPATH = $(CURDIR)/debian/go
%:
dh $@
override_dh_auto_build:
go build -v -ldflags="-s -w" -o govpp-snmp-agentx .
override_dh_auto_install:
install -D -m 0755 govpp-snmp-agentx debian/govpp-snmp-agentx/usr/sbin/govpp-snmp-agentx
install -D -m 0644 govpp-snmp-agentx.service debian/govpp-snmp-agentx/lib/systemd/system/govpp-snmp-agentx.service
install -D -m 0644 docs/govpp-snmp-agentx.1 debian/govpp-snmp-agentx/usr/share/man/man1/govpp-snmp-agentx.1
override_dh_auto_configure:
# Skip auto configure
override_dh_auto_test:
# Skip tests during packaging
override_dh_auto_clean:
rm -f govpp-snmp-agentx
[ -d debian/go ] && chmod -R +w debian/go || true
rm -rf debian/.gocache debian/go obj-*

72
docs/govpp-snmp-agentx.1 Normal file
View File

@ -0,0 +1,72 @@
.TH GOVPP-SNMP-AGENTX 1 "June 2025" "version 1.0.0" "User Commands"
.SH NAME
govpp-snmp-agentx \- VPP SNMP AgentX daemon for interface statistics
.SH SYNOPSIS
.B govpp-snmp-agentx
[\fIOPTION\fR]...
.SH DESCRIPTION
.B govpp-snmp-agentx
is an SNMP AgentX subagent that provides SNMP access to VPP (Vector Packet Processing) interface statistics and information. It connects to a master SNMP daemon via the AgentX protocol and populates standard IF-MIB tables with real-time VPP interface data.
.PP
The daemon implements two MIB tables:
.TP
.B ifEntry
Classic interface table (1.3.6.1.2.1.2.2.1) with basic interface statistics including counters for packets, bytes, errors, and discards.
.TP
.B ifXTable
Extended interface table (1.3.6.1.2.1.31.1.1.1) with high-capacity 64-bit counters and additional interface information.
.SH OPTIONS
.TP
.BR \-agentx.addr " " \fIADDRESS\fR
AgentX master agent address. Can be a TCP address (hostname:port) or Unix socket path.
Default: localhost:705
.TP
.BR \-debug
Enable debug logging to show detailed operational information.
.TP
.BR \-vppcfg " " \fIFILE\fR
VPP configuration YAML file to read interface descriptions from.
.TP
.BR \-vppstats.api.addr " " \fIPATH\fR
VPP API socket path for interface enumeration.
Default: /var/run/vpp/api.sock
.TP
.BR \-vppstats.stats.addr " " \fIPATH\fR
VPP statistics socket path for interface counters.
Default: /var/run/vpp/stats.sock
.TP
.BR \-vppstats.ifindex-offset " " \fINUMBER\fR
Offset added to VPP interface indices for SNMP interface numbering.
Default: 1000
.TP
.BR \-vppstats.period " " \fISECONDS\fR
Interval in seconds for querying VPP interface statistics.
Default: 10
.SH EXAMPLES
.TP
Connect to AgentX master via TCP:
.B govpp-snmp-agentx -agentx.addr snmp.example.com:705
.TP
Connect via Unix socket with debug logging:
.B govpp-snmp-agentx -agentx.addr /var/agentx/master -debug
.TP
Use custom VPP sockets and config:
.B govpp-snmp-agentx -vppstats.api.addr /opt/vpp/api.sock -vppcfg /etc/vpp/vppcfg.yaml
.SH FILES
.TP
.I /var/run/vpp/api.sock
Default VPP API socket
.TP
.I /var/run/vpp/stats.sock
Default VPP statistics socket
.TP
.I /var/agentx/master
Common AgentX Unix socket path
.SH SEE ALSO
.BR snmpd (8),
.BR snmpwalk (1),
.BR vpp (8)
.SH AUTHOR
Pim van Pelt <pim@ipng.ch>
.SH COPYRIGHT
Copyright 2025, IPng Networks GmbH

View File

@ -1,14 +1,11 @@
[Unit]
Description=GoVPP SNMP AgentX Daemon
After=network.target vpp.service
Requires=netns-dataplane.service
[Service]
Type=simple
ExecStartPre=-+/usr/bin/chmod 660 /run/vpp/stats.sock /run/vpp/api.sock /run/vpp/cli.sock
ExecStartPre=-+/usr/bin/chown :vpp /run/vpp/stats.sock /run/vpp/api.sock /run/vpp/cli.sock
ExecStartPre=-+/usr/bin/chmod 770 /var/agentx /var/agentx/master
ExecStartPre=-+/usr/bin/chown :vpp /var/agentx /var/agentx/master
ExecStartPre=-+/usr/bin/chown Debian-snmp:vpp /var/agentx /var/agentx/master
ExecStart=/usr/sbin/govpp-snmp-agentx -agentx.addr /var/agentx/master -vppcfg /etc/vpp/vppcfg.yaml -vppstats.period 10
User=Debian-snmp
Group=vpp

View File

@ -30,7 +30,8 @@ func main() {
// Load VPP config if specified
if *vppcfg != "" {
if err := interfaceMIB.LoadVPPConfig(*vppcfg); err != nil {
log.Fatalf("Failed to load VPP config: %v", err)
logger.Printf("Warning: Failed to load VPP config from %s: %v", *vppcfg, err)
logger.Printf("Continuing without VPP config file...")
}
}