2024-07-29 15:46:44 +02:00
|
|
|
package daemons
|
|
|
|
|
2024-08-09 18:44:33 +02:00
|
|
|
import (
|
2024-08-12 16:09:30 +02:00
|
|
|
"oc-scheduler/conf"
|
2024-08-09 18:44:33 +02:00
|
|
|
"oc-scheduler/logger"
|
|
|
|
"os/exec"
|
|
|
|
)
|
2024-07-29 15:46:44 +02:00
|
|
|
|
|
|
|
type LocalMonitor struct{
|
2024-08-09 18:44:33 +02:00
|
|
|
LokiURL string
|
|
|
|
KubeURL string
|
|
|
|
WorkflowName string
|
2024-07-29 15:46:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (lm *LocalMonitor) LaunchLocalMonitor (){
|
2024-08-09 18:44:33 +02:00
|
|
|
if (lm.LokiURL == "" || lm.KubeURL == "" || lm.WorkflowName == ""){
|
2024-07-29 15:46:44 +02:00
|
|
|
logger.Logger.Error().Msg("Missing parameter in LocalMonitor")
|
|
|
|
}
|
|
|
|
|
|
|
|
// For dev purposes, in prod KubeURL must be a kube API's URL
|
|
|
|
if(lm.KubeURL == "localhost"){
|
2024-08-09 18:44:33 +02:00
|
|
|
lm.execLocalKube()
|
2024-07-29 15:46:44 +02:00
|
|
|
} else{
|
2024-08-09 18:44:33 +02:00
|
|
|
lm.execRemoteKube()
|
2024-07-29 15:46:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-09 18:44:33 +02:00
|
|
|
func (lm *LocalMonitor) execLocalKube (){
|
2024-07-29 15:46:44 +02:00
|
|
|
// kube_url := ""
|
2024-08-12 16:09:30 +02:00
|
|
|
cmd := exec.Command("../oc-monitor/oc-monitor", "-w",lm.WorkflowName, "-u", lm.LokiURL, "-m", conf.GetConfig().MongoUrl,"-d", conf.GetConfig().DBName)
|
2024-08-09 18:44:33 +02:00
|
|
|
// cmd_ls := exec.Command("ls", "../oc-monitor")
|
2024-08-12 16:09:30 +02:00
|
|
|
err := cmd.Start()
|
2024-08-09 18:44:33 +02:00
|
|
|
// output, err := cmd_ls.CombinedOutput()
|
|
|
|
if err !=nil {
|
|
|
|
logger.Logger.Error().Msg("Could not start oc-monitor for " + lm.WorkflowName + " : " + err.Error())
|
|
|
|
}
|
|
|
|
|
2024-07-29 15:46:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-08-09 18:44:33 +02:00
|
|
|
func (lm *LocalMonitor) execRemoteKube (){
|
2024-07-29 15:46:44 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (lm *LocalMonitor) todo (){
|
|
|
|
|
|
|
|
}
|