diff --git a/pcp/pcp.go b/pcp/pcp.go index 38870d4..b575f61 100644 --- a/pcp/pcp.go +++ b/pcp/pcp.go @@ -14,9 +14,10 @@ import ( "gitlab.com/spdf/elektron/schedulers" ) -func Start(quit chan struct{}, logging *bool, logMType chan elekLogDef.LogMessageType, logMsg chan string, s scheduler.Scheduler) { +func Start(quit chan struct{}, logging *bool, logMType chan elekLogDef.LogMessageType, + logMsg chan string, pcpConfigFile string, s scheduler.Scheduler) { baseSchedRef := s.(*schedulers.BaseScheduler) - const pcpCommand string = "pmdumptext -m -l -f '' -t 1.0 -d , -c config" + const pcpCommand string = "pmdumptext -m -l -f '' -t 1.0 -d , -c " + pcpConfigFile cmd := exec.Command("sh", "-c", pcpCommand) cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} diff --git a/powerCap/extrema.go b/powerCap/extrema.go index 1433dc9..1c103dd 100644 --- a/powerCap/extrema.go +++ b/powerCap/extrema.go @@ -18,9 +18,9 @@ import ( ) func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThreshold, loThreshold float64, - logMType chan elekLogDef.LogMessageType, logMsg chan string) { + logMType chan elekLogDef.LogMessageType, logMsg chan string, pcpConfigFile string) { - const pcpCommand string = "pmdumptext -m -l -f '' -t 1.0 -d , -c config" + const pcpCommand string = "pmdumptext -m -l -f '' -t 1.0 -d , -c " + pcpConfigFile cmd := exec.Command("sh", "-c", pcpCommand) cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} diff --git a/powerCap/progressiveExtrema.go b/powerCap/progressiveExtrema.go index 21a8b77..838d051 100644 --- a/powerCap/progressiveExtrema.go +++ b/powerCap/progressiveExtrema.go @@ -31,9 +31,9 @@ func getNextCapValue(curCapValue float64, precision int) float64 { } func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiThreshold, loThreshold float64, - logMType chan elekLogDef.LogMessageType, logMsg chan string) { + logMType chan elekLogDef.LogMessageType, logMsg chan string, pcpConfigFile string) { - const pcpCommand string = "pmdumptext -m -l -f '' -t 1.0 -d , -c config" + const pcpCommand string = "pmdumptext -m -l -f '' -t 1.0 -d , -c " + pcpConfigFile cmd := exec.Command("sh", "-c", pcpCommand) cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} diff --git a/scheduler.go b/scheduler.go index 74696cb..be272f6 100644 --- a/scheduler.go +++ b/scheduler.go @@ -22,6 +22,8 @@ import ( var master = flag.String("master", "", "Location of leading Mesos master -- :") var tasksFile = flag.String("workload", "", "JSON file containing task definitions") var wattsAsAResource = flag.Bool("wattsAsAResource", false, "Enable Watts as a Resource") +var pcpConfigFile = flag.String("pcpConfigFile", "config", "PCP config file name (if file not " + + "present in the same directory, then provide path).") var pcplogPrefix = flag.String("logPrefix", "", "Prefix for pcplog") var powerCapPolicy = flag.String("powercap", "", "Power Capping policy. (default (''), extrema, prog-extrema).") var hiThreshold = flag.Float64("hiThreshold", 0.0, "Upperbound for when we should start capping") @@ -41,6 +43,8 @@ func init() { flag.StringVar(master, "m", "", "Location of leading Mesos master (shorthand)") flag.StringVar(tasksFile, "w", "", "JSON file containing task definitions (shorthand)") flag.BoolVar(wattsAsAResource, "waar", false, "Enable Watts as a Resource (shorthand)") + flag.StringVar(pcpConfigFile, "pcpCF", "config", "PCP config file name (if not present in" + + " the same directory, then provide path) (shorthand).") flag.StringVar(pcplogPrefix, "p", "", "Prefix for pcplog (shorthand)") flag.StringVar(powerCapPolicy, "pc", "", "Power Capping policy. (default (''), extrema, prog-extrema) (shorthand).") flag.Float64Var(hiThreshold, "ht", 700.0, "Upperbound for when we should start capping (shorthand)") @@ -195,14 +199,20 @@ func main() { } } + // Checking if pcp config file exists. + if _, err := os.Stat(*pcpConfigFile); os.IsNotExist(err) { + logger.WriteLog(elekLogDef.ERROR, "PCP config file does not exist!") + os.Exit(1) + } + if noPowercap { - go pcp.Start(pcpLog, &recordPCP, logMType, logMsg, scheduler) + go pcp.Start(pcpLog, &recordPCP, logMType, logMsg, *pcpConfigFile, scheduler) } else if extrema { go powerCap.StartPCPLogAndExtremaDynamicCap(pcpLog, &recordPCP, *hiThreshold, - *loThreshold, logMType, logMsg) + *loThreshold, logMType, logMsg, *pcpConfigFile) } else if progExtrema { go powerCap.StartPCPLogAndProgressiveExtremaCap(pcpLog, &recordPCP, *hiThreshold, - *loThreshold, logMType, logMsg) + *loThreshold, logMType, logMsg, *pcpConfigFile) } time.Sleep(1 * time.Second) // Take a second between starting PCP log and continuing