1
0
Fork 0

스텟들 바뀌지 않더라도 노티하게 함

This commit is contained in:
Sangbum Kim 2017-09-12 23:17:04 +09:00
parent 8aff2658e2
commit 1d55617d68
2 changed files with 31 additions and 23 deletions

View File

@ -58,7 +58,9 @@ func (c *fanControl) StartControl() {
case <-ticker: case <-ticker:
break checker break checker
case changedSpeed := <-c.fanSpeedConsumer: case changedSpeed := <-c.fanSpeedConsumer:
newFanSpeedList[changedSpeed.Id] = changedSpeed.FanSpeed if changedSpeed.Changed {
newFanSpeedList[changedSpeed.Id] = changedSpeed.FanSpeed
}
case <-c.handler.Done(): case <-c.handler.Done():
return return
} }

View File

@ -33,11 +33,13 @@ type processor struct {
type TempetureInfo struct { type TempetureInfo struct {
Id int Id int
Tempeture float64 Tempeture float64
Changed bool
} }
type FanspeedInfo struct { type FanspeedInfo struct {
Id int Id int
FanSpeed int FanSpeed int
Changed bool
} }
type Processor interface { type Processor interface {
@ -136,35 +138,39 @@ func (p *processor) StartMonitoring() {
fanspeed int fanspeed int
) )
/*
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 highestTemp != p.tempeture { if p.tempetureChanged != nil {
if p.tempetureChanged != nil { select {
select { case p.tempetureChanged <- TempetureInfo{
case p.tempetureChanged <- TempetureInfo{ Id: p.id,
Id: p.id, Tempeture: highestTemp,
Tempeture: highestTemp, Changed: highestTemp != p.tempeture,
}: }:
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
*/
fanspeed = p.normalizeFanspeed(p.fanController.Update(highestTemp)) fanspeed = p.normalizeFanspeed(p.fanController.Update(highestTemp))
if fanspeed != p.fanSpeed { if p.fanSpeedChanged != nil {
if p.fanSpeedChanged != nil { select {
select { case p.fanSpeedChanged <- FanspeedInfo{
case p.fanSpeedChanged <- FanspeedInfo{ Id: p.id,
Id: p.id, FanSpeed: fanspeed,
FanSpeed: fanspeed, Changed: fanspeed != p.fanSpeed,
}: }:
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
} }