func methodStreamBulkWalk(s *gosnmp.GoSNMP, oid string) { if resChn, err := s.StreamBulkWalk(uint8(cmdBulkSize), oid); err != nil { fmt.Printf("Error Bulk Walk: %v\n", err) } else { idx := 0 for resp := range resChn { if resp.Err != nil { fmt.Printf("Error: %v\n", resp.Err) } else { idx += 1 if oid, err := parseOID(resp.PDU.Name); err == nil { if prefix, suffix, err := TranslateOIDFromCache(oid); err == nil { // fmt.Printf("(%d) prefix: %s, suffix: %s -> value: %v (oid:%v)\n", idx, prefix, suffix, r.Value, r.Name) fmt.Printf("StreamBulkWalk: (%d) prefix: %s, suffix: %s -> value: %v\n", idx, prefix, suffix, resp.PDU.Value) } else if prefix != "" { fmt.Printf("StreamBulkWalk: (%d) prefix: %s, suffix: ---, err: %v -> value: %v\n", idx, prefix, err, resp.PDU.Value) } else { fmt.Printf("StreamBulkWalk: (%d) oid: %v -> value: %s err: %v\n", idx, resp.PDU.Name, resp.PDU.Value, err) } } else { fmt.Printf("StreamBulkWalk: ERROR: %v\n", err) } } } } }
func methodStreamWalk(s *gosnmp.GoSNMP, oid string) { fmt.Printf("methodStreamWalk: %v\n", oid) s.SetErrorDelayMs(cmdRetryDelayMs) s.SetRetryCnt(cmdRetryLimit) resChn, err := s.StreamWalk(oid, cmdDupFilterSize) if err != nil { fmt.Printf("Error getting response: %s\n", err.Error()) } else { idx := 0 for resp := range resChn { if resp.Err != nil { fmt.Printf("Error: %v\n", resp.Err) } else { idx += 1 if oid, err := parseOID(resp.PDU.Name); err == nil { if prefix, suffix, err := TranslateOIDFromCache(oid); err == nil { fmt.Printf("StreamWalk: (%d) prefix: %s, suffix: %s -> value: %v\n", idx, prefix, suffix, resp.PDU.Value) } else if prefix != "" { fmt.Printf("StreamWalk: (%d) prefix: %s, suffix: ---, err: %v -> value: %v\n", idx, prefix, err, resp.PDU.Value) } else { fmt.Printf("StreamWalk: (%d) oid: %v -> value: %v err: %v\n", idx, resp.PDU.Name, resp.PDU.Value, err) } } else { fmt.Printf("StreamWalk: ERROR: %v\n", err) } } } } }
func methodBulkWalk(s *gosnmp.GoSNMP, oid string) { fmt.Println("Bulk Walk", oid) res, err := s.BulkWalk(uint8(cmdBulkSize), oid) if err != nil { fmt.Printf("Error Bulk Walk: %v\n", err) } for idx, r := range res { // fmt.Printf("(%d) name: %v, t: %v, v: %v\n", idx, r.Name, r.Type, r.Value) if oid, err := parseOID(r.Name); err == nil { if prefix, suffix, err := TranslateOIDFromCache(oid); err == nil { // fmt.Printf("(%d) prefix: %s, suffix: %s -> value: %v (oid:%v)\n", idx, prefix, suffix, r.Value, r.Name) fmt.Printf("BulkWalk: (%d) prefix: %s, suffix: %s -> value: %v\n", idx, prefix, suffix, r.Value) } else if prefix != "" { fmt.Printf("BulkWalk: (%d) prefix: %s, suffix: ---, err: %v -> value: %v\n", idx, prefix, err, r.Value) } else { fmt.Printf("BulkWalk: (%d) oid: %v -> value: %s err: %v\n", idx, r.Name, r.Value, err) } } else { fmt.Printf("BulkWalk: ERROR: %v\n", err) } } }