move const values to iota plus code cleanup

Signed-off-by: ston1th <ston1th@giftfish.de>
This commit is contained in:
ston1th 2020-09-02 13:54:40 +02:00
parent bdba65df16
commit 1450a92a68
4 changed files with 19 additions and 24 deletions

View file

@ -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 {

View file

@ -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()
@ -97,7 +95,6 @@ type interrupt struct {
func getInterrupts() (map[string]interrupt, error) {
var interrupts = map[string]interrupt{}
n := nintr()
for i := _C_int(0); i < n; i++ {
@ -105,7 +102,6 @@ func getInterrupts() (map[string]interrupt, error) {
if err != nil {
return nil, err
}
interrupts[itr.device] = itr
}

View file

@ -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)

View file

@ -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
}