From 39bb2e341584ca6ce98e6cdf54683287fa5d4081 Mon Sep 17 00:00:00 2001 From: cyoung Date: Thu, 31 Jan 2019 11:45:21 -0500 Subject: [PATCH] Add min/max observed CPU temps. #728. --- main/gen_gdl90.go | 12 +++++++++++- web/plates/js/status.js | 2 ++ web/plates/status.html | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 35a5575f6..1ff0b0bb2 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -1148,6 +1148,8 @@ type status struct { Uptime int64 UptimeClock time.Time CPUTemp float32 + CPUTempMin float32 + CPUTempMax float32 NetworkDataMessagesSent uint64 NetworkDataMessagesSentNonqueueable uint64 NetworkDataBytesSent uint64 @@ -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 { @@ -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. diff --git a/web/plates/js/status.js b/web/plates/js/status.js index c96bb5978..f899dace8 100644 --- a/web/plates/js/status.js +++ b/web/plates/js/status.js @@ -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'); } diff --git a/web/plates/status.html b/web/plates/status.html index 093c57b39..fad9c8706 100644 --- a/web/plates/status.html +++ b/web/plates/status.html @@ -107,7 +107,7 @@
CPU Temp: - {{CPUTemp}} + {{CPUTemp}}
[{{CPUTempMin}} - {{CPUTempMax}}]
Free Storage: