@@ -63,7 +63,7 @@ var combinedTypeMapping = map[string]map[int]string{
6363
6464func oidToList (oid string ) []int {
6565 result := []int {}
66- for _ , x := range strings .Split (oid , "." ) {
66+ for x := range strings .SplitSeq (oid , "." ) {
6767 o , _ := strconv .Atoi (x )
6868 result = append (result , o )
6969 }
@@ -118,10 +118,7 @@ func ScrapeTarget(snmp scraper.SNMPScraper, target string, auth *config.Auth, mo
118118 maxOids = 1
119119 }
120120 for len (getOids ) > 0 {
121- oids := len (getOids )
122- if oids > maxOids {
123- oids = maxOids
124- }
121+ oids := min (len (getOids ), maxOids )
125122
126123 packet , err := snmp .Get (getOids [:oids ])
127124 if err != nil {
@@ -355,7 +352,7 @@ func (c Collector) collect(ch chan<- prometheus.Metric, logger *slog.Logger, cli
355352 g .MaxRepetitions = module .WalkParams .MaxRepetitions
356353 g .UseUnconnectedUDPSocket = module .WalkParams .UseUnconnectedUDPSocket
357354 if module .WalkParams .AllowNonIncreasingOIDs {
358- g .AppOpts = map [string ]interface {} {
355+ g .AppOpts = map [string ]any {
359356 "c" : true ,
360357 }
361358 }
@@ -423,10 +420,7 @@ func (c Collector) collect(ch chan<- prometheus.Metric, logger *slog.Logger, cli
423420// Collect implements Prometheus.Collector.
424421func (c Collector ) Collect (ch chan <- prometheus.Metric ) {
425422 wg := sync.WaitGroup {}
426- workerCount := c .concurrency
427- if workerCount < 1 {
428- workerCount = 1
429- }
423+ workerCount := max (c .concurrency , 1 )
430424 ctx , cancel := context .WithCancel (c .ctx )
431425 defer cancel ()
432426 workerChan := make (chan * NamedModule )
@@ -764,7 +758,7 @@ func enumAsStateSet(metric *config.Metric, value int, labelnames, labelvalues []
764758 return results
765759}
766760
767- func bits (metric * config.Metric , value interface {} , labelnames , labelvalues []string ) []prometheus.Metric {
761+ func bits (metric * config.Metric , value any , labelnames , labelvalues []string ) []prometheus.Metric {
768762 bytes , ok := value .([]byte )
769763 if ! ok {
770764 return []prometheus.Metric {prometheus .NewInvalidMetric (prometheus .NewDesc ("snmp_error" , "BITS type was not a BISTRING on the wire." , nil , nil ),
@@ -936,7 +930,7 @@ func indexOidsAsString(indexOids []int, typ string, fixedSize int, implied bool,
936930 return strings .Join (parts , "." ), subOid , indexOids
937931 case "InetAddressIPv6" :
938932 subOid , indexOids := splitOid (indexOids , 16 )
939- parts := make ([]interface {} , 16 )
933+ parts := make ([]any , 16 )
940934 for i , o := range subOid {
941935 parts [i ] = o
942936 }
0 commit comments