diff --git a/inspector/inspector.go b/inspector/inspector.go index ca5cade..d1507f7 100644 --- a/inspector/inspector.go +++ b/inspector/inspector.go @@ -8,6 +8,9 @@ import ( "github.com/bisohns/saido/driver" ) +// CustomCommand : every custom command must be prefixed by this +var CustomCommand = `custom` + // Inspector : defines a particular metric supported by a driver type Inspector interface { Parse(output string) @@ -19,14 +22,14 @@ type Inspector interface { type NewInspector func(driver *driver.Driver, custom ...string) (Inspector, error) var inspectorMap = map[string]NewInspector{ - `disk`: NewDF, - `docker`: NewDockerStats, - `uptime`: NewUptime, - `memory`: NewMemInfo, - `process`: NewProcess, - `loadavg`: NewLoadAvg, - `tcp`: NewTcp, - `custom`: NewCustom, + `disk`: NewDF, + `docker`: NewDockerStats, + `uptime`: NewUptime, + `memory`: NewMemInfo, + `process`: NewProcess, + `loadavg`: NewLoadAvg, + `tcp`: NewTcp, + CustomCommand: NewCustom, // NOTE: Inactive for now `responsetime`: NewResponseTime, } @@ -34,7 +37,7 @@ var inspectorMap = map[string]NewInspector{ // Valid : checks if inspector is a valid inspector func Valid(name string) bool { for key := range inspectorMap { - if name == key || strings.HasPrefix(name, "custom") { + if name == key || strings.HasPrefix(name, CustomCommand) { return true } } @@ -43,7 +46,7 @@ func Valid(name string) bool { // Init : initializes the specified inspector using name and driver func Init(name string, driver *driver.Driver, custom ...string) (Inspector, error) { - if strings.HasPrefix(name, "custom") { + if strings.HasPrefix(name, CustomCommand) { name = "custom" } val, ok := inspectorMap[name]