fix: missing cpu temp and swap logic

This commit is contained in:
Bobby Wibowo 2022-08-19 10:48:45 +07:00
parent 83c6cee482
commit bd71035517
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -836,7 +836,9 @@ const generateStats = async (req, res) => {
'CPU Load': `${currentLoad.currentLoad.toFixed(1)}%`,
'CPUs Load': currentLoad.cpus.map(cpu => `${cpu.load.toFixed(1)}%`).join(', '),
'CPU Temperature': {
value: cpuTemperature ? cpuTemperature.main : 'Not supported',
value: cpuTemperature && typeof cpuTemperature.main === 'number'
? cpuTemperature.main
: 'N/A',
type: 'tempC' // temp value from this library is hard-coded to C
},
Memory: {
@ -847,12 +849,12 @@ const generateStats = async (req, res) => {
type: 'byteUsage'
},
Swap: {
value: typeof mem.swapused === 'number' && typeof mem.swaptotal === 'number'
value: typeof mem.swaptotal === 'number' && mem.swaptotal > 0
? {
used: mem.swapused,
total: mem.swaptotal
}
: null,
: 'N/A',
type: 'byteUsage'
},
Uptime: {