Skip to content

refactor: log zero values in Cisco collector#4204

Merged
cgrinds merged 1 commit into
mainfrom
cbg-cisco
Mar 23, 2026
Merged

refactor: log zero values in Cisco collector#4204
cgrinds merged 1 commit into
mainfrom
cbg-cisco

Conversation

@cgrinds
Copy link
Copy Markdown
Collaborator

@cgrinds cgrinds commented Mar 23, 2026

No description provided.

@cgrinds cgrinds requested a review from rahulguptajss as a code owner March 23, 2026 14:03
Copilot AI review requested due to automatic review settings March 23, 2026 14:03
@cgrinds cgrinds requested a review from Hardikl as a code owner March 23, 2026 14:03
@cla-bot cla-bot Bot added the cla-signed label Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds additional diagnostics to the Cisco networkinterface collector to help investigate cases where interface byte counters are unexpectedly reported as zero/missing.

Changes:

  • Adds presence checks for eth_inbytes / eth_outbytes during interface parsing.
  • Introduces a debugMissingBytes helper that logs an error and appends the raw CLI JSON output to a local debug file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/collectors/cisco/plugins/networkinterface/networkinterface.go
Comment thread cmd/collectors/cisco/plugins/networkinterface/networkinterface.go
Comment thread cmd/collectors/cisco/plugins/networkinterface/networkinterface.go
Comment on lines +224 to +226
filename := "/tmp/interface_debug.txt"
f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debugMissingBytes appends output.String() (the full CLI response) to a hard-coded /tmp file. This can quickly create very large, unbounded files and adds disk I/O on the collection path; it may also fail in containers/locked-down environments where /tmp is read-only. Consider gating this behind a config/env flag and logging only the relevant per-interface JSON (or a small subset) to the normal logger instead of writing to disk, or use os.TempDir()/configurable path with rotation/limits.

Copilot uses AI. Check for mistakes.
@cgrinds cgrinds merged commit 92b2e2e into main Mar 23, 2026
14 checks passed
@cgrinds cgrinds deleted the cbg-cisco branch March 23, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants