diff --git a/config_manager.go b/config_manager.go index b193005..57a1499 100644 --- a/config_manager.go +++ b/config_manager.go @@ -11,6 +11,7 @@ import ( "os" "strings" "sync" + "fmt" ) type configManager struct { @@ -19,7 +20,7 @@ type configManager struct { addCh chan interface{} removeCh chan interface{} - configs map[string]*config_manager.Config + configs map[string] *config_manager.Config globalConfig config_manager.GlobalConfig } @@ -190,6 +191,6 @@ func (c *configManager) GetGlobalConfig() *config_manager.GlobalConfig { func (c *configManager) GetCrawlerById(id string) *config_manager.Config { return c.configs[id] } -func (c *configManager) GetCrawlers() map[string]*config_manager.Config { +func (c *configManager) GetCrawlers() map[string] *config_manager.Config { return c.configs } diff --git a/config_manager_test.go b/config_manager_test.go index 5c7ce95..5a2836b 100644 --- a/config_manager_test.go +++ b/config_manager_test.go @@ -22,6 +22,13 @@ func TestLoadConfig(t *testing.T) { data :=<- ch c := data.(config_manager.ConfigManager) cc := c.GetCrawlers() + + //ccc := cc["75045c53-a78d-4589-b8c1-4482cab720b6"] + // + //mmmm := ccc.Items[0].Keys[0].Metric + // + //fmt.Println(mmmm) + // assert.NotEqual(t, len(cc),0) }() diff --git a/test_agent/config/container/java_proxy/redis/736387363 b/test_agent/config/container/java_proxy/redis/736387363 index 0186fa9..23d6104 100644 --- a/test_agent/config/container/java_proxy/redis/736387363 +++ b/test_agent/config/container/java_proxy/redis/736387363 @@ -8,8 +8,11 @@ "portType" : "tcp" }, "auth" : { - - } + "url":"jdbc:sqlserver://192.168.1.106:1433;", + "id":"sa", + "pw":"qwe123", + "query" : "select * from master.dbo.sysprocesses" + } }, "schedule" : { "interval" : "10" @@ -18,6 +21,30 @@ "name":"redis", "container":"java_proxy" }, - "items" : [ - ] + "items" : [ + { + "keys" : [ + { + "metric" : "object[$0].db[$1].datafile_size", + "key" : "Data File(s) Size (KB)" + }, + { + "metric" : "object[$0].db[$1].logfile_size", + "key" : "Log File(s) Size (KB)" + } + ], + "queryInfo" : { + "query": "select object_name,instance_name, counter_name, cntr_value from sys.dm_os_performance_counters where ( counter_name = 'Data File(s) Size (KB)' or counter_name = 'Log File(s) Size (KB)' ) AND object_name = 'SQLServer:Databases'", + "extend" : { + "test":"test" + } + }, + "mappingInfo" : { + "parseDirection" : "row", + "arrayColumns" : [ "object_name","instance_name"], + "keyColumns" : ["counter_name"], + "valueColumn" : "cntr_value" + } + } + ] } \ No newline at end of file diff --git a/test_agent/config/container/java_proxy/sql/989238744 b/test_agent/config/container/java_proxy/sql/989238744 index c8e3608..230285c 100644 --- a/test_agent/config/container/java_proxy/sql/989238744 +++ b/test_agent/config/container/java_proxy/sql/989238744 @@ -8,8 +8,11 @@ "portType" : "tcp" }, "auth" : { - - } + "url":"jdbc:sqlserver://192.168.1.106:1433;", + "id":"sa", + "pw":"qwe123", + "query" : "select * from master.dbo.sysprocesses" + } }, "schedule" : { "interval" : "10" @@ -19,5 +22,29 @@ "container":"java_proxy" }, "items" : [ - ] + { + "keys" : [ + { + "metric" : "object[$0].db[$1].datafile_size", + "key" : "Data File(s) Size (KB)" + }, + { + "metric" : "object[$0].db[$1].logfile_size", + "key" : "Log File(s) Size (KB)" + } + ], + "queryInfo" : { + "query": "select object_name,instance_name, counter_name, cntr_value from sys.dm_os_performance_counters where ( counter_name = 'Data File(s) Size (KB)' or counter_name = 'Log File(s) Size (KB)' ) AND object_name = 'SQLServer:Databases'", + "extend" : { + "test":"test" + } + }, + "mappingInfo" : { + "parseDirection" : "row", + "arrayColumns" : [ "object_name","instance_name"], + "keyColumns" : ["counter_name"], + "valueColumn" : "cntr_value" + } + } + ] } \ No newline at end of file diff --git a/test_agent/config/container/network_proxy/health_activedirectory/123980918237 b/test_agent/config/container/network_proxy/health_activedirectory/123980918237 index f23d294..45ab6ed 100644 --- a/test_agent/config/container/network_proxy/health_activedirectory/123980918237 +++ b/test_agent/config/container/network_proxy/health_activedirectory/123980918237 @@ -8,8 +8,11 @@ "portType" : "tcp" }, "auth" : { - - } + "url":"jdbc:sqlserver://192.168.1.106:1433;", + "id":"sa", + "pw":"qwe123", + "query" : "select * from master.dbo.sysprocesses" + } }, "schedule" : { "interval" : "10" @@ -19,5 +22,29 @@ "container":"network_proxy" }, "items" : [ - ] + { + "keys" : [ + { + "metric" : "object[$0].db[$1].datafile_size", + "key" : "Data File(s) Size (KB)" + }, + { + "metric" : "object[$0].db[$1].logfile_size", + "key" : "Log File(s) Size (KB)" + } + ], + "queryInfo" : { + "query": "select object_name,instance_name, counter_name, cntr_value from sys.dm_os_performance_counters where ( counter_name = 'Data File(s) Size (KB)' or counter_name = 'Log File(s) Size (KB)' ) AND object_name = 'SQLServer:Databases'", + "extend" : { + "test":"test" + } + }, + "mappingInfo" : { + "parseDirection" : "row", + "arrayColumns" : [ "object_name","instance_name"], + "keyColumns" : ["counter_name"], + "valueColumn" : "cntr_value" + } + } + ] } \ No newline at end of file diff --git a/test_agent/test.json b/test_agent/test.json index f23d294..3bce50f 100644 --- a/test_agent/test.json +++ b/test_agent/test.json @@ -2,13 +2,16 @@ "id" : "123980918237", "target" : { "connection" : { - "ip" : "192.168.1.104", - "port" : "6379", + "ip" : "192.168.1.103", + "port" : "1433", "ssl" : false, "portType" : "tcp" }, "auth" : { - + "url":"jdbc:sqlserver://192.168.1.106:1433;", + "id":"sa", + "pw":"qwe123", + "query" : "select * from master.dbo.sysprocesses" } }, "schedule" : { @@ -19,5 +22,29 @@ "container":"network_proxy" }, "items" : [ + { + "keys" : [ + { + "metric" : "object[$0].db[$1].datafile_size", + "key" : "Data File(s) Size (KB)" + }, + { + "metric" : "object[$0].db[$1].logfile_size", + "key" : "Log File(s) Size (KB)" + } + ], + "queryInfo" : { + "query": "select object_name,instance_name, counter_name, cntr_value from sys.dm_os_performance_counters where ( counter_name = 'Data File(s) Size (KB)' or counter_name = 'Log File(s) Size (KB)' ) AND object_name = 'SQLServer:Databases'", + "extend" : { + "test":"test" + } + }, + "mappingInfo" : { + "parseDirection" : "row", + "arrayColumns" : [ "object_name","instance_name"], + "keyColumns" : ["counter_name"], + "valueColumn" : "cntr_value" + } + } ] } \ No newline at end of file