GithubHelp home page GithubHelp logo

jkuri / macstats Goto Github PK

View Code? Open in Web Editor NEW
66.0 6.0 5.0 191 KB

Mac OS X Statistics - Battery, Fans, CPU

License: MIT License

JavaScript 2.64% Python 2.18% C++ 44.93% C 13.50% TypeScript 36.75%
battery cycle-count capacity fan cpu darwin macos

macstats's Introduction

macstats

node script for you mac stats

Example output:

--- CPU Stats ---
CPU Temp:        33.75°C

--- Fans Stats ---
Fan 0 speed:     1996 RPM
Fan 1 speed:     2003 RPM

--- Battery Stats ---
Charged:         82%
Capacity:        92%
Cycle Count:     692 (69%)
Max Cycle Count: 1000
Current Charge:  5189 mAh
Maximum Charge:  6316 mAh
Design Capacity: 6900 mAh
Time Remaining:  6.54 h
Temperature:     30.06°C

Installation

npm i macstats -g

Run

macstats

API

'use strict';

let macstats = require('macstats');

console.log(macstats);

API Reference

Data Description
battery.battery_installed Is battery installed, true or false [Boolean]
battery.design_capacity Battery design capacity in mAh [Int]
battery.max_capacity Max battery capacity in mAh [Int]
battery.current_capacity Current battery capacity in mAh [Int]
battery.percentage Current capacity percentage [Int]
battery.design_cycle_count Design cycle count [Int]
battery.cycle_count Current battery cycle count [Int]
battery.cycle_percentage Cycle count percentage [Int]
battery.temperature Battery temperature in °C [Float]
battery.charged Current battery charge percentage [Int]
battery.time_remaining Remaining time in minutes, if plugged in time until full, otherwise time until empty [Int]
battery.time_remaining_hours Time remaining in hours. Use in a combination with time_remaining_minutes [Int]
battery.time_remaining_minutes Time remaining in minutes. Use in a combination with time_remaining_hours [Int]
cpu.temp CPU Temperature in °C [Float]
fan.num Total number of fans [Int]
fan.fans Array of Objects (properties: id [Int], rpm [Int]), example: [ { id: 0, rpm: 2007 }, { id: 1, rpm: 1999 } ] }

Author

Jan Kuri

Licence

This project is licensed under the MIT license. See the LICENSE file for more info.

Thanks

Thanks Massimiliano Marcon for SMC C++ code in v8.

macstats's People

Contributors

0xflotus avatar jkuri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

macstats's Issues

needs XCode to build?

tried npm i macstats -g
but get an error during install

node-gyp rebuild
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

no big drama, installing XCode now, but might be good to call out as a prerequisite?

Error: IOServiceOpen()

When I run the command to see CPU stats (e.g. CPU temperature), I always get this error message:

$ macstats
--- CPU Stats ---
Error: IOServiceOpen() = e00002c7
CPU Temp:        0°C
Error: IOServiceOpen() = e00002c7

--- Fans Stats ---

--- Battery Stats ---
Charged:         96%
Capacity:        97%
Cycle Count:     15 (2%)
Max Cycle Count: 1000
Current Charge:  4760 mAh
Maximum Charge:  4965 mAh
Design Capacity: 5100 mAh
Time Remaining:  0.0 h
Temperature:     28.96°C

Tested on a MacBook Air (11-inch, Early 2015) on macOS Sierra 10.12.2.

Expose API

It would be very useful for me if this package could be required and output could be generated programatically.

Temperature and fans are broken on M1

----- CPU -----
Temperature: 0°C

----- Fans -----
Fan #0: 0

----- Battery -----
Battery Installed:  ✔
Is Charged:         ✔
Capacity:           102%
Cycle Count:        20 (2%)
Design Cycle Count: 1000
Current Charge:     4603 mAh
Maximum Charge:     5221 mAh
Design Capacity:    5103 mAh
Time Remaining:     00:12:41
Temperature:        25°C

MBP 13" Late 2020

mac mini 2012 battery error

mac mini 2012 late
Catalina 10.15.5

111111
get error on information about battery. But this model acturally doesn't has battery.

MacOS 10.14 (Mojave)

Since the update, some data are missing,
Do you have an idea of what has changed?

$ macstats
----- CPU -----
Temperature: 46.375°C

----- Fans -----
Fan #0: 1304

----- Battery -----
Battery Installed:  ✔
Is Charged:         ✔
Capacity:           NaN%
Cycle Count:        NaN (NaN%)
Design Cycle Count: 1000
Current Charge:     5932 mAh
Maximum Charge:     6077 mAh
Design Capacity:    NaN mAh
Time Remaining:     0:0
Temperature:        31°C

node-gyp rebuild fails on Catalina: error: no viable conversion from 'MaybeLocal<v8::String>' to 'Local<v8::String>'

% npm install -g macstats
/usr/local/bin/macstats -> /usr/local/lib/node_modules/macstats/bin/macstats

> [email protected] install /usr/local/lib/node_modules/macstats
> node-gyp rebuild

  CXX(target) Release/obj.target/smc/smc/smc.o
../smc/smc.cc:272:9: error: no viable conversion from 'MaybeLocal<v8::String>' to 'Local<v8::String>'
        String::NewFromUtf8(isolate, "Expected number")));
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/artsr/Library/Caches/node-gyp/13.2.0/include/node/v8.h:189:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from
      'MaybeLocal<v8::String>' to 'const v8::Local<v8::String> &' for 1st argument
class Local {
      ^
/Users/artsr/Library/Caches/node-gyp/13.2.0/include/node/v8.h:189:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from
      'MaybeLocal<v8::String>' to 'v8::Local<v8::String> &&' for 1st argument
/Users/artsr/Library/Caches/node-gyp/13.2.0/include/node/v8.h:193:13: note: candidate template ignored: could not match 'Local' against 'MaybeLocal'
  V8_INLINE Local(Local<S> that)
            ^
/Users/artsr/Library/Caches/node-gyp/13.2.0/include/node/v8.h:6995:47: note: passing argument to parameter 'message' here
  static Local<Value> TypeError(Local<String> message);
                                              ^
../smc/smc.cc:275:39: error: too few arguments to function call, single argument 'context' was not specified
  int fanNumber = args[0]->Int32Value();
                  ~~~~~~~~~~~~~~~~~~~ ^
/Users/artsr/Library/Caches/node-gyp/13.2.0/include/node/v8.h:2778:3: note: 'Int32Value' declared here
  V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
  ^
/Users/artsr/Library/Caches/node-gyp/13.2.0/include/node/v8config.h:419:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
../smc/smc.cc:282:6: error: variable has incomplete type 'void'
void Init(v8::Handle<Object> exports)
     ^
../smc/smc.cc:282:15: error: no member named 'Handle' in namespace 'v8'
void Init(v8::Handle<Object> exports)
          ~~~~^
../smc/smc.cc:282:22: error: 'Object' does not refer to a value
void Init(v8::Handle<Object> exports)
                     ^
/Users/artsr/Library/Caches/node-gyp/13.2.0/include/node/v8.h:3541:17: note: declared here
class V8_EXPORT Object : public Value {
                ^
../smc/smc.cc:282:30: error: use of undeclared identifier 'exports'
void Init(v8::Handle<Object> exports)
                             ^
../smc/smc.cc:282:38: error: expected ';' after top level declarator
void Init(v8::Handle<Object> exports)
                                     ^
                                     ;
7 errors generated.
make: *** [Release/obj.target/smc/smc/smc.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/Cellar/node/13.2.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/macstats
gyp ERR! node -v v13.2.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/artsr/.npm/_logs/2020-01-15T10_52_24_826Z-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.