Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oscmejia/os-utils
OS Utils
https://github.com/oscmejia/os-utils
Last synced: 2 months ago
JSON representation
OS Utils
- Host: GitHub
- URL: https://github.com/oscmejia/os-utils
- Owner: oscmejia
- License: mit
- Created: 2012-08-01T23:02:05.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2022-04-22T05:47:12.000Z (over 2 years ago)
- Last Synced: 2024-11-01T21:04:23.768Z (3 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 239
- Watchers: 6
- Forks: 39
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-github-star - os-utils
README
os-utils
========An operating system utility library. Some methods are wrappers of node libraries
and others are calculations made by the module.## Installation
One line installation with [npm](http://npmjs.org).
```bash
npm install os-utils
```Then in your code
```js
var os = require('os-utils');os.cpuUsage(function(v){
console.log( 'CPU Usage (%): ' + v );
});os.cpuFree(function(v){
console.log( 'CPU Free:' + v );
});
```## Usage
The following methods are available:
### Calculate CPU usage for the next second
This is not an average of CPU usage like it is in the "os" module. The callback will receive a parameter with the value.
```js
os.cpuUsage( function(value) { /* ... */ } );
```
### Calculate free CPU for the next second
This is not based on average CPU usage like it is in the "os" module. The callback will receive a parameter with the value.
```js
os.cpuFree( function(value) { /* ... */ } );
```
### Get the platform name
```js
os.platform();
```### Get number of CPUs
```js
os.cpuCount()
```### Get current free memory
```js
os.freemem()
```### Get total memory
```js
os.totalmem()
```### Get a current free memory percentage
```js
os.freememPercentage()
```### Get the number of seconds the system has been running for
```js
os.sysUptime();
```
### Get the number of seconds the process has been running
```js
os.processUptime()
```### Get average load for 1, 5 or 15 minutes
```js
os.loadavg(1)
os.loadavg(5)
os.loadavg(15)
```