Merge branch 'master' of github.com:didi/nightingale
This commit is contained in:
commit
daa8ba4f48
|
@ -6,8 +6,6 @@ import (
|
|||
"github.com/didi/nightingale/src/dataobj"
|
||||
"github.com/didi/nightingale/src/modules/collector/sys"
|
||||
"github.com/didi/nightingale/src/toolkits/identity"
|
||||
|
||||
"github.com/toolkits/pkg/logger"
|
||||
)
|
||||
|
||||
func Collect() {
|
||||
|
@ -46,7 +44,6 @@ func collect(sec int64, fn func() []*dataobj.MetricValue) {
|
|||
item.Step = sec
|
||||
item.Endpoint = identity.Identity
|
||||
item.Timestamp = now
|
||||
logger.Debug("push item: ", item)
|
||||
metricValues = append(metricValues, item)
|
||||
}
|
||||
Push(metricValues)
|
||||
|
|
|
@ -39,7 +39,7 @@ func Push(metricItems []*dataobj.MetricValue) error {
|
|||
continue
|
||||
}
|
||||
}
|
||||
|
||||
logger.Debug("push item: ", item)
|
||||
items = append(items, item)
|
||||
}
|
||||
|
||||
|
|
|
@ -56,9 +56,19 @@ func PortCollect(p *model.PortCollect) {
|
|||
}
|
||||
|
||||
func isListening(port int, timeout int) bool {
|
||||
if isListen(port, timeout, "127.0.0.1") {
|
||||
return true
|
||||
}
|
||||
if isListen(port, timeout, identity.Identity) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isListen(port, timeout int, ip string) bool {
|
||||
var conn net.Conn
|
||||
var err error
|
||||
addr := fmt.Sprintf("127.0.0.1:%d", port)
|
||||
addr := fmt.Sprintf("%s:%d", ip, port)
|
||||
if timeout <= 0 {
|
||||
// default timeout 3 second
|
||||
timeout = 3
|
||||
|
|
Loading…
Reference in New Issue