Renamed alias log to elekLog

This commit is contained in:
balandi1 2019-11-21 14:02:47 -05:00
parent 7996240b2e
commit 9952b9861d
24 changed files with 254 additions and 254 deletions

View file

@ -29,7 +29,7 @@ import (
"syscall"
"time"
log "github.com/sirupsen/logrus"
elekLog "github.com/sirupsen/logrus"
"github.com/spdfg/elektron/elektronLogging"
elekLogTypes "github.com/spdfg/elektron/elektronLogging/types"
"github.com/spdfg/elektron/pcp"
@ -44,13 +44,13 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
if hiThreshold < loThreshold {
elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL,
log.InfoLevel,
log.Fields{}, "High threshold is lower than low threshold!")
elekLog.InfoLevel,
elekLog.Fields{}, "High threshold is lower than low threshold!")
}
pipe, err := cmd.StdoutPipe()
if err != nil {
log.Fatal(err)
elekLog.Fatal(err)
}
//cmd.Stdout = stdout
@ -62,8 +62,8 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
// Write to logfile
elektronLogging.ElektronLog.Log(elekLogTypes.PCP,
log.InfoLevel,
log.Fields{}, scanner.Text())
elekLog.InfoLevel,
elekLog.Fields{}, scanner.Text())
headers := strings.Split(scanner.Text(), ",")
@ -100,15 +100,15 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
if *logging {
elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL,
log.InfoLevel,
log.Fields{}, "Logging PCP...")
elekLog.InfoLevel,
elekLog.Fields{}, "Logging PCP...")
text := scanner.Text()
split := strings.Split(text, ",")
elektronLogging.ElektronLog.Log(elekLogTypes.PCP,
log.InfoLevel,
log.Fields{}, text)
elekLog.InfoLevel,
elekLog.Fields{}, text)
totalPower := 0.0
for _, powerIndex := range powerIndexes {
@ -120,8 +120,8 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
powerHistories[host] = powerHistories[host].Next()
elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL,
log.InfoLevel,
log.Fields{"Host": fmt.Sprintf("%s", indexToHost[powerIndex]), "Power": fmt.Sprintf("%f", (power * pcp.RAPLUnits))},
elekLog.InfoLevel,
elekLog.Fields{"Host": fmt.Sprintf("%s", indexToHost[powerIndex]), "Power": fmt.Sprintf("%f", (power * pcp.RAPLUnits))},
"")
totalPower += power
@ -134,15 +134,15 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
clusterMean := pcp.AverageClusterPowerHistory(clusterPowerHist)
elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL,
log.InfoLevel,
log.Fields{"Total power": fmt.Sprintf("%f %d", clusterPower, clusterPowerHist.Len()),
elekLog.InfoLevel,
elekLog.Fields{"Total power": fmt.Sprintf("%f %d", clusterPower, clusterPowerHist.Len()),
"Sec Avg": fmt.Sprintf("%f", clusterMean)},
"")
if clusterMean > hiThreshold {
elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL,
log.InfoLevel,
log.Fields{}, "Need to cap a node")
elekLog.InfoLevel,
elekLog.Fields{}, "Need to cap a node")
// Create statics for all victims and choose one to cap
victims := make([]pcp.Victim, 0, 8)
@ -164,13 +164,13 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
cappedHosts[victim.Host] = true
orderCapped = append(orderCapped, victim.Host)
elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL,
log.InfoLevel,
log.Fields{"Capping Victim": fmt.Sprintf("%s", victim.Host),
elekLog.InfoLevel,
elekLog.Fields{"Capping Victim": fmt.Sprintf("%s", victim.Host),
"Avg. Wattage": fmt.Sprintf("%f", victim.Watts*pcp.RAPLUnits)}, "")
if err := rapl.Cap(victim.Host, "rapl", 50); err != nil {
elektronLogging.ElektronLog.Log(elekLogTypes.ERROR,
log.ErrorLevel,
log.Fields{}, "Error capping host")
elekLog.ErrorLevel,
elekLog.Fields{}, "Error capping host")
}
break // Only cap one machine at at time.
}
@ -183,14 +183,14 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
orderCapped = orderCapped[:len(orderCapped)-1]
cappedHosts[host] = false
// User RAPL package to send uncap.
log.Printf("Uncapping host %s", host)
elekLog.Printf("Uncapping host %s", host)
elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL,
log.InfoLevel,
log.Fields{"Uncapped host": host}, "")
elekLog.InfoLevel,
elekLog.Fields{"Uncapped host": host}, "")
if err := rapl.Cap(host, "rapl", 100); err != nil {
elektronLogging.ElektronLog.Log(elekLogTypes.ERROR,
log.ErrorLevel,
log.Fields{}, "Error capping host")
elekLog.ErrorLevel,
elekLog.Fields{}, "Error capping host")
}
}
}
@ -201,11 +201,11 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
}(logging, hiThreshold, loThreshold)
elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL,
log.InfoLevel,
log.Fields{}, "PCP logging started")
elekLog.InfoLevel,
elekLog.Fields{}, "PCP logging started")
if err := cmd.Start(); err != nil {
log.Fatal(err)
elekLog.Fatal(err)
}
pgid, err := syscall.Getpgid(cmd.Process.Pid)
@ -213,8 +213,8 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
select {
case <-quit:
elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL,
log.InfoLevel,
log.Fields{}, "Stopping PCP logging in 5 seconds")
elekLog.InfoLevel,
elekLog.Fields{}, "Stopping PCP logging in 5 seconds")
time.Sleep(5 * time.Second)
// http://stackoverflow.com/questions/22470193/why-wont-go-kill-a-child-process-correctly