Skip to content

Conversation

@erikreinert
Copy link
Contributor

Summary

  • Add "type" field to all device data structures (vlan, switch, router, ap, pi, server) to enable future type-based filtering and processing
  • Generate prom-switches.json targeting port 161 for SNMP polling of Juniper switches
  • Configure Alloy with SNMP exporter to collect switch metrics (port statistics, CPU, memory) alongside existing AP and Pi metrics

@erikreinert erikreinert changed the title [READY] facts,monitoring: add SNMP scraping for network switches Add SNMP scraping for network switches Feb 1, 2026
@erikreinert erikreinert self-assigned this Feb 1, 2026
Enable monitoring of Juniper switches via SNMP by adding switch targets
to the prometheus configuration generator. This allows collecting switch
metrics (port statistics, CPU, memory) alongside existing AP and Pi
metrics.

- Generate prom-switches.json targeting port 161 for SNMP polling
- Configure Alloy with SNMP exporter for switch metrics collection
Change relative path from ../snmp.yml to ./snmp.yml since the file
is in the same directory as monitoring.nix.
Copy link
Member

@sarcasticadmin sarcasticadmin left a comment

Choose a reason for hiding this comment

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

@erikreinert thanks for working on all of this during the work party! Was this applied against core-master and able to scrape the 4200 we had running? I couldnt remember

I included some comments and did a little testing locally myself with the existing tests. I didnt want to bulldoze this branch but checkout https://github.com/socallinuxexpo/scale-network/tree/rh/snmp-scrape It encompasses more or less the items Im commenting on here.

As a follow up PR we should consider a related SNMP issue: #929 This would be so we dont have to embedded the snmp.yml in the repo

if not vlanid.isdigit():
return None
return {
"type": "vlan",
Copy link
Member

Choose a reason for hiding this comment

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

lets remove this extra type is doesnt actually do anything

with open(f"{outputdir}/prom-pis.json", "w") as f:
f.write(json.dumps(prom_pi_config, indent=2))

prom_switch_config = [
Copy link
Member

Choose a reason for hiding this comment

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

seems reasonable, thanks for sticking with the existing convention

assert inventory.populateservers(filename, mocvlans) == servers, filename


def test_generatepromconfigs():
Copy link
Member

Choose a reason for hiding this comment

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

i dont think these tests add a lot of value, seems to be mostly testing that open works. Lets remove these tests entirely

Copy link
Member

Choose a reason for hiding this comment

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

This was my fault and has been fixed in #1060 and currently in master so we can drop this commit

}

// Scrape SNMP metrics from switches
prometheus.scrape "switches" {
Copy link
Member

Choose a reason for hiding this comment

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

nice

@sarcasticadmin sarcasticadmin self-requested a review February 6, 2026 19:30
@sarcasticadmin sarcasticadmin changed the title Add SNMP scraping for network switches [READY] Add SNMP scraping for network switches Feb 6, 2026
Copy link
Member

@sarcasticadmin sarcasticadmin left a comment

Choose a reason for hiding this comment

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

Updated this PR with the subset of the original changes from rh/snmp-scrape

@sarcasticadmin sarcasticadmin merged commit db9f3c9 into master Feb 6, 2026
3 checks passed
@sarcasticadmin sarcasticadmin deleted the feature/snmp-scrape branch February 6, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants