feat: rewrite ClamAV exporter in Go - #3
Open
tharinfernando wants to merge 1 commit into
Open
Conversation
Ports clamav-exporter/exporter.py to Go with identical metrics and endpoints. Adds unit tests, Makefile, README with build/run docs and memory comparison. Keeps exporter.py until the Go version is verified in deployment. Refs OpenGovMail/OpenGovMail#291
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Go port of
clamav-exporter/exporter.pywith identical metrics and endpoints.Changes Made
clamav-exporter/main.go: stdlib HTTP server, Unix socket probe with TCPclamav:3310fallback,z<CMD>null-terminated protocol with 5s timeout, STATS/VERSION parsing, clamd and freshclam log parsing, Prometheus exposition for all 13 metricsclamav-exporter/main_test.go: 9 unit tests (STATS, VERSION, log parsing, freshclam status, golden exposition output, down-state)clamav-exporter/go.mod(go 1.21, stdlib only),Makefile(build, test, vet, docker-build),README.md(build/run docs, env vars, memory comparison)clamav-exporter/DockerfilePython base with multi-stage Go build on alpine, non-root user, sameEXPOSE 9810exporter.pyin place until the Go version is verified in deploymentChecklist (Email System)
clamav_up 0when ClamAV unreachable, sanitized logs, 5s timeoutsTesting Instructions
cd clamav-exporter && go test ./... && go vet ./...STARTUP_DELAY_SECONDS=0 go run main.go, thencurl -s localhost:9810/healthreturnsOKcurl -s localhost:9810/metricsshowsclamav_up 1and all 13 metrics with correct valuesdocker build -t opengovmail-clamav-exporter .succeeds, image 27.1MB vs python:3.11-slim base 198MBScreenshots / Logs
Memory (host RSS, no backend reachable): Python 23,512 KB idle and after 50 scrapes; Go 10,084 KB idle and 10,912 KB after 50 scrapes.
Notes for Reviewers
clamav_up 1because log stats are merged into the stats map before the truthiness check, so it never detects a down daemon. The Go version reportsclamav_up 0when STATS and VERSION both fail. Flagging for approval or I can match the old behavior.exporter.pydeletion is deferred to a follow-up after this is verified live, per the issue.