Skip to content

Commit

Permalink
support monitored-directories arg
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed May 6, 2022
1 parent 31f4c9e commit 2822501
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ var rootCmd = &cobra.Command{
}

var (
cfgFile string
config *exporter.Config
export exporter.Exporter
ctx context.Context
logr logrus.FieldLogger
executionUrl string
consensusUrl string
cfgFile string
config *exporter.Config
export exporter.Exporter
ctx context.Context
logr logrus.FieldLogger
executionUrl string
consensusUrl string
monitoredDirectories []string
)

// Execute adds all child commands to the root command and sets flags appropriately.
Expand All @@ -55,6 +56,7 @@ func init() {
rootCmd.PersistentFlags().IntVarP(&metricsPort, "metrics-port", "", 9090, "Port to serve Prometheus metrics on")
rootCmd.PersistentFlags().StringVarP(&executionUrl, "execution-url", "", "", "(optional) URL to the execution node")
rootCmd.PersistentFlags().StringVarP(&consensusUrl, "consensus-url", "", "", "(optional) URL to the consensus node")
rootCmd.PersistentFlags().StringSliceVarP(&monitoredDirectories, "monitored-directories", "", []string{}, "(optional) directories to monitor for disk usage")

// Cobra also supports local flags, which will only run
// when this action is called directly.
Expand Down Expand Up @@ -101,6 +103,11 @@ func initCommon() {
config.Consensus.URL = consensusUrl
}

if len(monitoredDirectories) > 0 {
config.DiskUsage.Enabled = true
config.DiskUsage.Directories = monitoredDirectories
}

export = exporter.NewExporter(log, config)
if err := export.Init(ctx); err != nil {
logrus.Fatal(err)
Expand Down

0 comments on commit 2822501

Please sign in to comment.