This commit is contained in:
crusader 2017-12-14 15:29:03 +09:00
parent 900a5c42dd
commit 6d2a0d64e0
2 changed files with 161 additions and 0 deletions

View File

@ -0,0 +1,39 @@
package ssh
import (
"encoding/json"
"io/ioutil"
"log"
"testing"
configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model"
"git.loafle.net/overflow/overflow_probe_container_network/crawler"
"github.com/stretchr/testify/assert"
)
func setConfig() crawler.Crawler {
config := &configM.Config{}
data, err := ioutil.ReadFile("./SSHCrawler_test.json")
if err != nil {
log.Fatal(err)
}
err = json.Unmarshal(data, config)
if err != nil {
log.Fatal(err)
}
c := NewCrawler().(*SSHCrawler)
c.PutConfig("c", config)
return c
}
func TestMatch(t *testing.T) {
// test config
c := setConfig()
rss, err := c.Get("c")
assert.Nil(t, err)
assert.NotNil(t, rss)
}

View File

@ -0,0 +1,122 @@
{
"id": "99",
"target": {
"auth": {
"pw": "!@#$qwer1234",
"id": "administrator"
},
"connection": {
"ip": "192.168.1.15",
"port": "22",
"portType": "tcp",
"ssl": false
}
},
"schedule": {
"interval": "5"
},
"crawler": {
"name": "SSH_CRAWLER",
"container": "go_proxy"
},
"items": [{
"keys": [{
"metric": "cpu.usage.sum",
"key": "sum"
},
{
"metric": "cpu.usage.user",
"key": "user"
},
{
"metric": "cpu.usage.nice",
"key": "nice"
},
{
"metric": "cpu.usage.system",
"key": "system"
},
{
"metric": "cpu.usage.iowait",
"key": "iowait"
},
{
"metric": "cpu.usage.irq",
"key": "irq"
},
{
"metric": "cpu.usage.softirq",
"key": "softirq"
},
{
"metric": "cpu.usage.steal",
"key": "steal"
},
{
"metric": "cpu.usage.guest",
"key": "guest"
},
{
"metric": "cpu.usage.gnice",
"key": "gnice"
}],
"queryInfo": {
"query": "cat /proc/stat",
"extend": {
"mode" : "cpu"
}
},
"mappingInfo": {
"parseDirection": null,
"arrayColumns": null,
"keyColumns": null,
"valueColumn": null
}
},
{
"keys": [{
"metric": "mem.usage.total",
"key": "MemTotal"
},
{
"metric": "mem.usage.free",
"key": "MemFree"
},
{
"metric": "mem.usage.available",
"key": "MemAvailable"
},
{
"metric": "mem.usage.buffers",
"key": "Buffers"
},
{
"metric": "mem.usage.cached",
"key": "Cached"
},
{
"metric": "mem.swap.usage.total",
"key": "SwapTotal"
},
{
"metric": "mem.swap.usage.free",
"key": "SwapFree"
},
{
"metric": "mem.swap.usage.cached",
"key": "SwapCached"
}],
"queryInfo": {
"query": "cat /proc/meminfo",
"extend": {
"mode": "mem"
}
},
"mappingInfo": {
"parseDirection": null,
"arrayColumns": null,
"keyColumns": null,
"valueColumn": null
}
}]
}