1 | os-utils
|
2 | ========
|
3 |
|
4 | an operating-system utility library. Some methods are wrappers of Node libraries
|
5 | and others are calculation made by the module.
|
6 |
|
7 |
|
8 | ## Instalation
|
9 |
|
10 | One line instaltion with [npm](http://npmjs.org).
|
11 |
|
12 | npm install os-utils
|
13 |
|
14 | Then in your code
|
15 |
|
16 | var os = require('os-utils');
|
17 |
|
18 |
|
19 | os.cpuUsage(function(v){
|
20 | console.log( 'CPU Usage (%): ' + v );
|
21 | });
|
22 |
|
23 | os.cpuFree(function(v){
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | ## Usage
|
29 |
|
30 | The follwoing methods are available:
|
31 |
|
32 |
|
33 | ### Calculate CPU usage in the next second. This is not an average of CPU usage like in the "os" module. The callback will receive a parameter with the value
|
34 |
|
35 | os.cpuUsage( callback );
|
36 |
|
37 |
|
38 | ### Calculate free CPU in the next second. This is not based on average CPU usage like in the "os" module. The callback will receive a parameter with the value
|
39 |
|
40 | os.cpuFree( callback );
|
41 |
|
42 |
|
43 | ### Get the platform name
|
44 |
|
45 | os.platform();
|
46 |
|
47 |
|
48 | ### Get number of CPU
|
49 |
|
50 | os.countCPUs()
|
51 |
|
52 |
|
53 | ### Get current free memory
|
54 |
|
55 | os.freemem()
|
56 |
|
57 |
|
58 | ### Get total memory
|
59 |
|
60 | os.totalmem()
|
61 |
|
62 |
|
63 | ### Get a percentage reporesentinf the free memory
|
64 |
|
65 | os.freememPercentage()
|
66 |
|
67 |
|
68 | ### Get the number of miliseconds that the system has been running for.
|
69 |
|
70 | os.sysUptime();
|
71 |
|
72 |
|
73 | ### Get the number of miliseconds that the process has been running for.
|
74 |
|
75 | os.processUptime()
|
76 |
|
77 |
|
78 | ### Get average load for the 1, 5 or 15 minutes
|
79 |
|
80 | os.loadavg(1)
|
81 | os.loadavg(5)
|
82 | os.loadavg(15)
|
83 |
|