다시 부하 줄임
This commit is contained in:
parent
e49b6d212d
commit
95e7c235cb
|
@ -80,7 +80,7 @@ func (m *influxMetric) StartLogging() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ticker := time.Tick(time.Second)
|
ticker := time.Tick(time.Second*2)
|
||||||
fanspeedList, tempetureList := make([]processor.FanspeedInfo, 0, 0), make([]processor.TempetureInfo, 0, 0)
|
fanspeedList, tempetureList := make([]processor.FanspeedInfo, 0, 0), make([]processor.TempetureInfo, 0, 0)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -91,7 +91,6 @@ func (m *influxMetric) StartLogging() {
|
||||||
go m.sendPoint(influxDbConn, batchPoint, fanspeedListTemp, tempetureListTemp)
|
go m.sendPoint(influxDbConn, batchPoint, fanspeedListTemp, tempetureListTemp)
|
||||||
case changedSpeed := <-m.fanSpeedConsumer:
|
case changedSpeed := <-m.fanSpeedConsumer:
|
||||||
fanspeedList = append(fanspeedList, changedSpeed)
|
fanspeedList = append(fanspeedList, changedSpeed)
|
||||||
|
|
||||||
case changedTempeture := <-m.tempetureConsumer:
|
case changedTempeture := <-m.tempetureConsumer:
|
||||||
tempetureList = append(tempetureList, changedTempeture)
|
tempetureList = append(tempetureList, changedTempeture)
|
||||||
case <-m.handler.Done():
|
case <-m.handler.Done():
|
||||||
|
|
4
main.go
4
main.go
|
@ -20,8 +20,8 @@ import (
|
||||||
var (
|
var (
|
||||||
app = kingpin.New("cpu_ctrl", "Interactive CPU fan controller").Author("Sangbum Kim")
|
app = kingpin.New("cpu_ctrl", "Interactive CPU fan controller").Author("Sangbum Kim")
|
||||||
verbose = app.Flag("verbose", "Enable verbose mode.").Short('v').Bool()
|
verbose = app.Flag("verbose", "Enable verbose mode.").Short('v').Bool()
|
||||||
P = app.Flag("proportional-gain", "Set proportional gain value.").Short('p').Default("1.5").Float64()
|
P = app.Flag("proportional-gain", "Set proportional gain value.").Short('p').Default("1.0").Float64()
|
||||||
I = app.Flag("integral-gain", "Set integral gain value.").Short('i').Default("0.4").Float64()
|
I = app.Flag("integral-gain", "Set integral gain value.").Short('i').Default("0.6").Float64()
|
||||||
D = app.Flag("derivative-gain", "Set derivative gain value.").Short('d').Default("2.0").Float64()
|
D = app.Flag("derivative-gain", "Set derivative gain value.").Short('d').Default("2.0").Float64()
|
||||||
SetPoint = app.Flag("set-point", "Set pointe tempeture").Short('t').Default("38.0").Float64()
|
SetPoint = app.Flag("set-point", "Set pointe tempeture").Short('t').Default("38.0").Float64()
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,12 @@ type processor struct {
|
||||||
type TempetureInfo struct {
|
type TempetureInfo struct {
|
||||||
Id int
|
Id int
|
||||||
Tempeture float64
|
Tempeture float64
|
||||||
Changed bool
|
|
||||||
At time.Time
|
At time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type FanspeedInfo struct {
|
type FanspeedInfo struct {
|
||||||
Id int
|
Id int
|
||||||
FanSpeed int
|
FanSpeed int
|
||||||
Changed bool
|
|
||||||
At time.Time
|
At time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,37 +142,39 @@ func (p *processor) StartMonitoring() {
|
||||||
CREATE CONTINUOUS QUERY "processor_tempeture_5s" ON "core" BEGIN SELECT mean("tempeture") AS "mean_tempeture" INTO "12 weeks"."processor_tempeture_5s" FROM "processor_tempeture" GROUP BY processor, time(5s) fill(previous) END
|
CREATE CONTINUOUS QUERY "processor_tempeture_5s" ON "core" BEGIN SELECT mean("tempeture") AS "mean_tempeture" INTO "12 weeks"."processor_tempeture_5s" FROM "processor_tempeture" GROUP BY processor, time(5s) fill(previous) END
|
||||||
*/
|
*/
|
||||||
highestTemp = p.getMaxTempetureOnProcessor(tempeturePathGlob)
|
highestTemp = p.getMaxTempetureOnProcessor(tempeturePathGlob)
|
||||||
if p.tempetureChanged != nil {
|
if highestTemp != p.tempeture {
|
||||||
select {
|
if p.tempetureChanged != nil {
|
||||||
case p.tempetureChanged <- TempetureInfo{
|
select {
|
||||||
Id: p.id,
|
case p.tempetureChanged <- TempetureInfo{
|
||||||
Tempeture: highestTemp,
|
Id: p.id,
|
||||||
Changed: highestTemp != p.tempeture,
|
Tempeture: highestTemp,
|
||||||
At: now,
|
At: now,
|
||||||
}:
|
}:
|
||||||
default:
|
default:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
p.tempeture = highestTemp
|
||||||
|
log.Debugf("processor %d : tempeture changed %f", p.id, highestTemp)
|
||||||
}
|
}
|
||||||
p.tempeture = highestTemp
|
|
||||||
log.Debugf("processor %d : tempeture changed %f", p.id, highestTemp)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CREATE CONTINUOUS QUERY "processor_cooling_fanspeed_5s" ON "core" BEGIN SELECT mean("noob") AS "mean_noob" INTO "12 weeks"."processor_cooling_fanspeed_5s" FROM "processor_cooling_fanspeed" GROUP BY processor, time(5s) fill(previous) END
|
CREATE CONTINUOUS QUERY "processor_cooling_fanspeed_5s" ON "core" BEGIN SELECT mean("noob") AS "mean_noob" INTO "12 weeks"."processor_cooling_fanspeed_5s" FROM "processor_cooling_fanspeed" GROUP BY processor, time(5s) fill(previous) END
|
||||||
*/
|
*/
|
||||||
fanspeed = p.normalizeFanspeed(p.fanController.Update(highestTemp))
|
fanspeed = p.normalizeFanspeed(p.fanController.Update(highestTemp))
|
||||||
if p.fanSpeedChanged != nil {
|
if fanspeed != p.fanSpeed {
|
||||||
select {
|
if p.fanSpeedChanged != nil {
|
||||||
case p.fanSpeedChanged <- FanspeedInfo{
|
select {
|
||||||
Id: p.id,
|
case p.fanSpeedChanged <- FanspeedInfo{
|
||||||
FanSpeed: fanspeed,
|
Id: p.id,
|
||||||
Changed: fanspeed != p.fanSpeed,
|
FanSpeed: fanspeed,
|
||||||
At: now,
|
At: now,
|
||||||
}:
|
}:
|
||||||
default:
|
default:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
p.fanSpeed = fanspeed
|
||||||
|
log.Debugf("processor %d : fan changed 0x%x", p.id, fanspeed)
|
||||||
}
|
}
|
||||||
p.fanSpeed = fanspeed
|
|
||||||
log.Debugf("processor %d : fan changed 0x%x", p.id, fanspeed)
|
|
||||||
case <-p.handler.Done():
|
case <-p.handler.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue