diff --git a/cmd/launcher/extension.go b/cmd/launcher/extension.go index 711ae363f..d3a2498c7 100644 --- a/cmd/launcher/extension.go +++ b/cmd/launcher/extension.go @@ -215,7 +215,7 @@ func commonRunnerOptions(logger log.Logger, k types.Knapsack) []runtime.OsqueryI runtime.WithAutoloadedExtensions(k.AutoloadedExtensions()...), runtime.WithUpdateDirectory(k.UpdateDirectory()), runtime.WithUpdateChannel(k.UpdateChannel()), - runtime.WithEnableWatchdog(k.EnableWatchdog()), + runtime.WithEnableWatchdog(k.WatchdogEnabled()), } } diff --git a/ee/agent/flags/flag_controller.go b/ee/agent/flags/flag_controller.go index d352d8903..f39c099f2 100644 --- a/ee/agent/flags/flag_controller.go +++ b/ee/agent/flags/flag_controller.go @@ -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 { diff --git a/ee/agent/flags/keys/keys.go b/ee/agent/flags/keys/keys.go index 437f0ebea..470c85185 100644 --- a/ee/agent/flags/keys/keys.go +++ b/ee/agent/flags/keys/keys.go @@ -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" diff --git a/ee/agent/knapsack/knapsack.go b/ee/agent/knapsack/knapsack.go index 3f2ef8a68..21a68bf8e 100644 --- a/ee/agent/knapsack/knapsack.go +++ b/ee/agent/knapsack/knapsack.go @@ -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 { diff --git a/ee/agent/types/flags.go b/ee/agent/types/flags.go index 5f6107f4b..78843f47f 100644 --- a/ee/agent/types/flags.go +++ b/ee/agent/types/flags.go @@ -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 diff --git a/ee/agent/types/mocks/flags.go b/ee/agent/types/mocks/flags.go index d8fd68662..63a4bfad0 100644 --- a/ee/agent/types/mocks/flags.go +++ b/ee/agent/types/mocks/flags.go @@ -244,20 +244,6 @@ func (_m *Flags) EnableInitialRunner() bool { return r0 } -// EnableWatchdog provides a mock function with given fields: -func (_m *Flags) EnableWatchdog() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - // EnrollSecret provides a mock function with given fields: func (_m *Flags) EnrollSecret() string { ret := _m.Called() @@ -865,20 +851,6 @@ func (_m *Flags) SetDisableTraceIngestTLS(enabled bool) error { return r0 } -// SetEnableWatchdog provides a mock function with given fields: enable -func (_m *Flags) SetEnableWatchdog(enable bool) error { - ret := _m.Called(enable) - - var r0 error - if rf, ok := ret.Get(0).(func(bool) error); ok { - r0 = rf(enable) - } else { - r0 = ret.Error(0) - } - - return r0 -} - // SetExportTraces provides a mock function with given fields: enabled func (_m *Flags) SetExportTraces(enabled bool) error { ret := _m.Called(enabled) @@ -1202,6 +1174,20 @@ func (_m *Flags) SetWatchdogDelaySec(sec int) error { return r0 } +// SetWatchdogEnabled provides a mock function with given fields: enable +func (_m *Flags) SetWatchdogEnabled(enable bool) error { + ret := _m.Called(enable) + + var r0 error + if rf, ok := ret.Get(0).(func(bool) error); ok { + r0 = rf(enable) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // SetWatchdogMemoryLimitMB provides a mock function with given fields: limit func (_m *Flags) SetWatchdogMemoryLimitMB(limit int) error { ret := _m.Called(limit) @@ -1342,6 +1328,20 @@ func (_m *Flags) WatchdogDelaySec() int { return r0 } +// WatchdogEnabled provides a mock function with given fields: +func (_m *Flags) WatchdogEnabled() bool { + ret := _m.Called() + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + // WatchdogMemoryLimitMB provides a mock function with given fields: func (_m *Flags) WatchdogMemoryLimitMB() int { ret := _m.Called() diff --git a/ee/agent/types/mocks/knapsack.go b/ee/agent/types/mocks/knapsack.go index a91a33e8d..0772a47b7 100644 --- a/ee/agent/types/mocks/knapsack.go +++ b/ee/agent/types/mocks/knapsack.go @@ -342,20 +342,6 @@ func (_m *Knapsack) EnableInitialRunner() bool { return r0 } -// EnableWatchdog provides a mock function with given fields: -func (_m *Knapsack) EnableWatchdog() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - // EnrollSecret provides a mock function with given fields: func (_m *Knapsack) EnrollSecret() string { ret := _m.Called() @@ -1057,20 +1043,6 @@ func (_m *Knapsack) SetDisableTraceIngestTLS(enabled bool) error { return r0 } -// SetEnableWatchdog provides a mock function with given fields: enable -func (_m *Knapsack) SetEnableWatchdog(enable bool) error { - ret := _m.Called(enable) - - var r0 error - if rf, ok := ret.Get(0).(func(bool) error); ok { - r0 = rf(enable) - } else { - r0 = ret.Error(0) - } - - return r0 -} - // SetExportTraces provides a mock function with given fields: enabled func (_m *Knapsack) SetExportTraces(enabled bool) error { ret := _m.Called(enabled) @@ -1394,6 +1366,20 @@ func (_m *Knapsack) SetWatchdogDelaySec(sec int) error { return r0 } +// SetWatchdogEnabled provides a mock function with given fields: enable +func (_m *Knapsack) SetWatchdogEnabled(enable bool) error { + ret := _m.Called(enable) + + var r0 error + if rf, ok := ret.Get(0).(func(bool) error); ok { + r0 = rf(enable) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // SetWatchdogMemoryLimitMB provides a mock function with given fields: limit func (_m *Knapsack) SetWatchdogMemoryLimitMB(limit int) error { ret := _m.Called(limit) @@ -1598,6 +1584,20 @@ func (_m *Knapsack) WatchdogDelaySec() int { return r0 } +// WatchdogEnabled provides a mock function with given fields: +func (_m *Knapsack) WatchdogEnabled() bool { + ret := _m.Called() + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + // WatchdogMemoryLimitMB provides a mock function with given fields: func (_m *Knapsack) WatchdogMemoryLimitMB() int { ret := _m.Called() diff --git a/pkg/launcher/options.go b/pkg/launcher/options.go index dcf1d80a5..078e44b92 100644 --- a/pkg/launcher/options.go +++ b/pkg/launcher/options.go @@ -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 @@ -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", 60, "How many seconds to delay running watchdog after osquery startup") flWatchdogMemoryLimitMB = flagset.Int("watchdog_memory_limit_mb", 200, "osquery memory utilization limit in MB") flWatchdogUtilizationLimitPercent = flagset.Int("watchdog_utilization_limit_percent", 10, "osquery CPU utilization limit in percent") @@ -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, diff --git a/pkg/launcher/options_test.go b/pkg/launcher/options_test.go index 330a601f8..c1e2d1fdb 100644 --- a/pkg/launcher/options_test.go +++ b/pkg/launcher/options_test.go @@ -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: 60, WatchdogMemoryLimitMB: 200, WatchdogUtilizationLimitPercent: 10,