Browse Source

move const values to iota plus code cleanup

Signed-off-by: ston1th <ston1th@giftfish.de>
pull/1774/head
ston1th 4 years ago
parent
commit
1450a92a68
  1. 14
      collector/cpu_openbsd_amd64.go
  2. 6
      collector/interrupts_openbsd_amd64.go
  3. 1
      collector/meminfo_openbsd_amd64.go
  4. 22
      collector/netdev_openbsd_amd64.go

14
collector/cpu_openbsd_amd64.go

@ -33,13 +33,13 @@ type clockinfo struct {
} }
const ( const (
CP_USER = 0 CP_USER = iota
CP_NICE = 1 CP_NICE
CP_SYS = 2 CP_SYS
CP_SPIN = 3 CP_SPIN
CP_INTR = 4 CP_INTR
CP_IDLE = 5 CP_IDLE
CPUSTATES = 6 CPUSTATES
) )
type cpuCollector struct { type cpuCollector struct {

6
collector/interrupts_openbsd_amd64.go

@ -67,9 +67,7 @@ func intr(idx _C_int) (itr interrupt, err error) {
return return
} }
var ( var interruptLabelNames = []string{"cpu", "type", "devices"}
interruptLabelNames = []string{"cpu", "type", "devices"}
)
func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) error { func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) error {
interrupts, err := getInterrupts() interrupts, err := getInterrupts()
@ -97,7 +95,6 @@ type interrupt struct {
func getInterrupts() (map[string]interrupt, error) { func getInterrupts() (map[string]interrupt, error) {
var interrupts = map[string]interrupt{} var interrupts = map[string]interrupt{}
n := nintr() n := nintr()
for i := _C_int(0); i < n; i++ { for i := _C_int(0); i < n; i++ {
@ -105,7 +102,6 @@ func getInterrupts() (map[string]interrupt, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
interrupts[itr.device] = itr interrupts[itr.device] = itr
} }

1
collector/meminfo_openbsd_amd64.go

@ -26,7 +26,6 @@ func (c *meminfoCollector) getMemInfo() (map[string]float64, error) {
return nil, err return nil, err
} }
uvmexp := *(*unix.Uvmexp)(unsafe.Pointer(&uvmexpb[0])) uvmexp := *(*unix.Uvmexp)(unsafe.Pointer(&uvmexpb[0]))
ps := float64(uvmexp.Pagesize) ps := float64(uvmexp.Pagesize)
// see uvm(9) // see uvm(9)

22
collector/netdev_openbsd_amd64.go

@ -63,17 +63,17 @@ func getNetDevStats(ignore *regexp.Regexp, accept *regexp.Regexp, logger log.Log
continue continue
} }
devStats := map[string]string{} netDev[dev] = map[string]string{
devStats["receive_packets"] = strconv.Itoa(int(data.Ipackets)) "receive_packets": strconv.Itoa(int(data.Ipackets)),
devStats["transmit_packets"] = strconv.Itoa(int(data.Opackets)) "transmit_packets": strconv.Itoa(int(data.Opackets)),
devStats["receive_errs"] = strconv.Itoa(int(data.Ierrors)) "receive_errs": strconv.Itoa(int(data.Ierrors)),
devStats["transmit_errs"] = strconv.Itoa(int(data.Oerrors)) "transmit_errs": strconv.Itoa(int(data.Oerrors)),
devStats["receive_bytes"] = strconv.Itoa(int(data.Ibytes)) "receive_bytes": strconv.Itoa(int(data.Ibytes)),
devStats["transmit_bytes"] = strconv.Itoa(int(data.Obytes)) "transmit_bytes": strconv.Itoa(int(data.Obytes)),
devStats["receive_multicast"] = strconv.Itoa(int(data.Imcasts)) "receive_multicast": strconv.Itoa(int(data.Imcasts)),
devStats["transmit_multicast"] = strconv.Itoa(int(data.Omcasts)) "transmit_multicast": strconv.Itoa(int(data.Omcasts)),
devStats["receive_drop"] = strconv.Itoa(int(data.Iqdrops)) "receive_drop": strconv.Itoa(int(data.Iqdrops)),
netDev[dev] = devStats }
} }
return netDev, nil return netDev, nil
} }

Loading…
Cancel
Save