add some test log
This commit is contained in:
parent
13cbec7711
commit
519b555c23
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"flashcat.cloud/categraf/pkg/cfg"
|
||||
|
@ -57,20 +56,15 @@ type ConfigType struct {
|
|||
|
||||
var Config *ConfigType
|
||||
|
||||
func InitConfig(configDir, debugMode string, testMode bool) error {
|
||||
func InitConfig(configDir string, debugMode bool, testMode bool) error {
|
||||
configFile := path.Join(configDir, "config.toml")
|
||||
if !file.IsExist(configFile) {
|
||||
return fmt.Errorf("configuration file(%s) not found", configFile)
|
||||
}
|
||||
|
||||
debug, err := strconv.ParseBool(debugMode)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse bool(%s): %v", debugMode, err)
|
||||
}
|
||||
|
||||
Config = &ConfigType{
|
||||
ConfigDir: configDir,
|
||||
DebugMode: debug,
|
||||
DebugMode: debugMode,
|
||||
TestMode: testMode,
|
||||
}
|
||||
|
||||
|
|
|
@ -234,9 +234,11 @@ func (o *Oracle) parseRow(row map[string]string, metricConf MetricConfig, slist
|
|||
}
|
||||
|
||||
if metricConf.FieldToAppend == "" {
|
||||
log.Println(metricConf.Mesurement+"_"+column, value, labels)
|
||||
slist.PushFront(inputs.NewSample(metricConf.Mesurement+"_"+column, value, labels))
|
||||
} else {
|
||||
suffix := cleanName(row[metricConf.FieldToAppend])
|
||||
log.Println(metricConf.Mesurement+"_"+suffix+"_"+column, value, labels)
|
||||
slist.PushFront(inputs.NewSample(metricConf.Mesurement+"_"+suffix+"_"+column, value, labels))
|
||||
}
|
||||
}
|
||||
|
|
2
main.go
2
main.go
|
@ -19,7 +19,7 @@ import (
|
|||
var (
|
||||
version = "0.0.1"
|
||||
configDir = flag.String("configs", osx.GetEnv("CATEGRAF_CONFIGS", "conf"), "Specify configuration directory.(env:CATEGRAF_CONFIGS)")
|
||||
debugMode = flag.String("debug", osx.GetEnv("CATEGRAF_DEBUG", "false"), "Is debug mode?.(env:CATEGRAF_DEBUG)")
|
||||
debugMode = flag.Bool("debug", false, "Is debug mode?")
|
||||
testMode = flag.Bool("test", false, "Is test mode? print metrics to stdout")
|
||||
showVersion = flag.Bool("version", false, "Show version.")
|
||||
inputFilters = flag.String("input-filter", "", "e.g. cpu:mem:system")
|
||||
|
|
Loading…
Reference in New Issue