Added ability to run commands in a shell

Diverges a small amount from the Python version for this.
This commit is contained in:
Ian Fijolek
2019-10-01 08:26:07 -07:00
parent 342b12432e
commit dd0b8e3f38
4 changed files with 37 additions and 4 deletions
+4 -2
View File
@@ -10,7 +10,7 @@ type Monitor struct {
// Config values
Name string
Command []string
CommandShell string `yaml:"command_shell`
CommandShell string `yaml:"command_shell"`
AlertDown []string `yaml:"alert_down"`
AlertUp []string `yaml:"alert_up"`
CheckInterval float64 `yaml:"check_interval"`
@@ -45,7 +45,9 @@ func (monitor *Monitor) Check() bool {
cmd = exec.Command(monitor.Command[0], monitor.Command[1:]...)
} else {
// TODO: Handle a command shell as well. This is untested
cmd = exec.Command(monitor.CommandShell)
//cmd = exec.Command("sh", "-c", "echo \"This is a test of the command system\"")
cmd = ShellCommand(monitor.CommandShell)
}
output, err := cmd.CombinedOutput()