Fix all open go lint and vet issues
This commit is contained in:
parent
5289ffb270
commit
c703435790
37 changed files with 136 additions and 129 deletions
|
|
@ -26,20 +26,31 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
type TCPConnectionState int
|
||||
type tcpConnectionState int
|
||||
|
||||
const (
|
||||
TCP_ESTABLISHED TCPConnectionState = iota + 1
|
||||
TCP_SYN_SENT
|
||||
TCP_SYN_RECV
|
||||
TCP_FIN_WAIT1
|
||||
TCP_FIN_WAIT2
|
||||
TCP_TIME_WAIT
|
||||
TCP_CLOSE
|
||||
TCP_CLOSE_WAIT
|
||||
TCP_LAST_ACK
|
||||
TCP_LISTEN
|
||||
TCP_CLOSING
|
||||
// TCP_ESTABLISHED
|
||||
tcpEstablished tcpConnectionState = iota + 1
|
||||
// TCP_SYN_SENT
|
||||
tcpSynSent
|
||||
// TCP_SYN_RECV
|
||||
tcpSynRecv
|
||||
// TCP_FIN_WAIT1
|
||||
tcpFinWait1
|
||||
// TCP_FIN_WAIT2
|
||||
tcpFinWait2
|
||||
// TCP_TIME_WAIT
|
||||
tcpTimeWait
|
||||
// TCP_CLOSE
|
||||
tcpClose
|
||||
// TCP_CLOSE_WAIT
|
||||
tcpCloseWait
|
||||
// TCP_LAST_ACK
|
||||
tcpLastAck
|
||||
// TCP_LISTEN
|
||||
tcpListen
|
||||
// TCP_CLOSING
|
||||
tcpClosing
|
||||
)
|
||||
|
||||
type tcpStatCollector struct {
|
||||
|
|
@ -84,10 +95,10 @@ func (c *tcpStatCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
|||
for st, value := range tcpStats {
|
||||
ch <- c.desc.mustNewConstMetric(value, st.String())
|
||||
}
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
func getTCPStats(statsFile string) (map[TCPConnectionState]float64, error) {
|
||||
func getTCPStats(statsFile string) (map[tcpConnectionState]float64, error) {
|
||||
file, err := os.Open(statsFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -97,9 +108,9 @@ func getTCPStats(statsFile string) (map[TCPConnectionState]float64, error) {
|
|||
return parseTCPStats(file)
|
||||
}
|
||||
|
||||
func parseTCPStats(r io.Reader) (map[TCPConnectionState]float64, error) {
|
||||
func parseTCPStats(r io.Reader) (map[tcpConnectionState]float64, error) {
|
||||
var (
|
||||
tcpStats = map[TCPConnectionState]float64{}
|
||||
tcpStats = map[tcpConnectionState]float64{}
|
||||
scanner = bufio.NewScanner(r)
|
||||
)
|
||||
|
||||
|
|
@ -116,35 +127,35 @@ func parseTCPStats(r io.Reader) (map[TCPConnectionState]float64, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
tcpStats[TCPConnectionState(st)]++
|
||||
tcpStats[tcpConnectionState(st)]++
|
||||
}
|
||||
|
||||
return tcpStats, nil
|
||||
}
|
||||
|
||||
func (st TCPConnectionState) String() string {
|
||||
func (st tcpConnectionState) String() string {
|
||||
switch st {
|
||||
case TCP_ESTABLISHED:
|
||||
case tcpEstablished:
|
||||
return "established"
|
||||
case TCP_SYN_SENT:
|
||||
case tcpSynSent:
|
||||
return "syn_sent"
|
||||
case TCP_SYN_RECV:
|
||||
case tcpSynRecv:
|
||||
return "syn_recv"
|
||||
case TCP_FIN_WAIT1:
|
||||
case tcpFinWait1:
|
||||
return "fin_wait1"
|
||||
case TCP_FIN_WAIT2:
|
||||
case tcpFinWait2:
|
||||
return "fin_wait2"
|
||||
case TCP_TIME_WAIT:
|
||||
case tcpTimeWait:
|
||||
return "time_wait"
|
||||
case TCP_CLOSE:
|
||||
case tcpClose:
|
||||
return "close"
|
||||
case TCP_CLOSE_WAIT:
|
||||
case tcpCloseWait:
|
||||
return "close_wait"
|
||||
case TCP_LAST_ACK:
|
||||
case tcpLastAck:
|
||||
return "last_ack"
|
||||
case TCP_LISTEN:
|
||||
case tcpListen:
|
||||
return "listen"
|
||||
case TCP_CLOSING:
|
||||
case tcpClosing:
|
||||
return "closing"
|
||||
default:
|
||||
return "unknown"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue