Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into becca/apply-osq-wat…
Browse files Browse the repository at this point in the history
…chdog-opts
  • Loading branch information
RebeccaMahany committed Dec 12, 2023
2 parents 2070c93 + 05d4407 commit f6102b3
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 90 deletions.
8 changes: 4 additions & 4 deletions ee/agent/flags/flag_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ func (fc *FlagController) OsqueryVerbose() bool {
return NewBoolFlagValue(WithDefaultBool(fc.cmdLineOpts.OsqueryVerbose)).get(fc.getControlServerValue(keys.OsqueryVerbose))
}

func (fc *FlagController) SetEnableWatchdog(enable bool) error {
return fc.setControlServerValue(keys.EnableWatchdog, boolToBytes(enable))
func (fc *FlagController) SetWatchdogEnabled(enable bool) error {
return fc.setControlServerValue(keys.WatchdogEnabled, boolToBytes(enable))
}
func (fc *FlagController) EnableWatchdog() bool {
return NewBoolFlagValue(WithDefaultBool(fc.cmdLineOpts.EnableWatchdog)).get(fc.getControlServerValue(keys.EnableWatchdog))
func (fc *FlagController) WatchdogEnabled() bool {
return NewBoolFlagValue(WithDefaultBool(fc.cmdLineOpts.WatchdogEnabled)).get(fc.getControlServerValue(keys.WatchdogEnabled))
}

func (fc *FlagController) SetWatchdogDelaySec(sec int) error {
Expand Down
2 changes: 1 addition & 1 deletion ee/agent/flags/keys/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
Debug FlagKey = "debug"
DebugLogFile FlagKey = "debug_log_file"
OsqueryVerbose FlagKey = "osquery_verbose"
EnableWatchdog FlagKey = "enable_watchdog"
WatchdogEnabled FlagKey = "watchdog_enabled"
WatchdogDelaySec FlagKey = "watchdog_delay_sec"
WatchdogMemoryLimitMB FlagKey = "watchdog_memory_limit_mb"
WatchdogUtilizationLimitPercent FlagKey = "watchdog_utilization_limit_percent"
Expand Down
8 changes: 4 additions & 4 deletions ee/agent/knapsack/knapsack.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ func (k *knapsack) OsqueryVerbose() bool {
return k.flags.OsqueryVerbose()
}

func (k *knapsack) SetEnableWatchdog(enable bool) error {
return k.flags.SetEnableWatchdog(enable)
func (k *knapsack) SetWatchdogEnabled(enable bool) error {
return k.flags.SetWatchdogEnabled(enable)
}
func (k *knapsack) EnableWatchdog() bool {
return k.flags.EnableWatchdog()
func (k *knapsack) WatchdogEnabled() bool {
return k.flags.WatchdogEnabled()
}

func (k *knapsack) SetWatchdogDelaySec(sec int) error {
Expand Down
6 changes: 3 additions & 3 deletions ee/agent/types/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ type Flags interface {
SetOsqueryVerbose(verbose bool) error
OsqueryVerbose() bool

// EnableWatchdog enables the osquery watchdog
SetEnableWatchdog(enable bool) error
EnableWatchdog() bool
// WatchdogEnabled enables the osquery watchdog
SetWatchdogEnabled(enable bool) error
WatchdogEnabled() bool

// WatchdogDelaySec sets the number of seconds the watchdog will delay on startup before running
SetWatchdogDelaySec(sec int) error
Expand Down
56 changes: 28 additions & 28 deletions ee/agent/types/mocks/flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 28 additions & 28 deletions ee/agent/types/mocks/knapsack.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/launcher/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ type Options struct {
DebugLogFile string
// OsqueryVerbose puts osquery into verbose mode
OsqueryVerbose bool
// EnableWatchdog enables the osquery watchdog
EnableWatchdog bool
// WatchdogEnabled enables the osquery watchdog
WatchdogEnabled bool
// WatchdogDelaySec sets the number of seconds the watchdog will delay on startup before running
WatchdogDelaySec int
// WatchdogMemoryLimitMB sets the memory limit on osquery processes
Expand Down Expand Up @@ -221,7 +221,7 @@ func ParseOptions(subcommandName string, args []string) (*Options, error) {
flLoggingInterval = flagset.Duration("logging_interval", 60*time.Second, "The interval at which logs should be flushed to the server")
flOsquerydPath = flagset.String("osqueryd_path", "", "Path to the osqueryd binary to use (Default: find osqueryd in $PATH)")
flOsqueryHealthcheckStartupDelay = flagset.Duration("osquery_healthcheck_startup_delay", 10*time.Minute, "time to wait before beginning osquery healthchecks")
flEnableWatchdog = flagset.Bool("enable_watchdog", false, "Whether to enable the osquery watchdog")
flWatchdogEnabled = flagset.Bool("watchdog_enabled", false, "Whether to enable the osquery watchdog")
flWatchdogDelaySec = flagset.Int("watchdog_delay_sec", 120, "How many seconds to delay running watchdog after osquery startup")
flWatchdogMemoryLimitMB = flagset.Int("watchdog_memory_limit_mb", 600, "osquery memory utilization limit in MB")
flWatchdogUtilizationLimitPercent = flagset.Int("watchdog_utilization_limit_percent", 50, "osquery CPU utilization limit in percent")
Expand Down Expand Up @@ -389,7 +389,7 @@ func ParseOptions(subcommandName string, args []string) (*Options, error) {
DisableControlTLS: disableControlTLS,
InsecureControlTLS: insecureControlTLS,
EnableInitialRunner: *flInitialRunner,
EnableWatchdog: *flEnableWatchdog,
WatchdogEnabled: *flWatchdogEnabled,
EnrollSecret: *flEnrollSecret,
EnrollSecretPath: *flEnrollSecretPath,
ExportTraces: *flExportTraces,
Expand Down
2 changes: 1 addition & 1 deletion pkg/launcher/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func getArgsAndResponse() (map[string]string, *Options) {
UpdateChannel: "stable",
AutoloadedExtensions: []string{"some-extension.ext"},
DelayStart: 0 * time.Second,
EnableWatchdog: false,
WatchdogEnabled: false,
WatchdogDelaySec: 120,
WatchdogMemoryLimitMB: 600,
WatchdogUtilizationLimitPercent: 50,
Expand Down
2 changes: 1 addition & 1 deletion pkg/osquery/runtime/osqueryinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (o *OsqueryInstance) createOsquerydCommand(osquerydBinary string, paths *os
"--utc",
}

if o.knapsack != nil && o.knapsack.EnableWatchdog() {
if o.knapsack != nil && o.knapsack.WatchdogEnabled() {
args = append(args, fmt.Sprintf("--watchdog_memory_limit=%d", o.knapsack.WatchdogMemoryLimitMB()))
args = append(args, fmt.Sprintf("--watchdog_utilization_limit=%d", o.knapsack.WatchdogUtilizationLimitPercent()))
args = append(args, fmt.Sprintf("--watchdog_delay=%d", o.knapsack.WatchdogDelaySec()))
Expand Down
2 changes: 1 addition & 1 deletion pkg/osquery/runtime/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (r *Runner) Start(cancel context.CancelFunc) error {
return fmt.Errorf("starting instance: %w", err)
}
r.instance.knapsack.RegisterChangeObserver(r,
keys.EnableWatchdog, keys.WatchdogMemoryLimitMB, keys.WatchdogUtilizationLimitPercent, keys.WatchdogDelaySec,
keys.WatchdogEnabled, keys.WatchdogMemoryLimitMB, keys.WatchdogUtilizationLimitPercent, keys.WatchdogDelaySec,
)

go func() {
Expand Down
Loading

0 comments on commit f6102b3

Please sign in to comment.