Skip to content

Commit

Permalink
Add min/max observed CPU temps.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyoung committed Jan 31, 2019
1 parent 7026f19 commit 39bb2e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion main/gen_gdl90.go
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,8 @@ type status struct {
Uptime int64
UptimeClock time.Time
CPUTemp float32
CPUTempMin float32
CPUTempMax float32
NetworkDataMessagesSent uint64
NetworkDataMessagesSentNonqueueable uint64
NetworkDataBytesSent uint64
Expand Down Expand Up @@ -1350,7 +1352,7 @@ func printStats() {
runtime.ReadMemStats(&memstats)
log.Printf("stats [started: %s]\n", humanize.RelTime(time.Time{}, stratuxClock.Time, "ago", "from now"))
log.Printf(" - Disk bytes used = %s (%.1f %%), Disk bytes free = %s (%.1f %%)\n", humanize.Bytes(usage.Used()), 100*usage.Usage(), humanize.Bytes(usage.Free()), 100*(1-usage.Usage()))
log.Printf(" - CPUTemp=%.02f deg C, MemStats.Alloc=%s, MemStats.Sys=%s, totalNetworkMessagesSent=%s\n", globalStatus.CPUTemp, humanize.Bytes(uint64(memstats.Alloc)), humanize.Bytes(uint64(memstats.Sys)), humanize.Comma(int64(totalNetworkMessagesSent)))
log.Printf(" - CPUTemp=%.02f [%.02f - %.02f] deg C, MemStats.Alloc=%s, MemStats.Sys=%s, totalNetworkMessagesSent=%s\n", globalStatus.CPUTemp, globalStatus.CPUTempMin, globalStatus.CPUTempMax, humanize.Bytes(uint64(memstats.Alloc)), humanize.Bytes(uint64(memstats.Sys)), humanize.Comma(int64(totalNetworkMessagesSent)))
log.Printf(" - UAT/min %s/%s [maxSS=%.02f%%], ES/min %s/%s, Total traffic targets tracked=%s", humanize.Comma(int64(globalStatus.UAT_messages_last_minute)), humanize.Comma(int64(globalStatus.UAT_messages_max)), float64(maxSignalStrength)/10.0, humanize.Comma(int64(globalStatus.ES_messages_last_minute)), humanize.Comma(int64(globalStatus.ES_messages_max)), humanize.Comma(int64(len(seenTraffic))))
log.Printf(" - Network data messages sent: %d total, %d nonqueueable. Network data bytes sent: %d total, %d nonqueueable.\n", globalStatus.NetworkDataMessagesSent, globalStatus.NetworkDataMessagesSentNonqueueable, globalStatus.NetworkDataBytesSent, globalStatus.NetworkDataBytesSentNonqueueable)
if globalSettings.GPS_Enabled {
Expand Down Expand Up @@ -1649,8 +1651,16 @@ func main() {
go printStats()

// Monitor RPi CPU temp.
globalStatus.CPUTempMin = invalidCpuTemp
globalStatus.CPUTempMax = invalidCpuTemp
go cpuTempMonitor(func(cpuTemp float32) {
globalStatus.CPUTemp = cpuTemp
if isCPUTempValid(cpuTemp) && ((cpuTemp < globalStatus.CPUTempMin) || !isCPUTempValid(globalStatus.CPUTempMin)) {
globalStatus.CPUTempMin = cpuTemp
}
if isCPUTempValid(cpuTemp) && ((cpuTemp > globalStatus.CPUTempMax) || !isCPUTempValid(globalStatus.CPUTempMax)) {
globalStatus.CPUTempMax = cpuTemp
}
})

// Start reading from serial UAT radio.
Expand Down
2 changes: 2 additions & 0 deletions web/plates/js/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ function StatusCtrl($rootScope, $scope, $state, $http, $interval) {
if (boardtemp != undefined) {
/* boardtemp is celcius to tenths */
$scope.CPUTemp = String(boardtemp.toFixed(1) + '°C / ' + ((boardtemp * 9 / 5) + 32.0).toFixed(1) + '°F');
$scope.CPUTempMin = String(status.CPUTempMin.toFixed(1)) + '°C';
$scope.CPUTempMax = String(status.CPUTempMax.toFixed(1)) + '°C';
} else {
// $('#CPUTemp').text('unavailable');
}
Expand Down
2 changes: 1 addition & 1 deletion web/plates/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
</div>
<div class="col-sm-4 label_adj">
<span class="col-xs-5"><strong>CPU Temp:</strong></span>
<span class="col-xs-7">{{CPUTemp}}</span>
<span class="col-xs-7">{{CPUTemp}} <div ng-show="DeveloperMode == true">[{{CPUTempMin}} - {{CPUTempMax}}]</div></span>
</div>
<div class="col-sm-4 label_adj">
<span class="col-xs-5"><strong>Free Storage:</strong></span>
Expand Down

0 comments on commit 39bb2e3

Please sign in to comment.