diff --git a/crawler/health/ssh/SSHHealthCrawler.go b/crawler/health/ssh/SSHHealthCrawler.go index 69081ad..3a87ae5 100644 --- a/crawler/health/ssh/SSHHealthCrawler.go +++ b/crawler/health/ssh/SSHHealthCrawler.go @@ -1,6 +1,8 @@ package ssh import ( + "fmt" + "strings" "time" cnsms "git.loafle.net/commons/service_matcher-go/ssh" @@ -42,7 +44,10 @@ func (c *SSHHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, e return nil, err } elapsed := time.Since(start) - result[mci.Key] = elapsed.String() + if !strings.Contains(elapsed.String(), "ms") { + return nil, fmt.Errorf("Not valid data : %s", elapsed) + } + result[mci.Key] = strings.Split(elapsed.String(), "ms")[0] break default: break diff --git a/crawler/health/ssh/SSHHealthCrawler_test.go b/crawler/health/ssh/SSHHealthCrawler_test.go index d28fcbe..e3e3fac 100644 --- a/crawler/health/ssh/SSHHealthCrawler_test.go +++ b/crawler/health/ssh/SSHHealthCrawler_test.go @@ -11,14 +11,13 @@ import ( func TestMatch(t *testing.T) { config := &ocmsc.SensorConfig{} config.Connection = &ocmsc.SensorConfigConnection{ - MetaIPTypeKey: "V4", - IP: "192.168.1.111", - MetaPortTypeKey: "TCP", - Port: "22", - MetaCryptoTypeKey: "SSL", + MetaIPTypeKey: "V4", + IP: "192.168.1.103", + MetaPortTypeKey: "TCP", + Port: "22", } metaCollectionItem := &meta.MetaCollectionItem{ - Key: "service.health.response_time", + Key: "ssh.response_time", } config.MetaCollectionItems = make([]*meta.MetaCollectionItem, 1) config.MetaCollectionItems[0] = metaCollectionItem