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

View file

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

View file

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

View file

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