Skip to content

Commit

Permalink
Allow running multiple custom commands
Browse files Browse the repository at this point in the history
  • Loading branch information
deven96 committed Nov 10, 2022
1 parent 6ee59c9 commit 9aac418
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ metrics:
memory:
tcp:
# custom command to show uptime
custom: "cat /proc/uptime"
custom-uptime: "cat /proc/uptime"
custom-dir: 'dir C:\'
poll-interval: 30
8 changes: 6 additions & 2 deletions inspector/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package inspector
import (
"errors"
"fmt"
"strings"

"github.com/bisohns/saido/driver"
)
Expand Down Expand Up @@ -32,8 +33,8 @@ 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 {
for key := range inspectorMap {
if name == key || strings.HasPrefix(name, "custom") {
return true
}
}
Expand All @@ -42,6 +43,9 @@ 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") {
name = "custom"
}
val, ok := inspectorMap[name]
if ok {
inspector, err := val(driver, custom...)
Expand Down

0 comments on commit 9aac418

Please sign in to comment.