diff --git a/daemons/execute_monitor_local.go b/daemons/execute_monitor_local.go index f58cc79..c2eabf4 100644 --- a/daemons/execute_monitor_local.go +++ b/daemons/execute_monitor_local.go @@ -1,10 +1,12 @@ package daemons import ( + "bufio" "fmt" "oc-schedulerd/conf" "os/exec" + oclib "cloud.o-forge.io/core/oc-lib" "github.com/rs/zerolog" ) @@ -23,6 +25,9 @@ func (lm *LocalMonitor) LaunchLocalMonitor() { } func (lm *LocalMonitor) execKube() { + + l := oclib.GetLogger() + args := []string{ "-e", lm.ExecutionID, "-p", lm.PeerID, "-u", conf.GetConfig().LokiUrl, "-m", conf.GetConfig().MongoUrl, "-d", conf.GetConfig().DBName, @@ -35,10 +40,24 @@ func (lm *LocalMonitor) execKube() { if lm.Duration > 0 { args = append(args, "-t", fmt.Sprintf("%d", lm.Duration)) } + cmd := exec.Command(conf.GetConfig().MonitorPath, args...) fmt.Printf("Command : %v\n", cmd) - err := cmd.Start() + + stdoutMonitord, err := cmd.StdoutPipe(); + if err != nil { + l.Error().Msg("Could not retrieve stdoutpipe for execution of oc-monitord" + err.Error()) + return + } + + err = cmd.Start() if err != nil { lm.Logger.Error().Msg("Could not start oc-monitor for " + lm.ExecutionID + " : " + err.Error()) } + + scanner := bufio.NewScanner(stdoutMonitord) + for scanner.Scan() { + output := scanner.Text() + l.Debug().Msg(output) + } }