pcp: CPU/MEM utilization & task share variance per node
This commit is contained in:
parent
abadb9a328
commit
46be28ef8d
4 changed files with 113 additions and 22 deletions
34
pcp/pcp.go
34
pcp/pcp.go
|
@ -2,14 +2,18 @@ package pcp
|
|||
|
||||
import (
|
||||
elecLogDef "bitbucket.org/sunybingcloud/elektron/logging/def"
|
||||
"bitbucket.org/sunybingcloud/elektron/schedulers"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/mesos/mesos-go/api/v0/scheduler"
|
||||
"log"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Start(quit chan struct{}, logging *bool, logMType chan elecLogDef.LogMessageType, logMsg chan string) {
|
||||
func Start(quit chan struct{}, logging *bool, logMType chan elecLogDef.LogMessageType, logMsg chan string, s scheduler.Scheduler) {
|
||||
baseSchedRef := s.(*schedulers.BaseScheduler)
|
||||
const pcpCommand string = "pmdumptext -m -l -f '' -t 1.0 -d , -c config"
|
||||
cmd := exec.Command("sh", "-c", pcpCommand)
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
|
@ -34,14 +38,40 @@ func Start(quit chan struct{}, logging *bool, logMType chan elecLogDef.LogMessag
|
|||
scanner.Scan()
|
||||
|
||||
seconds := 0
|
||||
|
||||
for scanner.Scan() {
|
||||
text := scanner.Text()
|
||||
|
||||
if *logging {
|
||||
logMType <- elecLogDef.PCP
|
||||
logMsg <- scanner.Text()
|
||||
logMsg <- text
|
||||
}
|
||||
|
||||
seconds++
|
||||
|
||||
memUtils := memUtilPerNode(text)
|
||||
memTaskShares := make([]float64, len(memUtils))
|
||||
|
||||
cpuUtils := cpuUtilPerNode(text)
|
||||
cpuTaskShares := make([]float64, len(cpuUtils))
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
host := fmt.Sprintf("stratos-00%d.cs.binghamton.edu", i+1)
|
||||
slaveID := baseSchedRef.HostNameToSlaveID[host]
|
||||
tasksRunning := len(baseSchedRef.Running[slaveID])
|
||||
if tasksRunning > 0 {
|
||||
cpuTaskShares[i] = cpuUtils[i] / float64(tasksRunning)
|
||||
memTaskShares[i] = memUtils[i] / float64(tasksRunning)
|
||||
}
|
||||
}
|
||||
|
||||
cpuVariance := calcVariance(cpuUtils)
|
||||
cpuTaskSharesVariance := calcVariance(cpuTaskShares)
|
||||
memVariance := calcVariance(memUtils)
|
||||
memTaskSharesVariance := calcVariance(memTaskShares)
|
||||
|
||||
logMType <- elecLogDef.DEG_COL
|
||||
logMsg <- fmt.Sprintf("%f, %f, %f, %f", cpuVariance, cpuTaskSharesVariance, memVariance, memTaskSharesVariance)
|
||||
}
|
||||
}(logging)
|
||||
|
||||
|
|
Reference in a new issue