Provide pcp config file from commandline.
Taking pcp config file name (or path) from commandline. In scheduler.go, also checking to see if provided pcp config file exists. If not, then exitting.
This commit is contained in:
parent
8e87bcb439
commit
1e9828c35b
4 changed files with 20 additions and 9 deletions
|
@ -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}
|
||||
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
16
scheduler.go
16
scheduler.go
|
@ -22,6 +22,8 @@ import (
|
|||
var master = flag.String("master", "", "Location of leading Mesos master -- <mesos-master>:<port>")
|
||||
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
|
||||
|
|
Reference in a new issue