Skip to content

Commit 9aac418

Browse files
committed
Allow running multiple custom commands
1 parent 6ee59c9 commit 9aac418

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

config.example.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ metrics:
4141
memory:
4242
tcp:
4343
# custom command to show uptime
44-
custom: "cat /proc/uptime"
44+
custom-uptime: "cat /proc/uptime"
45+
custom-dir: 'dir C:\'
4546
poll-interval: 30

inspector/inspector.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package inspector
33
import (
44
"errors"
55
"fmt"
6+
"strings"
67

78
"github.com/bisohns/saido/driver"
89
)
@@ -32,8 +33,8 @@ var inspectorMap = map[string]NewInspector{
3233

3334
// Valid : checks if inspector is a valid inspector
3435
func Valid(name string) bool {
35-
for key, _ := range inspectorMap {
36-
if name == key {
36+
for key := range inspectorMap {
37+
if name == key || strings.HasPrefix(name, "custom") {
3738
return true
3839
}
3940
}
@@ -42,6 +43,9 @@ func Valid(name string) bool {
4243

4344
// Init : initializes the specified inspector using name and driver
4445
func Init(name string, driver *driver.Driver, custom ...string) (Inspector, error) {
46+
if strings.HasPrefix(name, "custom") {
47+
name = "custom"
48+
}
4549
val, ok := inspectorMap[name]
4650
if ok {
4751
inspector, err := val(driver, custom...)

0 commit comments

Comments
 (0)