- Add MIB files from LibreNMS in priv/mibs/ for reference - Create MibParser module to validate OIDs against official MIB definitions - Add MIB validation tests to ensure hardcoded OIDs match MIB specs - Refactor SNMP tests to be generic/behavior-focused instead of vendor-specific - Remove vendor-specific test files (cisco_test, net_snmp_test) - All 104 tests passing with automated OID validation
56 lines
1.7 KiB
Markdown
56 lines
1.7 KiB
Markdown
# SNMP MIB Files
|
|
|
|
This directory contains SNMP MIB (Management Information Base) files used by Towerops for network device monitoring.
|
|
|
|
## Directory Structure
|
|
|
|
- `standard/` - Standard IETF/IANA MIBs (IF-MIB, ENTITY-MIB, etc.)
|
|
- `cisco/` - Cisco vendor-specific MIBs
|
|
- `mikrotik/` - MikroTik vendor-specific MIBs
|
|
- `net-snmp/` - Net-SNMP specific MIBs (LM-SENSORS, UCD-SNMP)
|
|
|
|
## Source
|
|
|
|
MIB files are sourced from the [LibreNMS project](https://github.com/librenms/librenms/tree/master/mibs), which maintains a comprehensive collection of vendor MIBs.
|
|
|
|
## Purpose
|
|
|
|
These MIB files serve as:
|
|
|
|
1. **Reference Documentation** - Authoritative source for OID definitions
|
|
2. **Validation** - Tests verify that hardcoded OIDs in profile modules match MIB definitions
|
|
3. **Discovery** - Can be browsed to understand available SNMP objects
|
|
|
|
## Usage in Code
|
|
|
|
Profile modules (e.g., `Towerops.Snmp.Profiles.Cisco`) contain hardcoded OID strings for performance. These are validated against MIB files during testing to ensure accuracy.
|
|
|
|
Example from `Towerops.Snmp.Profiles.Base`:
|
|
|
|
```elixir
|
|
@interface_oids %{
|
|
if_index: "1.3.6.1.2.1.2.2.1.1", # Validated against IF-MIB
|
|
if_descr: "1.3.6.1.2.1.2.2.1.2" # Validated against IF-MIB
|
|
}
|
|
```
|
|
|
|
## Adding New MIBs
|
|
|
|
To add support for a new vendor:
|
|
|
|
1. Create a directory: `priv/mibs/vendor_name/`
|
|
2. Download MIB files from LibreNMS or vendor
|
|
3. Add OID references in the appropriate profile module
|
|
4. Tests will automatically validate against the new MIBs
|
|
|
|
## MIB File Format
|
|
|
|
MIB files use ASN.1 (Abstract Syntax Notation One) format, which defines:
|
|
- Object identifiers (OIDs)
|
|
- Data types
|
|
- Access levels
|
|
- Descriptions
|
|
|
|
## Testing
|
|
|
|
See `test/towerops/snmp/mib_validation_test.exs` for OID validation tests.
|