Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nswbmw/cpu-memory-monitor
CPU & Memory Monitor, auto dump.
https://github.com/nswbmw/cpu-memory-monitor
coredump cpu memory monitoring snapshot
Last synced: about 1 month ago
JSON representation
CPU & Memory Monitor, auto dump.
- Host: GitHub
- URL: https://github.com/nswbmw/cpu-memory-monitor
- Owner: nswbmw
- Created: 2017-07-11T09:32:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-14T08:37:29.000Z (over 5 years ago)
- Last Synced: 2024-07-19T10:31:00.067Z (5 months ago)
- Topics: coredump, cpu, memory, monitoring, snapshot
- Language: JavaScript
- Size: 5.86 KB
- Stars: 27
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-nodejs - cpu-memory-monitor - CPU & Memory Monitor, auto dump. ![](https://img.shields.io/github/stars/nswbmw/cpu-memory-monitor.svg?style=social&label=Star) (Repository / Performance Profiling/Analysis)
- awesome-github-star - cpu-memory-monitor
README
## cpu-memory-monitor
CPU & Memory Monitor, auto dump.
### Install
```
$ npm i cpu-memory-monitor --save
```### Usage
```
require('cpu-memory-monitor')(options)
```example:
```javascript
require('cpu-memory-monitor')({
cpu: {
interval: 1000,
duration: 30000,
threshold: 60,
profileDir: '/tmp',
counter: 3,
limiter: [5, 'hour']
},
memory: {
interval: 5000,
threshold: '500mb',
...
}
})
```will generate:
```
cpu-${process.pid}-${Date.now()}.cpuprofile
memory-${process.pid}-${Date.now()}.heapsnapshot
leak-memory-${process.pid}-${Date.now()}.heapsnapshot
``````
require('cpu-memory-monitor')({
cpu: {
interval: 1000,
duration: 30000,
threshold: 60,
profileDir: '/tmp',
counter: 3,
limiter: [5, 'hour']
}
})
```**means**: every `1000ms` check CPU usage, when CPU(%) > `60%` for `3` times, then dump `30000ms` CPU usage(`.cpuprofile`) to `/tmp`, dump could be triggered at most `5` times an `hour`.
you can also use:
```bash
$ kill -USR2 PID
```see [heapdump](https://github.com/bnoordhuis/node-heapdump).
### Options
- cpu`{Object}`
- interval`{Number}`: interval(ms) for check CPU usage, default: `1000`
- duration`{Number}`: duration(ms) for profiling CPU, default: `30000`
- threshold`{Number}:` process max CPU(%) usage, default: `90`
- profileDir`{String}`: directory for save cpuprofile, default: `process.cwd()`
- counter`{Number}:` the number of CPU > threshold, then dump, default: `1`
- limiter`{Array}`: options pass to [limiter](https://github.com/jhurliman/node-rate-limiter), default: `[3, 'hour']`
- memory`{Object}`
- interval`{Number}`: interval(ms) for check Memory usage, default: `1000`
- threshold`{String}:` process max Memory usage, default: `1.2gb`, see [bytes](https://github.com/visionmedia/bytes.js)
- profileDir`{String}`: directory for save heapsnapshot, default: `process.cwd()`
- counter`{Number}:` the number of Memory > threshold, then dump, default: `1`
- limiter`{Array}`: options pass to [limiter](https://github.com/jhurliman/node-rate-limiter), default: `[3, 'hour']`**NB**: If omit cpu/memory option, cpu-momery-monitor will not monitor it.
### License
MIT