Skip to content

Commit

Permalink
dependencies update systeminformation v 5.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Dec 21, 2024
1 parent ce95b13 commit e79814d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 101 deletions.
111 changes: 56 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

![micro-monitor](https://www.plus-innovations.com/images/micro-monitor-logo.png)

micro-mon - Simple CLI system and OS information tool for Linux, macOS and windows implemented in [node.js][nodejs-url]
micro-mon - Simple CLI system and OS information tool for Linux, macOS and
windows implemented in [node.js][nodejs-url]

[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Git Issues][issues-img]][issues-url]
[![deps status][daviddm-img]][daviddm-url]
[![MIT license][license-img]][license-url]
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Git Issues][issues-img]][issues-url]
[![deps status][daviddm-img]][daviddm-url]
[![MIT license][license-img]][license-url]

## Quick Start

Expand Down Expand Up @@ -36,44 +37,45 @@ Press `q` (quit) or `CTRL-c` to exit mmon.
- users online
- [docker][docker-url] containers

I tested it on several Debian, Raspbian, Ubuntu distributions, inside Docker containers as well as OS X (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave, Catalina) and Windows 10.
I tested it on several Debian, Raspbian, Ubuntu distributions, inside Docker
containers as well as OS X (Mavericks, Yosemite, El Captain, Sierra, High
Sierra, Mojave, Catalina) and Windows 10.

This CLI tool depends on the [systeminformation][systeminformation-url] npm package that I wrote. Have a look at it, if you are interested.
This CLI tool depends on the [systeminformation][systeminformation-url] npm
package that I wrote. Have a look at it, if you are interested.

## Command Line Options

**Set interval**

The default update interval is 2 seconds but you can change it easily:
the following command line option sets it to 5 seconds:
The default update interval is 2 seconds but you can change it easily: the
following command line option sets it to 5 seconds:

```
mmon -i 5
```


## Version history

| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 2.0.0 | 2020-01-11 | added windows support, updated dependencies, fixes and refactoring |
| 1.1.5 | 2017-02-19 | dependencies bump |
| 1.1.4 | 2016-11-03 | minor refactoring, dependencies bump |
| 1.1.3 | 2016-11-02 | bug fix mem total, dependencies bump |
| 1.1.2 | 2016-08-30 | tiny fixes, design improvement |
| 1.1.1 | 2016-08-30 | systeminformation dependency bump |
| 1.1.0 | 2016-08-29 | top processes |
| 1.0.4 | 2016-08-23 | tiny fixes (merge, use strict) |
| 1.0.3 | 2016-08-19 | tiny improvement, updated copyright notes |
| 1.0.2 | 2016-08-19 | tiny fixes |
| 1.0.1 | 2016-08-19 | documentation update, colors |
| 1.0.0 | 2016-08-19 | initial version |
| Version | Date | Comment |
| ------- | ---------- | ------------------------------------------- |
| 1.2.0 | 2024-12-21 | dependencies bump - systeminformation 5.x.x |
| 1.1.5 | 2017-02-19 | dependencies bump |
| 1.1.4 | 2016-11-03 | minor refactoring, dependencies bump |
| 1.1.3 | 2016-11-02 | bug fix mem total, dependencies bump |
| 1.1.2 | 2016-08-30 | tiny fixes, design improvement |
| 1.1.1 | 2016-08-30 | systeminformation dependency bump |
| 1.1.0 | 2016-08-29 | top processes |
| 1.0.4 | 2016-08-23 | tiny fixes (merge, use strict) |
| 1.0.3 | 2016-08-19 | tiny improvement, updated copyright notes |
| 1.0.2 | 2016-08-19 | tiny fixes |
| 1.0.1 | 2016-08-19 | documentation update, colors |
| 1.0.0 | 2016-08-19 | initial version |

## Comments

If you have ideas or comments, please do not hesitate to contact me.


Happy monitoring!

Sincerely,
Expand All @@ -82,62 +84,61 @@ Sebastian Hildebrandt, [+innovations](http://www.plus-innovations.com)

## Credits

Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebrandt)
Written by Sebastian Hildebrandt
[sebhildebrandt](https://github.com/sebhildebrandt)

#### Contributers

- none so far. Comments, pull requests welcome ;-)

## Copyright Information

Linux is a registered trademark of Linus Torvalds, OS X is a registered trademark of Apple Inc.,
Windows is a registered trademark of Microsoft Corporation. Node.js is a trademark of Joyent Inc.,
Intel is a trademark of Intel Corporation, Raspberry Pi is a trademark of the Raspberry Pi Foundation,
Debian is a trademark of the Debian Project, Ubuntu is a trademark of Canonical Ltd., Docker is a trademark of Docker Inc.
All other trademarks are the property of their respective owners.
Linux is a registered trademark of Linus Torvalds, OS X is a registered
trademark of Apple Inc., Windows is a registered trademark of Microsoft
Corporation. Node.js is a trademark of Joyent Inc., Intel is a trademark of
Intel Corporation, Raspberry Pi is a trademark of the Raspberry Pi Foundation,
Debian is a trademark of the Debian Project, Ubuntu is a trademark of Canonical
Ltd., Docker is a trademark of Docker Inc. All other trademarks are the property
of their respective owners.

## License [![MIT license][license-img]][license-url]

>The [`MIT`][license-url] License (MIT)
> The [`MIT`][license-url] License (MIT)
>
>Copyright © 2014-2020 Sebastian Hildebrandt, [+innovations](http://www.plus-innovations.com).
> Copyright © 2014-2020 Sebastian Hildebrandt,
> [+innovations](http://www.plus-innovations.com).
>
>Permission is hereby granted, free of charge, to any person obtaining a copy
>of this software and associated documentation files (the "Software"), to deal
>in the Software without restriction, including without limitation the rights
>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
>copies of the Software, and to permit persons to whom the Software is
>furnished to do so, subject to the following conditions:
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
>The above copyright notice and this permission notice shall be included in
>all copies or substantial portions of the Software.
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
>THE SOFTWARE.
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
>
>Further details see [LICENSE](LICENSE) file.
> Further details see [LICENSE](LICENSE) file.
[npm-image]: https://img.shields.io/npm/v/mmon.svg?style=flat-square
[npm-url]: https://npmjs.org/package/mmon
[downloads-image]: https://img.shields.io/npm/dm/mmon.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/mmon

[license-url]: https://github.com/sebhildebrandt/mmon/blob/master/LICENSE
[license-img]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
[npmjs-license]: https://img.shields.io/npm/l/mmon.svg?style=flat-square
[systeminformation-url]: https://github.com/sebhildebrandt/systeminformation

[nodejs-url]: https://nodejs.org/en/
[docker-url]: https://www.docker.com/

[daviddm-img]: https://img.shields.io/david/sebhildebrandt/mmon.svg?style=flat-square
[daviddm-url]: https://david-dm.org/sebhildebrandt/mmon

[issues-img]: https://img.shields.io/github/issues/sebhildebrandt/mmon.svg?style=flat-square
[issues-url]: https://github.com/sebhildebrandt/mmon/issues
72 changes: 27 additions & 45 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function calc_primary_net() {
iface: iface_name,
ip4: iface_ip4,
ip6: iface_ip6
}
};
}
function calc_fs() {
let size = 0;
Expand All @@ -94,7 +94,7 @@ function calc_fs() {
used: used,
free: ((size && (size > used)) ? size - used : 0),
use: (size ? 100.0 * used / size : 0)
}
};
}

function calc_nwconn() {
Expand All @@ -109,7 +109,7 @@ function calc_nwconn() {
all: all,
established: established,
listen: listen
}
};
}

// ------------------------------------------------
Expand Down Expand Up @@ -143,8 +143,8 @@ function displayAll(first) {
let fssize = calc_fs();
let nwconn = calc_nwconn();
// console.log(cols.log(' CPU MEM FS DiskIO', 'white'));
console.log('CPU: ' + draw.progress(dynamicData.currentLoad.currentload, 37, true, true) + ' ' + cols.log('CPU: ', 'white') + draw.fmtNum(dynamicData.currentLoad.currentload, 2, 6, 70, 85) + ' % ' + cols.log('MEM: ', 'white') + draw.fmtNum(dynamicData.mem.used / dynamicData.mem.total * 100, 2, 6, 70, 85) + ' % ' + cols.log('FS: ', 'white') + draw.fmtNum(fssize.use, 2, 6, 70, 85) + ' %');
console.log('MEM: ' + draw.progress(dynamicData.mem.used / dynamicData.mem.total * 100, 37, true, true) + ' Speed:' + ' ' + draw.fmtNum(dynamicData.cpuCurrentspeed.avg, 2, 4) + 'GHz ' + 'Total: ' + draw.fmtNum(dynamicData.mem.total / 1073741824.0, 2, 6) + 'GB ' + 'Total:' + draw.fmtNum(fssize.size / 1073741824.0, 2, 9) + 'GB');
console.log('CPU: ' + draw.progress(dynamicData.currentLoad.currentLoad, 37, true, true) + ' ' + cols.log('CPU: ', 'white') + draw.fmtNum(dynamicData.currentLoad.currentLoad, 2, 6, 70, 85) + ' % ' + cols.log('MEM: ', 'white') + draw.fmtNum(dynamicData.mem.used / dynamicData.mem.total * 100, 2, 6, 70, 85) + ' % ' + cols.log('FS: ', 'white') + draw.fmtNum(fssize.use, 2, 6, 70, 85) + ' %');
console.log('MEM: ' + draw.progress(dynamicData.mem.used / dynamicData.mem.total * 100, 37, true, true) + ' Speed:' + ' ' + draw.fmtNum(dynamicData.cpuCurrentSpeed.avg, 2, 4) + 'GHz ' + 'Total: ' + draw.fmtNum(dynamicData.mem.total / 1073741824.0, 2, 6) + 'GB ' + 'Total:' + draw.fmtNum(fssize.size / 1073741824.0, 2, 9) + 'GB');
console.log('FS: ' + draw.progress(fssize.use, 37, true, true) + ' Temp:' + (dynamicData.temp && dynamicData.temp.main && dynamicData.temp.main > 0 ? draw.fmtNum(dynamicData.temp.main, 2, 7, 70, 90) : ' -.--') + ' °C ' + 'Free: ' + draw.fmtNum(dynamicData.mem.free / 1073741824.0, 2, 6) + 'GB ' + 'Free: ' + draw.fmtNum(fssize.free / 1073741824.0, 2, 8) + 'GB');

console.log();
Expand All @@ -155,19 +155,19 @@ function displayAll(first) {
lines.push('');

lines[0] = lines[0] + cols.log('FS Stats', 'white');
lines[1] = lines[1] + 'RX: ' + (dynamicData.fsStats.rx_sec >= 0 ? draw.fmtNum(dynamicData.fsStats.rx_sec, 2, 14, 500000, 1000000) + ' B/s' : ' - ');
lines[2] = lines[2] + 'WX: ' + (dynamicData.fsStats.wx_sec >= 0 ? draw.fmtNum(dynamicData.fsStats.wx_sec, 2, 14, 500000, 1000000) + ' B/s' : ' - ');
lines[3] = lines[3] + 'TX: ' + (dynamicData.fsStats.tx_sec >= 0 ? draw.fmtNum(dynamicData.fsStats.tx_sec, 2, 14, 500000, 1000000) + ' B/s' : ' - ');
lines[1] = lines[1] + 'RX: ' + (dynamicData.fsStats.rx_sec != null ? draw.fmtNum(dynamicData.fsStats.rx_sec, 2, 14, 500000, 1000000) + ' B/s' : ' - ');
lines[2] = lines[2] + 'WX: ' + (dynamicData.fsStats.wx_sec != null ? draw.fmtNum(dynamicData.fsStats.wx_sec, 2, 14, 500000, 1000000) + ' B/s' : ' - ');
lines[3] = lines[3] + 'TX: ' + (dynamicData.fsStats.tx_sec != null ? draw.fmtNum(dynamicData.fsStats.tx_sec, 2, 14, 500000, 1000000) + ' B/s' : ' - ');

lines[0] = lines[0] + ' ' + cols.log('IOPS', 'white');
lines[1] = lines[1] + ' ' + 'rIO: ' + (dynamicData.disksIO.rIO_sec >= 0 ? draw.fmtNum(dynamicData.disksIO.rIO_sec, 2, 10, 200, 500) + ' per s' : ' - ');
lines[2] = lines[2] + ' ' + 'wIO: ' + (dynamicData.disksIO.wIO_sec >= 0 ? draw.fmtNum(dynamicData.disksIO.wIO_sec, 2, 10, 200, 500) + ' per s' : ' - ');
lines[3] = lines[3] + ' ' + 'tIO: ' + (dynamicData.disksIO.tIO_sec >= 0 ? draw.fmtNum(dynamicData.disksIO.tIO_sec, 2, 10, 200, 500) + ' per s' : ' - ');
lines[1] = lines[1] + ' ' + 'rIO: ' + (dynamicData.disksIO.rIO_sec != null ? draw.fmtNum(dynamicData.disksIO.rIO_sec, 2, 10, 200, 500) + ' per s' : ' - ');
lines[2] = lines[2] + ' ' + 'wIO: ' + (dynamicData.disksIO.wIO_sec != null ? draw.fmtNum(dynamicData.disksIO.wIO_sec, 2, 10, 200, 500) + ' per s' : ' - ');
lines[3] = lines[3] + ' ' + 'tIO: ' + (dynamicData.disksIO.tIO_sec != null ? draw.fmtNum(dynamicData.disksIO.tIO_sec, 2, 10, 200, 500) + ' per s' : ' - ');

lines[0] = lines[0] + ' ' + cols.log('NET: ', 'white') + (' ' + primaryNet.iface).substr(-12);
lines[1] = lines[1] + ' ' + 'IP: ' + (' ' + primaryNet.ip4).substr(-15);
lines[2] = lines[2] + ' ' + 'RX: ' + (dynamicData.networkStats && dynamicData.networkStats[0] && dynamicData.networkStats[0].rx_sec >= 0 ? draw.fmtNum(dynamicData.networkStats[0].rx_sec, 2, 11, 100000, 200000) + ' B/s' : ' - ');
lines[3] = lines[3] + ' ' + 'TX: ' + (dynamicData.networkStats && dynamicData.networkStats[0] && dynamicData.networkStats[0].rx_sec >= 0 ? draw.fmtNum(dynamicData.networkStats[0].tx_sec, 2, 11, 100000, 200000) + ' B/s' : ' - ');
lines[2] = lines[2] + ' ' + 'RX: ' + (dynamicData.networkStats && dynamicData.networkStats[0] && dynamicData.networkStats[0].rx_sec != null ? draw.fmtNum(dynamicData.networkStats[0].rx_sec, 2, 11, 100000, 200000) + ' B/s' : ' - ');
lines[3] = lines[3] + ' ' + 'TX: ' + (dynamicData.networkStats && dynamicData.networkStats[0] && dynamicData.networkStats[0].rx_sec != null ? draw.fmtNum(dynamicData.networkStats[0].tx_sec, 2, 11, 100000, 200000) + ' B/s' : ' - ');

lines[0] = lines[0] + ' ' + cols.log('NW-Connect. ', 'white');
lines[1] = lines[1] + ' All: ' + draw.fmtNum(nwconn.all, 0, 4);
Expand All @@ -180,7 +180,7 @@ function displayAll(first) {
lines[3] = lines[3] + ' Blocked: ' + draw.fmtNum(dynamicData.processes.blocked, 0, 5);

lines.forEach(line => {
console.log(line)
console.log(line);
});

// Raster FS und UserUser
Expand Down Expand Up @@ -213,7 +213,7 @@ function displayAll(first) {
for (let i = 1; i <= 5; i++) {
if (i <= dynamicData.users.length) {
if (i < 5 || dynamicData.users.length == 5) {
lines[i] = lines[i] + draw.strLeft(dynamicData.users[i - 1].user, 16) + ' ' + draw.strLeft(dynamicData.users[i - 1].tty, 10) + ' ' + draw.strLeft(dynamicData.users[i - 1].ip, 15) + ' ' + draw.strRight(dynamicData.users[i - 1].date, 11)
lines[i] = lines[i] + draw.strLeft(dynamicData.users[i - 1].user, 16) + ' ' + draw.strLeft(dynamicData.users[i - 1].tty, 10) + ' ' + draw.strLeft(dynamicData.users[i - 1].ip, 15) + ' ' + draw.strRight(dynamicData.users[i - 1].date, 11);
} else {
lines[i] = lines[i] + '+' + draw.fmtNum(dynamicData.users.length - 4, 0, 2) + ' more users online...';
}
Expand All @@ -224,7 +224,7 @@ function displayAll(first) {

console.log();
lines.forEach(line => {
console.log(line)
console.log(line);
});

// Raster Processes
Expand All @@ -239,7 +239,7 @@ function displayAll(first) {
// Processes
lines[0] = lines[0] + cols.log('PID Top 5 Processes', 'white', 'darkgray') + cols.log(' State TTY User CPU% MEM%', 'lightgray', 'darkgray');
// top 5 processes
let topProcesses = dynamicData.processes.list.sort(function (a, b) { return ((b.pcpu - a.pcpu) * 100 + b.pmem - a.pmem) }).splice(0, 5);
let topProcesses = dynamicData.processes.list.sort(function (a, b) { return ((b.pcpu - a.pcpu) * 100 + b.pmem - a.pmem); }).splice(0, 5);
for (let i = 1; i <= 5; i++) {
if (i <= topProcesses.length) {
lines[i] = lines[i] +
Expand All @@ -248,16 +248,16 @@ function displayAll(first) {
draw.strLeft(topProcesses[i - 1].state, 10) + ' ' +
draw.strLeft(topProcesses[i - 1].tty, 11) + ' ' +
draw.strLeft(topProcesses[i - 1].user, 16) + ' ' +
draw.fmtNum(topProcesses[i - 1].pcpu < 100 ? topProcesses[i - 1].pcpu : 100, 2, 6, 70, 85) + ' ' +
draw.fmtNum(topProcesses[i - 1].pmem, 2, 6, 70, 85);
draw.fmtNum(topProcesses[i - 1].cpu < 100 ? topProcesses[i - 1].cpu : 100, 2, 6, 70, 85) + ' ' +
draw.fmtNum(topProcesses[i - 1].mem, 2, 6, 70, 85);
} else {
lines[i] = ' '.repeat(110);
}
}

console.log();
lines.forEach(line => {
console.log(line)
console.log(line);
});

// Raster Docker
Expand Down Expand Up @@ -288,12 +288,12 @@ function displayAll(first) {
}
}
if (dockerData.length == 0) {
lines[3] = cols.log(' No Docker Containers found ...', 'darkgray')
lines[3] = cols.log(' No Docker Containers found ...', 'darkgray');
}

console.log();
lines.forEach(line => {
console.log(line)
console.log(line);
});

lines = [];
Expand All @@ -306,28 +306,10 @@ function displayAll(first) {

console.log();
lines.forEach(line => {
console.log(line)
console.log(line);
});
console.log();

/*
lines[0] = draw.strAdd(lines[0], , 25);
lines[1] = draw.strAdd(lines[1], , 25);
lines[2] = draw.strAdd(lines[2], , 25);
lines[3] = draw.strAdd(lines[3], , 25);
console.log();
console.log(cols.log('NET: ', 'white') + (' ' + primaryNet.iface.substr(-11)));
console.log('IP: ' + (' ' + primaryNet.ip4).substr(-15));
console.log('RX: ' + (dynamicData.networkStats.rx_sec >= 0 ? draw.fmtNum(dynamicData.networkStats.rx_sec, 2, 11, 100000, 200000) + ' B/s' : ' -'));
console.log('TX: ' + (dynamicData.networkStats.tx_sec >= 0 ? draw.fmtNum(dynamicData.networkStats.tx_sec, 2, 11, 100000, 200000) + ' B/s' : ' -'));
*/
// console.log(cols.log('NET: ', 'white') + (' ' + (fssize.use).toFixed(2)).substr(-5) + '%');
// console.log('Total: ' + (' ' + (fssize.size / 1073741824.0).toFixed(2)).substr(-7) + 'GB');
// console.log('Free: ' + (' ' + (fssize.free / 1073741824.0).toFixed(2)).substr(-7) + 'GB');

//console.log('\n\n\n\n');

console.log(cols.log(footer(), 'black', 'gray'));
draw.hide();
}
Expand Down Expand Up @@ -384,7 +366,7 @@ function getStaticData(callback) {
// ------------------------------------------------
function exitHandler(options, err) {
if (options.cleanup) { }
if (err) { console.log(err.stack) } //;
if (err) { console.log(err.stack); } //;
if (options.exit) {
// draw.show();
// draw.clear();
Expand Down Expand Up @@ -438,13 +420,13 @@ getStaticData().then(resultStatic => {
si.getDynamicData().then(resultDynamic => {
_.merge(dynamicData, resultDynamic);
displayAll(false);
})
});
}, interval);
setInterval(function () {
si.dockerAll().then(resultDocker => {
dockerData = resultDocker;
})
}, dockerinterval)
});
}, dockerinterval);
});

});
Expand Down
Loading

0 comments on commit e79814d

Please sign in to comment.