...

Source file src/github.com/cybertec-postgresql/pgwatch/v3/internal/metrics/cmdopts.go

Documentation: github.com/cybertec-postgresql/pgwatch/v3/internal/metrics

     1  package metrics
     2  
     3  import (
     4  	"time"
     5  )
     6  
     7  // CmdOpts specifies metric command-line options
     8  type CmdOpts struct {
     9  	Metrics                      string `short:"m" long:"metrics" mapstructure:"metrics" description:"File or folder of YAML files with metrics definitions" env:"PW_METRICS"`
    10  	CreateHelpers                bool   `long:"create-helpers" mapstructure:"create-helpers" description:"Create helper database objects from metric definitions" env:"PW_CREATE_HELPERS"`
    11  	DirectOSStats                bool   `long:"direct-os-stats" mapstructure:"direct-os-stats" description:"Extract OS related psutil statistics not via PL/Python wrappers but directly on host" env:"PW_DIRECT_OS_STATS"`
    12  	InstanceLevelCacheMaxSeconds int64  `long:"instance-level-cache-max-seconds" mapstructure:"instance-level-cache-max-seconds" description:"Max allowed staleness for instance level metric data shared between DBs of an instance. Set to 0 to disable" env:"PW_INSTANCE_LEVEL_CACHE_MAX_SECONDS" default:"30"`
    13  	EmergencyPauseTriggerfile    string `long:"emergency-pause-triggerfile" mapstructure:"emergency-pause-triggerfile" description:"When the file exists no metrics will be temporarily fetched / scraped" env:"PW_EMERGENCY_PAUSE_TRIGGERFILE" default:"/tmp/pgwatch-emergency-pause"`
    14  }
    15  
    16  func (c CmdOpts) CacheAge() time.Duration {
    17  	if c.InstanceLevelCacheMaxSeconds < 0 {
    18  		c.InstanceLevelCacheMaxSeconds = 0
    19  	}
    20  	return time.Duration(c.InstanceLevelCacheMaxSeconds) * time.Second
    21  }
    22