What is systeminformation?
The systeminformation package is a Node.js library that provides detailed information about the system it's running on. It can retrieve data about the CPU, memory, disks, network, battery, and more. It is designed to be a comprehensive tool for system monitoring and hardware details retrieval in Node.js applications.
What are systeminformation's main functionalities?
System Information
Retrieve general information about the system like manufacturer, model, version, and serial number.
const si = require('systeminformation');
si.system().then(data => console.log(data));
CPU Information
Get detailed information about the CPU, including brand, speed, and cores.
const si = require('systeminformation');
si.cpu().then(data => console.log(data));
Memory Information
Access information about the system's memory, such as total, free, and used memory.
const si = require('systeminformation');
si.mem().then(data => console.log(data));
Disk Information
Provides information about the disk layout, including type and size of each disk.
const si = require('systeminformation');
si.diskLayout().then(data => console.log(data));
Network Information
Gather data on network interfaces, including IP addresses, MAC addresses, and status.
const si = require('systeminformation');
si.networkInterfaces().then(data => console.log(data));
Battery Information
Check the status of the battery, its capacity, and whether it's charging.
const si = require('systeminformation');
si.battery().then(data => console.log(data));
Other packages similar to systeminformation
os-utils
os-utils is a package that provides basic operating system-related utility functions. It is less comprehensive than systeminformation, focusing mainly on CPU usage, free memory, and uptime.
vitalsigns
vitalsigns is a package designed for health monitoring of Node.js applications. It can track CPU and memory usage, but it is more focused on application health rather than detailed system information.
systeminformation
Simple system and OS information library for node.js
Using systeminformation
Installation
$ npm install systeminformation
Usage
All functions are implemented as asynchronous functions. Here a small example how to use them:
var si = require('systeminformation');
si.cpu(function(data) {
console.log('CPU-Information:');
console.log(data);
})
Core concept
Node.JS comes with some basic OS-informations, but I always wanted a little more. So I came up to write this little library. This library is work in progress. It is quite "fresh" - means, there might be a lot of inconsistencies or even bugs. I was only able to test it on some Debian and Ubuntu distributions as well as OSX (Maveriks). But be carefull, not all options will work on OSX. AND: this library will definitely NOT work on Windows platforms!
If you have comments, suggestions & reports, please feel free to contact me!
Reference
Sections
This library is splitted in several sections:
- Operating System
- CPU
- Memory
- File System
- Network
- Processes
- Users
- Internet
Command Reference and OS Support
command | Linux | OSX | Comments |
---|
si.osinfo() | X | X | OS information |
- platform | X | X | 'Linux' or 'Darwin' |
- distro | X | X | |
- release | X | X | |
- codename | | X | |
- kernel | X | X | kernel release - same as os.release() |
- arch | X | X | same as os.arch() |
- hostname | X | X | same as os.hostname() |
- logofile | X | X | e.g. 'apple', 'debian', 'fedora', ... |
si.cpu() | X | X | CPU information |
- brand | X | X | e.g. 'Intel(R)' |
- speed | X | X | e.g. '3.40GHz' |
si.cpu_currentspeed() | X | X | current speed (GHz) |
si.cores() | X | X | # cores |
si.cpu_temperature() | X | | CPU temperature (if sensors is installed) |
- main | X | X | main temperature |
- cores | X | X | array of temperatures |
si.mem() | X | X | Memory information |
- total | X | X | |
- free | X | X | |
- used | X | X | |
- active | X | X | |
- buffcache | X | X | |
- swaptotal | X | | |
- swapused | X | | |
- swapfree | X | | |
si.fs_size() | X | X | returns array of mounted file systems |
- [0].fs | X | X | name of file system |
- [0].size | X | X | sizes in Bytes |
- [0].used | X | X | used in Bytes |
- [0].use | X | X | used in % |
- [0].mount | X | X | mount point |
si.fs_speed() | X | | currend transfer speed |
- read_sec | X | | bytes read / second |
- write_sec | X | | bytes written / second |
si.network_interfaces() | X | X | array of network interfaces |
- [0].iface | X | X | interface name |
- [0].ip4 | X | X | ip4 address |
- [0].ip6 | X | X | ip6 address |
si.network_speed('eth1') | X | | current network speed of given interface |
- operstate | X | | up / down |
- rx_sec | X | | received bytes / second |
- tx_sec | X | X | transferred bytes per second |
si.currentload() | X | X | CPU-Load in % |
si.fullload() | X | X | CPU-full load since bootup in % |
si.services('mysql, apache2, nginx') | X | X | pass comma separated string of services |
- [0].service | X | X | name of service |
- [0].running | X | X | true / false |
- [0].pcpu | X | X | process % CPU |
- [0].pmem | X | X | process % MEM |
si.processes() | X | X | # running processes |
si.processload('apache2') | X | X | detailed information about given process |
- proc | X | X | process name |
- pid | X | X | PID |
- cpu | X | X | process % CPU |
- mem | X | X | process % MEM |
si.users() | X | X | array of users online |
si.checksite(url) | X | X | response-time (ms) to fetch given URL |
Remember: All functions are implemented as asynchronous functions! So another example, how to use a specific function might be:
var si = require('systeminformation');
si.network_speed('eth1', function(data) {
console.log('Network Interface Speed (eth1):');
console.log('- is up: ' + data.operstate);
console.log('- RX speed/sec: ' + data.rx_sec);
console.log('- TX speed/sec: ' + data.tx_sec);
})
Version history
Version | Date | Comment |
---|
1.0.0 | 2015-07-18 | bug-fixes, version bumb, published as npm component |
0.0.3 | 2014-04-14 | bug-fix (cpu_speed) |
0.0.2 | 2014-03-14 | Optimization FS-Speed & CPU current speed |
0.0.1 | 2014-03-13 | initial release |
If you have ideas or comments, please do not hesitate to contact me.
Happy monitoring!
Sincerely,
Sebastian Hildebrandt
http://www.plus-innovations.com
Credits
Written by Sebastian Hildebrandt sebhildebrandt
License
The MIT License (MIT)
Copyright (c) 2015 +innovations.
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 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.