2017-04-13 03:43:39 +00:00
|
|
|
package collector_go
|
|
|
|
|
2017-04-14 10:09:51 +00:00
|
|
|
import (
|
2017-04-17 08:20:21 +00:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
conf "loafle.com/overflow/crawler_go/config"
|
2017-04-15 11:32:56 +00:00
|
|
|
"log"
|
2017-04-14 10:09:51 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
2017-04-13 03:43:39 +00:00
|
|
|
|
|
|
|
func TestCallGet(t *testing.T) {
|
2017-04-14 10:09:51 +00:00
|
|
|
c := Collector{}
|
|
|
|
c.Start()
|
2017-04-17 04:13:23 +00:00
|
|
|
time.Sleep(time.Second * 10)
|
2017-04-13 03:43:39 +00:00
|
|
|
|
2017-04-17 08:20:21 +00:00
|
|
|
//log.Println("add sensor")
|
|
|
|
//c.AddSensor("/network/smb/t2.conf")
|
|
|
|
//time.Sleep(time.Second * 3)
|
2017-04-15 11:32:56 +00:00
|
|
|
|
2017-04-17 08:20:21 +00:00
|
|
|
log.Println("update sensor")
|
|
|
|
c.UpdateSensor(newConf())
|
|
|
|
|
|
|
|
time.Sleep(time.Second * 30)
|
|
|
|
}
|
|
|
|
|
|
|
|
func newConf() *conf.Config {
|
|
|
|
bytes, err := ioutil.ReadFile("/config/container/network/smb/smb2.conf")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
conf := conf.Config{}
|
|
|
|
json.Unmarshal(bytes, &conf)
|
|
|
|
|
|
|
|
return &conf
|
2017-04-14 10:09:51 +00:00
|
|
|
}
|