This commit is contained in:
insanity 2018-07-05 17:33:10 +09:00
parent 6fa01a3e43
commit 6c5db94606
2 changed files with 11 additions and 7 deletions

View File

@ -1,6 +1,8 @@
package ssh package ssh
import ( import (
"fmt"
"strings"
"time" "time"
cnsms "git.loafle.net/commons/service_matcher-go/ssh" 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 return nil, err
} }
elapsed := time.Since(start) 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 break
default: default:
break break

View File

@ -12,13 +12,12 @@ func TestMatch(t *testing.T) {
config := &ocmsc.SensorConfig{} config := &ocmsc.SensorConfig{}
config.Connection = &ocmsc.SensorConfigConnection{ config.Connection = &ocmsc.SensorConfigConnection{
MetaIPTypeKey: "V4", MetaIPTypeKey: "V4",
IP: "192.168.1.111", IP: "192.168.1.103",
MetaPortTypeKey: "TCP", MetaPortTypeKey: "TCP",
Port: "22", Port: "22",
MetaCryptoTypeKey: "SSL",
} }
metaCollectionItem := &meta.MetaCollectionItem{ metaCollectionItem := &meta.MetaCollectionItem{
Key: "service.health.response_time", Key: "ssh.response_time",
} }
config.MetaCollectionItems = make([]*meta.MetaCollectionItem, 1) config.MetaCollectionItems = make([]*meta.MetaCollectionItem, 1)
config.MetaCollectionItems[0] = metaCollectionItem config.MetaCollectionItems[0] = metaCollectionItem