Skip to content

Commit

Permalink
move const values to iota plus code cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: ston1th <ston1th@giftfish.de>
  • Loading branch information
ston1th committed Nov 12, 2020
1 parent bdba65d commit 1450a92
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
14 changes: 7 additions & 7 deletions collector/cpu_openbsd_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ type clockinfo struct {
}

const (
CP_USER = 0
CP_NICE = 1
CP_SYS = 2
CP_SPIN = 3
CP_INTR = 4
CP_IDLE = 5
CPUSTATES = 6
CP_USER = iota
CP_NICE
CP_SYS
CP_SPIN
CP_INTR
CP_IDLE
CPUSTATES
)

type cpuCollector struct {
Expand Down
6 changes: 1 addition & 5 deletions collector/interrupts_openbsd_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ func intr(idx _C_int) (itr interrupt, err error) {
return
}

var (
interruptLabelNames = []string{"cpu", "type", "devices"}
)
var interruptLabelNames = []string{"cpu", "type", "devices"}

func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) error {
interrupts, err := getInterrupts()
Expand Down Expand Up @@ -97,15 +95,13 @@ type interrupt struct {

func getInterrupts() (map[string]interrupt, error) {
var interrupts = map[string]interrupt{}

n := nintr()

for i := _C_int(0); i < n; i++ {
itr, err := intr(i)
if err != nil {
return nil, err
}

interrupts[itr.device] = itr
}

Expand Down
1 change: 0 additions & 1 deletion collector/meminfo_openbsd_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func (c *meminfoCollector) getMemInfo() (map[string]float64, error) {
return nil, err
}
uvmexp := *(*unix.Uvmexp)(unsafe.Pointer(&uvmexpb[0]))

ps := float64(uvmexp.Pagesize)

// see uvm(9)
Expand Down
22 changes: 11 additions & 11 deletions collector/netdev_openbsd_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ func getNetDevStats(ignore *regexp.Regexp, accept *regexp.Regexp, logger log.Log
continue
}

devStats := map[string]string{}
devStats["receive_packets"] = strconv.Itoa(int(data.Ipackets))
devStats["transmit_packets"] = strconv.Itoa(int(data.Opackets))
devStats["receive_errs"] = strconv.Itoa(int(data.Ierrors))
devStats["transmit_errs"] = strconv.Itoa(int(data.Oerrors))
devStats["receive_bytes"] = strconv.Itoa(int(data.Ibytes))
devStats["transmit_bytes"] = strconv.Itoa(int(data.Obytes))
devStats["receive_multicast"] = strconv.Itoa(int(data.Imcasts))
devStats["transmit_multicast"] = strconv.Itoa(int(data.Omcasts))
devStats["receive_drop"] = strconv.Itoa(int(data.Iqdrops))
netDev[dev] = devStats
netDev[dev] = map[string]string{
"receive_packets": strconv.Itoa(int(data.Ipackets)),
"transmit_packets": strconv.Itoa(int(data.Opackets)),
"receive_errs": strconv.Itoa(int(data.Ierrors)),
"transmit_errs": strconv.Itoa(int(data.Oerrors)),
"receive_bytes": strconv.Itoa(int(data.Ibytes)),
"transmit_bytes": strconv.Itoa(int(data.Obytes)),
"receive_multicast": strconv.Itoa(int(data.Imcasts)),
"transmit_multicast": strconv.Itoa(int(data.Omcasts)),
"receive_drop": strconv.Itoa(int(data.Iqdrops)),
}
}
return netDev, nil
}

0 comments on commit 1450a92

Please sign in to comment.