Merge pull request #848 from ArtamonovEvgenii/master

Set relative default path for textfile collector
This commit is contained in:
Ben Reedy
2021-10-23 14:27:00 +10:00
committed by GitHub

View File

@@ -38,7 +38,7 @@ var (
textFileDirectory = kingpin.Flag(
"collector.textfile.directory",
"Directory to read text files with metrics from.",
).Default("C:\\Program Files\\windows_exporter\\textfile_inputs").String()
).Default(getDefaultPath()).String()
mtimeDesc = prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "textfile", "mtime_seconds"),
@@ -335,3 +335,8 @@ func checkBOM(encoding utfbom.Encoding) error {
return fmt.Errorf(encoding.String())
}
func getDefaultPath() string {
execPath, _ := os.Executable()
return filepath.Join(execPath, "textfile_inputs")
}