Documentation
¶
Overview ¶
Package snmp provides shared SNMP protocol helpers used by both discover and enumerate modules.
Index ¶
- Variables
- func ExtractStringValue(value interface{}) string
- func FormatUptime(seconds int) string
- func LookupEnterpriseName(enterpriseID int) string
- func ParseEngineID(engineID []byte) (format, data string, enterprise int)
- func PopulateServerInfo(serverInfo *commonprotocolfern.SnmpServerInfo, v3Info *SNMPv3EngineInfo, ...)
- type SNMPSystemInfo
- type SNMPv3EngineInfo
Constants ¶
This section is empty.
Variables ¶
var CommonNoAuthUsernames = []string{
"public",
"initial",
"admin",
"snmpuser",
"default",
"monitor",
"noauth",
"",
}
CommonNoAuthUsernames are the default usernames tested for NoAuthNoPriv access.
var SystemOIDs = []string{
"1.3.6.1.2.1.1.1.0",
"1.3.6.1.2.1.1.2.0",
"1.3.6.1.2.1.1.3.0",
"1.3.6.1.2.1.1.4.0",
"1.3.6.1.2.1.1.5.0",
"1.3.6.1.2.1.1.6.0",
"1.3.6.1.2.1.1.7.0",
}
SystemOIDs are the standard system MIB OIDs queried by SNMP operations.
Functions ¶
func ExtractStringValue ¶
func ExtractStringValue(value interface{}) string
ExtractStringValue converts various SNMP value types to string. Returns empty string for nil values to avoid "<nil>" literals.
func FormatUptime ¶
FormatUptime converts seconds to a human-readable format.
func LookupEnterpriseName ¶
LookupEnterpriseName returns the enterprise name for a given enterprise ID.
func ParseEngineID ¶
ParseEngineID analyzes the engine ID format and extracts relevant information.
func PopulateServerInfo ¶
func PopulateServerInfo(serverInfo *commonprotocolfern.SnmpServerInfo, v3Info *SNMPv3EngineInfo, sysInfo *SNMPSystemInfo)
PopulateServerInfo fills a SnmpServerInfo from SNMPv3EngineInfo and SNMPSystemInfo.
Types ¶
type SNMPSystemInfo ¶
type SNMPSystemInfo struct {
SysDescr string
SysObjectID string
SysUpTime uint32
SysContact string
SysName string
SysLocation string
SysServices int
}
SNMPSystemInfo holds SNMP system MIB information.
func ParseSystemInfo ¶
func ParseSystemInfo(result *gosnmp.SnmpPacket) *SNMPSystemInfo
ParseSystemInfo extracts system MIB values from an SNMP GET result.
func TrySNMPCommunityCheck ¶
func TrySNMPCommunityCheck(ip net.IP, port uint16, timeout int, community string, version gosnmp.SnmpVersion) (bool, *SNMPSystemInfo, error)
TrySNMPCommunityCheck tests if an SNMP community string works. Returns success status, system info, and error.
func TrySNMPv3NoAuthGet ¶
TrySNMPv3NoAuthGet attempts a single SNMPv3 GET with NoAuthNoPriv for a specific username. Returns true if the GET succeeds (unauthenticated read access is allowed). Also returns parsed system info if the query succeeded.
type SNMPv3EngineInfo ¶
type SNMPv3EngineInfo struct {
EngineID string
EngineIDFormat string
EngineIDData string
EngineBoots int
EngineTime int
Enterprise int
}
SNMPv3EngineInfo holds SNMPv3 engine discovery information.
func TrySNMPv3Discovery ¶
TrySNMPv3Discovery attempts SNMPv3 engine discovery. Returns engine info, system description (if available), and error.