code refactor

This commit is contained in:
Ulric Qin 2022-04-19 19:05:16 +08:00
parent 26d4bf1195
commit 1305b80f72
5 changed files with 20 additions and 13 deletions

View File

@ -1,11 +1,11 @@
# # collect interval
# interval = 15
[[instances]]
# commands, support glob
commands = [
"/opt/categraf/scripts/*.sh"
]
# [[instances]]
# # commands, support glob
# commands = [
# "/opt/categraf/scripts/*.sh"
# ]
# # timeout for each command to complete
# timeout = 5

View File

@ -1,14 +1,14 @@
# # collect interval
# interval = 15
[[instances]]
address = "10.1.2.3:1521/orcl"
username = "monitor"
password = "123456"
is_sys_dba = false
is_sys_oper = false
disable_connection_pool = false
max_open_connections = 5
# [[instances]]
# address = "10.1.2.3:1521/orcl"
# username = "monitor"
# password = "123456"
# is_sys_dba = false
# is_sys_oper = false
# disable_connection_pool = false
# max_open_connections = 5
# # interval = global.interval * interval_times
# interval_times = 1
# labels = { region="cloud" }

View File

@ -58,6 +58,10 @@ func (e *Exec) GetInterval() config.Duration {
}
func (e *Exec) Init() error {
if len(e.Instances) == 0 {
return fmt.Errorf("exec instances empty")
}
for i := 0; i < len(e.Instances); i++ {
if e.Instances[i].DataFormat == "" || e.Instances[i].DataFormat == "influx" {
e.Instances[i].parser = influx.NewSeriesParser()

View File

@ -76,6 +76,9 @@ func (o *Oracle) Init() error {
o.dbconnpool = make(map[string]*sqlx.DB)
for i := 0; i < len(o.Instances); i++ {
dbConf := o.Instances[i]
if dbConf.Address == "" {
return fmt.Errorf("some oracle address is blank")
}
connString := getConnectionString(dbConf)
db, err := sqlx.Open("godror", connString)
if err != nil {