# os-toolbox

> Operating-system toolbox to get system metrics.

Latest version **0.2.10** (published 2018-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install os-toolbox
pnpm add os-toolbox
yarn add os-toolbox
bun add os-toolbox
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.10 |
| Published | 2018-06-06 |
| First published | 2016-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 2 |
| Unpacked size | 14.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Matthieu Drouian |
| Maintainers | mrelier, ziggornif |
| Keywords | os, operating system, server, memory, cpu, monitor, stats, harddrive |

## Links

- npm: https://www.npmjs.com/package/os-toolbox
- Repository: https://github.com/Ziggornif/os-toolbox
- Homepage: https://github.com/Ziggornif/os-toolbox#readme
- Issues: https://github.com/Ziggornif/os-toolbox/issues
- npm.io page: https://npm.io/package/os-toolbox

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [current-processes](https://npm.io/package/current-processes.md) ^0.2.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.2.10 (latest) — 2018-06-06
- 0.2.9 — 2017-10-16
- 0.2.7 — 2017-06-23
- 0.2.6 — 2017-05-17
- 0.2.5 — 2017-04-05
- 0.2.4 — 2017-03-24
- 0.2.3 — 2017-03-01
- 0.2.2 — 2017-02-23
- 0.2.1 — 2017-02-04
- 0.2.0 — 2017-02-04
- 0.1.6 — 2017-02-02
- 0.1.5 — 2016-12-31
- 0.1.4 — 2016-12-15
- 0.1.3 — 2016-12-14
- 0.1.2 — 2016-12-13
- … 2 more at https://npm.io/package/os-toolbox/versions

## README

OS Toolbox
==========
[![NPM version][npm-image]][npm-url]
[![Build Status](https://travis-ci.org/Ziggornif/os-toolbox.svg?branch=master)](https://travis-ci.org/Ziggornif/os-toolbox)

## Installation
``` bash
$ npm install os-toolbox
```

## Usage

``` javascript
var ostb = require( 'os-toolbox' );
```

### Before use 
**/!\ All functions use promises !**

### Get platform
Get platform name.
``` javascript
ostb.platform(); //ex : linux
```

### Get uptime
Get system uptime in seconds.
``` javascript
ostb.uptime(); //ex : 419419
```

### Get CPU load
Get cpu load percentage.
``` javascript
ostb.cpuLoad().then(function(cpuusage){
   console.log(cpuusage); //ex: 34 (percent)
});
```

### Get memory usage
Get memory usage percentage.
``` javascript
ostb.memoryUsage().then(function(memusage){
   console.log(memusage); //ex: 93 (percent)
}, function(error){
    //errors here
});
```

### Get current processes
Get current running processes.
``` javascript
ostb.currentProcesses().then(function(processes){
   console.log(processes);
}, function(error){
    //errors here
});
```

**Using sort :**

Results could be sort by each attributes (cpu, memory, pid ...) (cf example)

Sort param format:
* type: pid, name, cpu or mem
* order: asc or desc

``` javascript
   { 
       type: 'cpu', 
       order: 'desc'
    }
```

Exemple:
``` javascript
ostb.currentProcesses(sort).then(function(processes){
   console.log(processes);
}, function(error){
    //errors here
});
```

**The following is an example current processes output :**

``` javascript
[ { pid: 2316, name: 'code', cpu: 4, mem: 1.114957060891639 },
  { pid: 2310, name: 'nautilus', cpu: 8, mem: 0.989467485779745 },
  { pid: 3867, name: 'notify-osd', cpu: 0, mem: 0.8229067957850149 },
  { pid: 2312, name: 'albert', cpu: 1, mem: 0.8190965839223904 },
  { pid: 1716, name: 'code', cpu: 0.3, mem: 0.8020248554469948 },
  { pid: 2457, name: 'code', cpu: 1.6, mem: 0.7947013313474048 }
]
```

### Get system services list (Linux only)
Get system services list.
``` javascript
ostb.services().then(function (result) {
   console.log(result);
}, function(error){
    //errors here
});
```

**Using filters :**

Results could be filtered by service name (cf example)

Filters param format:
``` javascript
   [{name: 'service'}, {name: ....]
```

Exemple:
``` javascript
ostb.services(filters).then(function (result) {
   console.log(result);
}, function(error){
    //errors here
});
```

**The following is an example system services output :**
``` javascript
[ { name: 'apache2', runing: false },
  { name: 'cron', runing: true },
  { name: 'dbus', runing: false },
  { name: 'exim4', runing: false },
  { name: 'nginx', runing: false },
  { name: 'php5-fpm', runing: false },
  { name: 'postgresql', runing: false },
  { name: 'procps', runing: false },
  { name: 'rabbitmq-server', runing: false },
  { name: 'redis-server', runing: false },
  { name: 'resolvconf', runing: true },
  { name: 'rsync', runing: false },
  { name: 'rsyslog', runing: false },
  { name: 'sudo', runing: false },
  { name: 'udev', runing: false },
  { name: 'unattended-upgrades', runing: false },
  { name: 'urandom', runing: false },
  { name: 'x11-common', runing: false } ]
```

## License

[MIT license](http://opensource.org/licenses/MIT). 

[npm-image]: https://img.shields.io/npm/v/os-toolbox.svg
[npm-url]: https://www.npmjs.com/package/os-toolbox

---
_Source: https://npm.io/package/os-toolbox · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
