From d0cfc14af9f1f2b762a4d3f98a55ac52e13d2153 Mon Sep 17 00:00:00 2001 From: eartamonov Date: Sun, 3 Oct 2021 21:12:36 +0300 Subject: [PATCH] Set relative default path for textfile collector Signed-off-by: Artamonov Evgenii --- collector/textfile.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/collector/textfile.go b/collector/textfile.go index 7be1a016..0a874923 100644 --- a/collector/textfile.go +++ b/collector/textfile.go @@ -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") +}