sql problem has solved
This commit is contained in:
parent
ca5d24c9a0
commit
36751de2f7
|
@ -9,7 +9,6 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
)
|
||||
|
||||
type configManager struct {
|
||||
|
@ -33,7 +32,6 @@ func GetInstance() *configManager {
|
|||
|
||||
func (c *configManager) stop() {}
|
||||
|
||||
|
||||
func (c *configManager) getConfigPath() string {
|
||||
return c.globalConfig.Paths.RootFolder + c.globalConfig.Paths.ConfigFolder
|
||||
}
|
||||
|
@ -46,8 +44,6 @@ func (c *configManager) getConfigFilePath(config *config_manager.Config) string
|
|||
return c.getContainerPath() + appendSeperator(config.Crawler.Container) + appendSeperator(config.Crawler.Name) + config.Id
|
||||
}
|
||||
|
||||
|
||||
|
||||
func appendSeperator(str string) string {
|
||||
if strings.LastIndex(str, "/") != len(str)-1 {
|
||||
return str + "/"
|
||||
|
@ -157,7 +153,7 @@ func (c *configManager) removeConfig(id string) {
|
|||
// check exists
|
||||
config, ok := c.configs[removeid]
|
||||
if !ok {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
// 해당 파일 삭제
|
||||
|
@ -179,8 +175,6 @@ func (c *configManager) removeConfig(id string) {
|
|||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// implements methods
|
||||
func (c *configManager) GetGlobalConfig() *config_manager.GlobalConfig {
|
||||
return &c.globalConfig
|
||||
|
|
|
@ -3,13 +3,13 @@ package config_manager_go
|
|||
import (
|
||||
"testing"
|
||||
//"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"loafle.com/overflow/agent_api/config_manager"
|
||||
"encoding/json"
|
||||
"github.com/google/uuid"
|
||||
"loafle.com/overflow/agent_api/observer"
|
||||
"io/ioutil"
|
||||
"loafle.com/overflow/agent_api/config_manager"
|
||||
"loafle.com/overflow/agent_api/messages"
|
||||
"loafle.com/overflow/agent_api/observer"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -35,7 +35,6 @@ func TestLoadConfig(t *testing.T) {
|
|||
//time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
|
||||
func TestAddConfig(t *testing.T) {
|
||||
_configManager.loadGlobalConfig("/root/gowork/src/loafle.com/overflow/config_manager_go/test_agent/global.yaml")
|
||||
|
||||
|
@ -58,7 +57,6 @@ func TestAddConfig(t *testing.T) {
|
|||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
|
||||
func TestRemoveConfig(t *testing.T) {
|
||||
GetInstance()
|
||||
_configManager.loadGlobalConfig("/home/snoop/develop/path/go/src/loafle.com/overflow/config_manager_go/test_agent/global.yaml")
|
||||
|
|
|
@ -2,7 +2,6 @@ package config_manager_go
|
|||
|
||||
import (
|
||||
"loafle.com/overflow/agent_api/config_manager"
|
||||
|
||||
)
|
||||
|
||||
//import (
|
||||
|
@ -11,10 +10,6 @@ import (
|
|||
//)
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func Start(ch chan *config_manager.GlobalConfig, path string) error {
|
||||
_configManager = GetInstance()
|
||||
_configManager.loadGlobalConfig(path + "/" + "global.yaml")
|
||||
|
@ -35,7 +30,6 @@ func Stop(ch chan bool) {
|
|||
ch <- true
|
||||
}
|
||||
|
||||
|
||||
func AddSensor(tmpFilePath string) {
|
||||
|
||||
GetInstance().addConfig(tmpFilePath)
|
||||
|
@ -67,12 +61,10 @@ func RemoveSensor(id string) {
|
|||
|
||||
GetInstance().removeConfig(id)
|
||||
|
||||
|
||||
}
|
||||
|
||||
func UpdateSensor(tmpFile string) {
|
||||
|
||||
|
||||
//GetInstance().
|
||||
|
||||
//overwrite file
|
||||
|
@ -82,14 +74,6 @@ func UpdateSensor(tmpFile string) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//func agentStartHandler() {
|
||||
// agentStart := make(chan interface{}, 0)
|
||||
// observer.Add(messages.AGT_STARTING, agentStart)
|
||||
|
@ -129,5 +113,3 @@ func UpdateSensor(tmpFile string) {
|
|||
// observer.Add(messages.TASK_SENSOR_REMOVE,_configManager.removeCh)
|
||||
// go _configManager.removeConfig()
|
||||
//}
|
||||
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
{
|
||||
"keys" : [
|
||||
{
|
||||
"metric":"net.connection_count",
|
||||
"metric":"net.mysql.connection_count",
|
||||
"key":"Connections"
|
||||
}
|
||||
|
||||
],
|
||||
"queryInfo" : {
|
||||
"query":"show status where `variable_name` = 'Connections'"
|
||||
"query":"show status where variable_name = 'Connections'"
|
||||
},
|
||||
"mappingInfo" : {
|
||||
"parseDirection" : "row",
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
}
|
||||
},
|
||||
"schedule" : {
|
||||
"interval" : "5"
|
||||
"interval" : "10"
|
||||
},
|
||||
"crawler" : {
|
||||
"name":"SQL",
|
||||
|
@ -24,8 +24,8 @@
|
|||
{
|
||||
"keys" : [
|
||||
{
|
||||
"metric" :"net.connection_count",
|
||||
"key" : "Connections"
|
||||
"metric" :"net.sqlserver.connection_count",
|
||||
"key" : "connection_count"
|
||||
}
|
||||
],
|
||||
"queryInfo" : {
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
"id" : "989238744",
|
||||
"target" : {
|
||||
"connection" : {
|
||||
"ip" : "192.168.1.107",
|
||||
"ip" : "192.168.1.106",
|
||||
"port" : "5432",
|
||||
"ssl" : false,
|
||||
"portType" : "tcp"
|
||||
},
|
||||
"auth" : {
|
||||
"url":"jdbc:postgresql://192.168.1.107:5432/postgres",
|
||||
"id":"postgres",
|
||||
"pw":"!@#$qwer1234"
|
||||
"url":"jdbc:postgresql://192.168.1.106:5432/postgres",
|
||||
"id":"vertx",
|
||||
"pw":"qwe123"
|
||||
}
|
||||
},
|
||||
"schedule" : {
|
||||
"interval" : "10"
|
||||
"interval" : "3"
|
||||
},
|
||||
"crawler" : {
|
||||
"name":"SQL",
|
||||
|
@ -24,13 +24,14 @@
|
|||
{
|
||||
"keys" : [
|
||||
{
|
||||
"metric":"net.connection_count",
|
||||
"metric":"net.pgsql.connection_count",
|
||||
"key" : "connection_count"
|
||||
}
|
||||
],
|
||||
"queryInfo":{
|
||||
"query" : "select count(pid) as connection_count from pg_catalog.pg_stat_activity where state <> 'idle'"
|
||||
}
|
||||
"query" : "select count(pid) as connection_count from pg_catalog.pg_stat_activity where state <> 'idle';"
|
||||
},
|
||||
"mappingInfo" : {}
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user