remodeling

This commit is contained in:
jackdaw@loafle.com 2017-04-27 20:34:07 +09:00
parent d2ca696119
commit 297afd4dc1
6 changed files with 131 additions and 15 deletions

View File

@ -11,6 +11,7 @@ import (
"os" "os"
"strings" "strings"
"sync" "sync"
"fmt"
) )
type configManager struct { type configManager struct {
@ -19,7 +20,7 @@ type configManager struct {
addCh chan interface{} addCh chan interface{}
removeCh chan interface{} removeCh chan interface{}
configs map[string]*config_manager.Config configs map[string] *config_manager.Config
globalConfig config_manager.GlobalConfig globalConfig config_manager.GlobalConfig
} }
@ -190,6 +191,6 @@ func (c *configManager) GetGlobalConfig() *config_manager.GlobalConfig {
func (c *configManager) GetCrawlerById(id string) *config_manager.Config { func (c *configManager) GetCrawlerById(id string) *config_manager.Config {
return c.configs[id] 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 return c.configs
} }

View File

@ -22,6 +22,13 @@ func TestLoadConfig(t *testing.T) {
data :=<- ch data :=<- ch
c := data.(config_manager.ConfigManager) c := data.(config_manager.ConfigManager)
cc := c.GetCrawlers() 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) assert.NotEqual(t, len(cc),0)
}() }()

View File

@ -8,8 +8,11 @@
"portType" : "tcp" "portType" : "tcp"
}, },
"auth" : { "auth" : {
"url":"jdbc:sqlserver://192.168.1.106:1433;",
} "id":"sa",
"pw":"qwe123",
"query" : "select * from master.dbo.sysprocesses"
}
}, },
"schedule" : { "schedule" : {
"interval" : "10" "interval" : "10"
@ -18,6 +21,30 @@
"name":"redis", "name":"redis",
"container":"java_proxy" "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"
}
}
]
} }

View File

@ -8,8 +8,11 @@
"portType" : "tcp" "portType" : "tcp"
}, },
"auth" : { "auth" : {
"url":"jdbc:sqlserver://192.168.1.106:1433;",
} "id":"sa",
"pw":"qwe123",
"query" : "select * from master.dbo.sysprocesses"
}
}, },
"schedule" : { "schedule" : {
"interval" : "10" "interval" : "10"
@ -19,5 +22,29 @@
"container":"java_proxy" "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"
}
}
]
} }

View File

@ -8,8 +8,11 @@
"portType" : "tcp" "portType" : "tcp"
}, },
"auth" : { "auth" : {
"url":"jdbc:sqlserver://192.168.1.106:1433;",
} "id":"sa",
"pw":"qwe123",
"query" : "select * from master.dbo.sysprocesses"
}
}, },
"schedule" : { "schedule" : {
"interval" : "10" "interval" : "10"
@ -19,5 +22,29 @@
"container":"network_proxy" "container":"network_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"
}
}
]
} }

View File

@ -2,13 +2,16 @@
"id" : "123980918237", "id" : "123980918237",
"target" : { "target" : {
"connection" : { "connection" : {
"ip" : "192.168.1.104", "ip" : "192.168.1.103",
"port" : "6379", "port" : "1433",
"ssl" : false, "ssl" : false,
"portType" : "tcp" "portType" : "tcp"
}, },
"auth" : { "auth" : {
"url":"jdbc:sqlserver://192.168.1.106:1433;",
"id":"sa",
"pw":"qwe123",
"query" : "select * from master.dbo.sysprocesses"
} }
}, },
"schedule" : { "schedule" : {
@ -19,5 +22,29 @@
"container":"network_proxy" "container":"network_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"
}
}
] ]
} }