From 7a3b36f90ed0b2b13f7a900ee29f7fa30819560d Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 17 Jan 2017 18:32:13 +0100 Subject: [PATCH] minor cpuTemperature fix (OSX) --- CHANGELOG.md | 2 ++ LICENSE | 2 +- README.md | 10 +++++++++- lib/cpu.js | 13 +++++++------ lib/index.js | 2 ++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc49d6f..79eb53f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,6 +94,8 @@ Other changes | Version | Date | Comment | | -------------- | -------------- | -------- | +| 3.15.1 | 2017-01-17 | minor cpuTemperature fix (OSX) | +| 3.15.0 | 2017-01-15 | added cpuTemperature also for OSX | | 3.14.0 | 2017-01-14 | added currentLoad per cpu/core, cpu cache and cpu flags | | 3.13.0 | 2016-11-23 | added shell (returns standard shell) | | 3.12.0 | 2016-11-17 | refactoring and extended currentLoad | diff --git a/LICENSE b/LICENSE index f9dc944..0eefbf3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2016 Sebastian Hildebrandt +Copyright (c) 2014-2017 Sebastian Hildebrandt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 3ae0ed3..0828ebc 100644 --- a/README.md +++ b/README.md @@ -382,6 +382,11 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra - Quentin Busuttil [Buzut](https://github.com/Buzut) - lapsio [lapsio](https://github.com/lapsio) +OSX Temperature: Credits here are going to: + +- Massimiliano Marcon [mmarcon](https://github.com/mmarcon) - for his work on [smc-code][smc-code-url] +- Sébastien Lavoie[lavoiesl](https://github.com/lavoiesl) for his work on [osx-cpu-temp][osx-cpu-temp-url] code. + ## Copyright Information Linux is a registered trademark of Linus Torvalds, OS X is a registered trademark of Apple Inc., @@ -394,7 +399,7 @@ All other trademarks are the property of their respective owners. >The [`MIT`][license-url] License (MIT) > ->Copyright © 2014-2016 Sebastian Hildebrandt, [+innovations](http://www.plus-innovations.com). +>Copyright © 2014-2017 Sebastian Hildebrandt, [+innovations](http://www.plus-innovations.com). > >Permission is hereby granted, free of charge, to any person obtaining a copy >of this software and associated documentation files (the "Software"), to deal @@ -438,3 +443,6 @@ All other trademarks are the property of their respective owners. [mmon-npm-url]: https://npmjs.org/package/mmon [mmon-github-url]: https://github.com/sebhildebrandt/mmon + +[smc-code-url]: https://github.com/mmarcon/node-smc +[osx-cpu-temp-url]: https://github.com/lavoiesl/osx-cpu-temp diff --git a/lib/cpu.js b/lib/cpu.js index fbfcee7..9e1d06a 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -261,15 +261,16 @@ function cpuTemperature(callback) { let value = smc.get(key); if (id == 0) { if (value > 0) { - result.main = value + result.main = value; result.max = value; } id = 1; - } - if (value > 0) { - result.cores.push(value); - sum = sum + value; - if (value > result.max) result.max = value; + } else { + if (value > 0) { + result.cores.push(value); + sum = sum + value; + if (value > result.max) result.max = value; + } } }); if (result.cores.length) { diff --git a/lib/index.js b/lib/index.js index dd964a8..0ecdf41 100644 --- a/lib/index.js +++ b/lib/index.js @@ -81,6 +81,8 @@ // -------------------------------- // // version date comment +// 3.15.1 2017-01-17 minor cpuTemperature fix (OSX) +// 3.15.0 2017-01-15 added cpuTemperature also for OSX // 3.14.0 2017-01-14 added currentLoad per cpu/core, cpu cache (L1, L2, L3) and cpu flags // 3.13.0 2016-11-23 added shell (determines standard shell) // 3.12.0 2016-11-17 refactoring and extended currentLoad (better OSX coverage and added irq load)