mirror of
https://codeberg.org/scip/io-exporter.git
synced 2025-12-17 04:21:00 +01:00
make sleep time configurable
This commit is contained in:
@@ -19,10 +19,11 @@ const (
|
|||||||
SLEEP = 5
|
SLEEP = 5
|
||||||
Usage = `io-exporter [options] <file>
|
Usage = `io-exporter [options] <file>
|
||||||
Options:
|
Options:
|
||||||
-t --timeout <int> When should the operation timeout in seconds
|
-t --timeout <int> When should the operation timeout in seconds
|
||||||
-l --label <label=value> Add label to exported metric
|
-s --sleeptime <int> Time to sleep between checks (default: 5s)
|
||||||
-h --help Show help
|
-l --label <label=value> Add label to exported metric
|
||||||
-v --version Show program version`
|
-h --help Show help
|
||||||
|
-v --version Show program version`
|
||||||
)
|
)
|
||||||
|
|
||||||
// config via commandline flags
|
// config via commandline flags
|
||||||
@@ -32,6 +33,7 @@ type Config struct {
|
|||||||
Label []string `koanf:"label"` // -v
|
Label []string `koanf:"label"` // -v
|
||||||
Timeout int `koanf:"timeout"` // -t
|
Timeout int `koanf:"timeout"` // -t
|
||||||
Port int `koanf:"port"` // -p
|
Port int `koanf:"port"` // -p
|
||||||
|
Sleeptime int `koanf:"sleep"` // -s
|
||||||
|
|
||||||
File string
|
File string
|
||||||
Labels []Label
|
Labels []Label
|
||||||
@@ -55,6 +57,7 @@ func InitConfig(output io.Writer) (*Config, error) {
|
|||||||
flagset.StringArrayP("label", "l", nil, "additional labels")
|
flagset.StringArrayP("label", "l", nil, "additional labels")
|
||||||
flagset.IntP("timeout", "t", 1, "timeout for file operation in seconds")
|
flagset.IntP("timeout", "t", 1, "timeout for file operation in seconds")
|
||||||
flagset.IntP("port", "p", 9187, "prometheus metrics port to listen to")
|
flagset.IntP("port", "p", 9187, "prometheus metrics port to listen to")
|
||||||
|
flagset.IntP("sleeptime", "s", 5, "time to sleep between checks (default: 5s)")
|
||||||
|
|
||||||
if err := flagset.Parse(os.Args[1:]); err != nil {
|
if err := flagset.Parse(os.Args[1:]); err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse program arguments: %w", err)
|
return nil, fmt.Errorf("failed to parse program arguments: %w", err)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func Run() {
|
|||||||
|
|
||||||
metrics.Set(result, elapsed)
|
metrics.Set(result, elapsed)
|
||||||
|
|
||||||
time.Sleep(SLEEP * time.Second)
|
time.Sleep(time.Duration(conf.Sleeptime) * time.Second)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user