systeminformation/docs/gettingstarted.html
Sebastian Hildebrandt 4c28e0ac8e updated docs
2020-04-26 11:22:50 +02:00

176 lines
8.7 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-LRlmVvLKVApDVGuspQFnRQJjkv0P7/YFrw84YYQtmYG4nK8c+M+NlmYDCv0rKWpG" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
<script src="main.js"></script>
<!-- Favicon -->
<link rel="icon" type="image/png" sizes="192x192" href="/assets/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/assets/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon-16x16.png">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<title>systeminformation</title>
</head>
<body>
<nav class="nav">
<div class="container">
<a href="."><img class="logo float-left" src="assets/logo.png">
<div class="title float-left">systeminformation</div>
</a>
<div class="text float-right github"><a href="https://github.com/sebhildebrandt/systeminformation">View on Github <i class="fab fa-github"></i></a></div>
<div class="text float-right todocs"><a href="./#docs">Docs Overview</a></div>
</div>
</nav>
<section class="container">
<div class="row">
<div class="col-12 col-md-4 col-lg-3 col-xl-2 menu" id="menu">
</div>
<div class="col-12 col-md-8 col-lg-9 col-xl-10 content">
<div class="row">
<div class="col-12 sectionheader">
<div class="title">Quick Start</div>
<div class="text">
<p>Lightweight collection of 40+ functions to retrieve detailed hardware, system and OS information.</p>
<ul>
<li>simple to use</li>
<li>get detailed information about system, cpu, baseboard, battery, memory, disks/filesystem, network, docker, software, services and processes</li>
<li>supports Linux, macOS, partial Windows, FreeBSD, OpenBSD, NetBSD and SunOS support</li>
<li>no npm dependencies (for production)</li>
</ul>
<h2>Core Concept</h2>
<p><a href="https://nodejs.org/en/" rel="nofollow">Node.js</a> comes with some basic OS information, but I always wanted a little more. So I came up to write this
little library. This library is still work in progress. It is supposed to be used as a <a href="https://nodejs.org/en/" rel="nofollow">node.js</a> backend/server-side library (will definilely not work within a browser). It requires node.js version 4.0 and above.</p>
<p>I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave) and some Windows 7, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines.
Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details.</p>
<p>If you have comments, suggestions &amp; reports, please feel free to contact me on <a href="https://github.com/sebhildebrandt/systeminformation/issues">github</a>!</p>
<p>I also created a nice little command line tool called <a href="https://github.com/sebhildebrandt/mmon" rel="nofollow">mmon</a> (micro-monitor) for Linux and macOS, also available via <a href="https://github.com/sebhildebrandt/mmon" rel="nofollow">github</a> and <a href="https://npmjs.org/package/mmon" rel="nofollow">npm</a></p>
<h2>Installation</h2>
<pre>$ npm install systeminformation --save</pre>
<h2>Usage</h2>
<p>All functions (except <span class="code">version</span> and <span class="code">time</span>) are implemented as asynchronous functions. Here a small example how to use them:</p>
<pre><code class="js">const si = require('systeminformation');
// promises style - new since version 3
si.cpu()
.then(data => console.log(data))
.catch(error => console.error(error));
</code></pre>
<h2>Callback, Promises, Async Await</h2>
<p>Remember: all functions (except <span class="code">version</span> and <span class="code">time</span>) are implemented as asynchronous functions! There are now three ways to consume them:</p>
<p><strong>Callback Style</strong></p>
<pre><code class="js">const si = require('systeminformation');
si.cpu(function(data) {
console.log('CPU Information:');
console.log('- manufucturer: ' + data.manufacturer);
console.log('- brand: ' + data.brand);
console.log('- speed: ' + data.speed);
console.log('- cores: ' + data.cores);
console.log('- physical cores: ' + data.physicalCores);
console.log('...');
})</code></pre><br>
<p><strong>Promise Style</strong></p>
<p>Promises style is new since version 3.0.<p></p>
<p>When omitting callback parameter (cb), then you can use all function in a promise oriented way. All functions (exept of <span class="code">version</span> and <span class="code">time</span>) are returning a promise, that you can consume:</p>
<pre><code class="js">const si = require('systeminformation');
si.cpu()
.then(data => {
console.log('CPU Information:');
console.log('- manufucturer: ' + data.manufacturer);
console.log('- brand: ' + data.brand);
console.log('- speed: ' + data.speed);
console.log('- cores: ' + data.cores);
console.log('- physical cores: ' + data.physicalCores);
console.log('...');
})
.catch(error => console.error(error));</code></pre><br>
<p><strong>Async/Await Style</strong></p>
<p>Since node v7.6 you can also use the async / await pattern. The above example would then look like this:</p>
<pre><code class="js">const si = require('systeminformation');
async function cpuData() {
try {
const data = await si.cpu();
console.log('CPU Information:');
console.log('- manufucturer: ' + data.manufacturer);
console.log('- brand: ' + data.brand);
console.log('- speed: ' + data.speed);
console.log('- cores: ' + data.cores);
console.log('- physical cores: ' + data.physicalCores);
console.log('...');
} catch (e) {
console.log(e)
}
}</code></pre><br>
<p><strong>Issues</strong></p>
<p>If you discover some empty or incorrect values, please be sure to first have a look at the <a href="issues.html">Known issues</a> section.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<footer class="container-fluid">
<div class="container">
<div class="row">
<div class="col-lg-4 col-12">
<ul class="list-unstyled">
<li><a href=".">Home</a></li>
<li><a href="https://github.com/sebhildebrandt/systeminformation">Github <i class="fab fa-github"></i></a></li>
<li><a href="contributors.html">Contributors</a></li>
<li><a href="https://buymeacoff.ee/systeminfo">Buy me a coffee</a></li>
</ul>
</div>
<div class="col-lg-4 col-12">
<ul class="list-unstyled">
<li><a href="gettingstarted.html">Quick Start</a></li>
<li><a href="issues.html">Known Issues</a></li>
<li><a href="statsfunctions.html">Stats Functions</a></li>
<li><a href="history.html">Version history</a></li>
</ul>
</div>
<div class="col-lg-4 col-12">
<ul class="list-unstyled">
<li><a href="https://www.plus-innovations.com">&copy; 2020 Sebastian Hildebrandt, +innovations</a></li>
<li><a href="copyright.html">Copyright &amp; License</a></li>
<li><a href="trademarks.html">Trademarks</a></li>
<li><a href="https://github.com/sebhildebrandt/systeminformation/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="MIT license" /></a></li>
</ul>
</div>
</div>
</div>
</footer>
<script>
window.onload = function (e) {
createMenu();
}
</script>
</body>
</html>