systeminformation/docs/filesystem.html
2021-01-25 19:57:24 +01:00

897 lines
29 KiB
HTML

<!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.15.1/css/all.css" integrity="sha384-9ZfPnbegQSumzaE7mks2IYgHoayLtuto3AS6ieArECeaR8nCfliJVuLh/GaQ1gyM" crossorigin="anonymous">
<link rel="stylesheet" href="roboto/css/roboto.css">
<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">Disks and File System</div>
<div class="text">
<p>In this section you will learn how to get disks information, file system information, disk I/O stats and file system stats:</p>
<p>For function reference and examples we assume, that we imported <span class="code">systeminformation</span> as follows:</p>
<pre><code class="js">const si = require('systeminformation');</code></pre>
<h2>Disk Layout, Block Devices and Disks IO</h2>
<p>All functions in this section return a promise or can be called with a callback function (parameter <span class="code">cb</span> in the function reference)</p>
<table class="table table-sm table-bordered table-striped">
<thead>
<tr>
<th>Function</th>
<th>Result object</th>
<th>Linux</th>
<th>BSD</th>
<th>Mac</th>
<th>Win</th>
<th>Sun</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td>si.diskLayout(cb)</td>
<td>[{...}]</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>physical disk layout (array)</td>
</tr>
<tr>
<td></td>
<td>[0].device</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>e.g. /dev/sda</td>
</tr>
<tr>
<td></td>
<td>[0].type</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>HD, SSD, NVMe</td>
</tr>
<tr>
<td></td>
<td>[0].name</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>disk name</td>
</tr>
<tr>
<td></td>
<td>[0].vendor</td>
<td>X</td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>vendor/producer</td>
</tr>
<tr>
<td></td>
<td>[0].size</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>size in bytes</td>
</tr>
<tr>
<td></td>
<td>[0].totalCylinders</td>
<td></td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>total cylinders</td>
</tr>
<tr>
<td></td>
<td>[0].totalHeads</td>
<td></td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>total heads</td>
</tr>
<tr>
<td></td>
<td>[0].totalTracks</td>
<td></td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>total tracks</td>
</tr>
<tr>
<td></td>
<td>[0].totalSectors</td>
<td></td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>total sectors</td>
</tr>
<tr>
<td></td>
<td>[0].tracksPerCylinder</td>
<td></td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>tracks per cylinder</td>
</tr>
<tr>
<td></td>
<td>[0].sectorsPerTrack</td>
<td></td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>sectors per track</td>
</tr>
<tr>
<td></td>
<td>[0].bytesPerSector</td>
<td></td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>bytes per sector</td>
</tr>
<tr>
<td></td>
<td>[0].firmwareRevision</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>firmware revision</td>
</tr>
<tr>
<td></td>
<td>[0].serialNum</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>serial number</td>
</tr>
<tr>
<td></td>
<td>[0].interfaceType</td>
<td>X</td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>SATA, PCIe, ...</td>
</tr>
<tr>
<td></td>
<td>[0].smartStatus</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>S.M.A.R.T Status (see Known Issues)</td>
</tr>
<tr>
<td></td>
<td>[0].smartData</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>full S.M.A.R.T data from smartctl<br>requires at least smartmontools 7.0<br>(see Known Issues)</td>
</tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
si.diskLayout().then(data => console.log(data));</code></pre class="example">
<pre class="example">
[
{
device: '/dev/nvme0n1',
type: 'NVMe',
name: 'SAMSUNG xxxxxxxxxxxx-xxxx',
vendor: 'Samsung',
size: 1024209543168,
bytesPerSector: null,
totalCylinders: null,
totalHeads: null,
totalSectors: null,
totalTracks: null,
tracksPerCylinder: null,
sectorsPerTrack: null,
firmwareRevision: '',
serialNum: '...serial....',
interfaceType: 'PCIe',
smartStatus: 'unknown',
smartData: {
json_format_version: [Array],
smartctl: [Object],
device: [Object],
model_name: 'SAMSUNG xxxxxxxxxxxx-xxxx',
serial_number: '...serial....',
...
}
},
{
...
}
]</pre>
</tr>
<tr>
<td>si.blockDevices(cb)</td>
<td>[{...}]</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>returns array of disks, partitions,<br />raids and roms</td>
</tr>
<tr>
<td></td>
<td>[0].name</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>name</td>
</tr>
<tr>
<td></td>
<td>[0].type</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>type</td>
</tr>
<tr>
<td></td>
<td>[0].fstype</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>file system type (e.g. ext4)</td>
</tr>
<tr>
<td></td>
<td>[0].mount</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>mount point</td>
</tr>
<tr>
<td></td>
<td>[0].size</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>size in bytes</td>
</tr>
<tr>
<td></td>
<td>[0].physical</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>physical type (HDD, SSD, CD/DVD)</td>
</tr>
<tr>
<td></td>
<td>[0].uuid</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>UUID</td>
</tr>
<tr>
<td></td>
<td>[0].label</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>label</td>
</tr>
<tr>
<td></td>
<td>[0].model</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>model</td>
</tr>
<tr>
<td></td>
<td>[0].serial</td>
<td>X</td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>serial</td>
</tr>
<tr>
<td></td>
<td>[0].removable</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>serial</td>
</tr>
<tr>
<td></td>
<td>[0].protocol</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>protocol (SATA, PCI-Express, ...)</td>
</tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
si.blockDevices().then(data => console.log(data));</code></pre class="example">
<pre class="example">
[
{
name: 'nvme0n1',
type: 'disk',
fstype: '',
mount: '',
size: 1024209543168,
physical: 'SSD',
uuid: '',
label: '',
model: 'SAMSUNG xxxxxxxxxxxx-xxxx',
serial: '... serial ...',
removable: false,
protocol: 'nvme',
group: undefined
},
{
...
}
]</pre>
</tr>
<tr>
<td>si.disksIO(cb)</td>
<td>{...}</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>current transfer stats</td>
</tr>
<tr>
<td></td>
<td>rIO</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>read IOs on all mounted drives</td>
</tr>
<tr>
<td></td>
<td>wIO</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>write IOs on all mounted drives</td>
</tr>
<tr>
<td></td>
<td>tIO</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>write IOs on all mounted drives</td>
</tr>
<tr>
<td></td>
<td>rIO_sec</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>read IO per sec (* see notes)</td>
</tr>
<tr>
<td></td>
<td>wIO_sec</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>write IO per sec (* see notes)</td>
</tr>
<tr>
<td></td>
<td>tIO_sec</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>total IO per sec (* see notes)</td>
</tr>
<tr>
<td></td>
<td>ms</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>interval length (for per second values)</td>
</tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
setInterval(function() {
si.disksIO().then(data => {
console.log(data);
})
}, 1000)</code></pre class="example">
<pre class="example">
{ // first call
rIO: 899825,
wIO: 932331,
tIO: 1832156,
rIO_sec: null,
wIO_sec: null,
tIO_sec: null,
ms: 0
}
{ // second call
rIO: 899863,
wIO: 932331,
tIO: 1832194,
rIO_sec: 38.5395537525355,
wIO_sec: 0,
tIO_sec: 38.5395537525355,
ms: 986
}...</pre>
</tr>
</tbody>
</table>
<h2>File System and File System Stats</h2>
<table class="table table-sm table-bordered table-striped">
<thead>
<tr>
<th>Function</th>
<th>Result object</th>
<th>Linux</th>
<th>BSD</th>
<th>Mac</th>
<th>Win</th>
<th>Sun</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td>si.fsSize(cb)</td>
<td>[{...}]</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td>returns array of mounted file systems</td>
</tr>
<tr>
<td></td>
<td>[0].fs</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td>name of file system</td>
</tr>
<tr>
<td></td>
<td>[0].type</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td>type of file system</td>
</tr>
<tr>
<td></td>
<td>[0].size</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td>sizes in bytes</td>
</tr>
<tr>
<td></td>
<td>[0].used</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td>used in bytes</td>
</tr>
<tr>
<td></td>
<td>[0].use</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td>used in %</td>
</tr>
<tr>
<td></td>
<td>[0].mount</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td>mount point</td>
</tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
si.fsSize().then(data => console.log(data));</code></pre class="example">
<pre class="example">
[
{
fs: '/dev/md2',
type: 'ext4',
size: 972577361920,
used: 59142635520,
use: 6.08,
mount: '/'
},
{
...
}
]</pre>
</tr>
<tr>
<td>si.fsOpenFiles(cb)</td>
<td>{...}</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td>count max/allocated file descriptors</td>
</tr>
<tr>
<td></td>
<td>max</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td>count max</td>
</tr>
<tr>
<td></td>
<td>allocated</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td>count allocated</td>
</tr>
<tr>
<td></td>
<td>available</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td>count available</td>
</tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
si.fsOpenFiles().then(data => console.log(data));</code></pre class="example">
<pre class="example">
{
max: 6566555,
allocated: 1856,
available: 0
}</pre>
</tr>
<tr>
<td>si.fsStats(cb)</td>
<td>{...}</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>current transfer stats</td>
</tr>
<tr>
<td></td>
<td>rx</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>bytes read since startup</td>
</tr>
<tr>
<td></td>
<td>wx</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>bytes written since startup</td>
</tr>
<tr>
<td></td>
<td>tx</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>total bytes read + written since startup</td>
</tr>
<tr>
<td></td>
<td>rx_sec</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>bytes read / second (* see notes)</td>
</tr>
<tr>
<td></td>
<td>wx_sec</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>bytes written / second (* see notes)</td>
</tr>
<tr>
<td></td>
<td>tx_sec</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>total bytes reads + written / second</td>
</tr>
<tr>
<td></td>
<td>ms</td>
<td>X</td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td>interval length (for per second values)</td>
</tr>
<tr class="example">
<td></td>
<td colspan="7">
<h5>Example</h5>
<pre><code class="js">const si = require('systeminformation');
setInterval(function() {
si.fsStats().then(data => {
console.log(data);
})
}, 1000)</code></pre class="example">
<pre class="example">
{ // first call
rx: 14015849472,
wx: 15316003328,
tx: 29331852800,
rx_sec: null,
wx_sec: null,
tx_sec: null,
ms: 0
}
{ // second call
rx: 14015849472,
wx: 15316007424,
tx: 29331856896,
rx_sec: 0,
wx_sec: 4083.748753738784,
tx_sec: 4083.748753738784,
ms: 1003
}...</pre>
</tr>
</tbody>
</table>
<h4>Getting correct stats values</h4>
<p>In <span class="code">disksIO()</span> and <span class="code">fsStats()</span> the
results / sec. values (rx_sec, IOPS, ...) are calculated correctly beginning with the <strong>second</strong> call of the function.
It is determined by calculating the difference of transferred bytes / IOs divided by the time between two calls of the function.</p>
<p>The first time you are calling one of this functions, you will get <span class="code">-1</span> for transfer rates.
The second time, you should then get statistics based on the time between the two calls ...</p>
<p>So basically, if you e.g. need a values for filesystem stats stats every second, your code should look like this:</p>
<pre><code class="js">const si = require('systeminformation');
setInterval(function() {
si.fsStats().then(data => {
console.log(data);
})
}, 1000)</code></pre>
<p>Beginning with the second call, you get file system transfer values per second.</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="." class="medium home">Home</a></li>
<li>&nbsp;</li>
<li><a href="security.html">Security Advisories&nbsp;&nbsp;<i class="fas fa-shield-check"></i></a></li>
<li><a href="https://github.com/sebhildebrandt/systeminformation">Github <i class="fab fa-github"></i></a></li>
<li><a href="https://buymeacoff.ee/systeminfo" class="medium badge bg-primary"><i class="fas fa-coffee"></i>&nbsp;&nbsp;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="changes.html">Version 5 Changes</a></li>
<li><a href="history.html">Full Version history</a></li>
<li><a href="issues.html">Known Issues</a></li>
<li><a href="statsfunctions.html">Stats Functions</a></li>
</ul>
</div>
<div class="col-lg-4 col-12">
<ul class="list-unstyled">
<li><a href="contributors.html">Contributors</a></li>
<li><a href="trademarks.html">Trademarks</a></li>
<li><a href="copyright.html">Copyright &amp; License&nbsp;&nbsp;<img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="MIT license" /></a></li>
<li><a href="https://www.plus-innovations.com">&copy; 2021 Sebastian Hildebrandt</a></li>
<li><a href="https://www.plus-innovations.com">+innovations GmbH</a></li>
</ul>
</div>
</div>
</div>
</footer>
<script>
window.onload = function (e) {
createMenu();
}
</script>
</body>
</html>