added logging to see if monitord is running well

This commit is contained in:
pb 2025-04-17 19:59:33 +02:00
parent 494ba2f361
commit d94f9603e8

View File

@ -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)
}
}