Get disk usage info
npm install @dropb/diskinfo> Disk usage info on both \*nix (via df) and Windows (via WMIC) systems
[![npm z][npm-image]][npm-url]
[![Build status][test-image]][test-url]
``sh`
npm install @dropb/diskinfo
`js
// JS example (Windows)
const { diskinfo } = require('@dropb/diskinfo');
diskinfo()
.then(result => console.log(result))
.catch(err => console.error(err.message));
/* OUTPUT:
[{
fstype: '3',
size: 185429127168,
used: 51971362816,
avail: 133457764352,
pcent: '29%',
target: 'C:'
},
{
fstype: '2',
size: 16046358528,
used: 4434288640,
avail: 11612069888,
pcent: '28%',
target: 'F:'
},
{
fstype: '4',
size: 107569381376,
used: 106081509376,
avail: 1487872000,
pcent: '99%',
target: 'V:'
}]
*/
`
`ts
// Typescript example (Ubuntu)
import { diskinfo, DiskInfo } from '@dropb/diskinfo';
async function run() {
const result: DiskInfo = await diskinfo('./');
console.log(result);
}
run();
/* OUTPUT:
{ fstype: '/dev/sda1',
size: 47242534912,
used: 21033943040,
avail: 23785177088,
pcent: '47%',
target: '/' }
*/
`
`ts
/**
* @param file - get info of the filesystem containing the specified file or directory
* @returns promise for an object with the info for the specified file or directory
*/
function diskinfo(file: string): Promise
/**
* @returns promise for an array with the info for all mounted filesystem
*/
function diskinfo(): Promise
/**
* Info of the filesystem
*/
interface DiskInfo {
/**
* POSIX - File system type
*
* Win32 - Win32_LogicalDisk DriveType(as String!):``
* - "0": Unknown
* - "1": No Root Directory
* - "2": Removable Disk
* - "3": Local Disk
* - "4": Network Drive
* - "5": Compact Disc
* - "6": RAM Disk
*/
fstype: string;
/**
* Total size in bytes
*/
size: number;
/**
* Used size in bytes
*/
used: number;
/**
* Available size in bytes
*/
avail: number;
/**
* Percentage of used divided by size
*/
pcent: string;
/**
* Mount point
*/
target: string;
}
- df
- Win32_LogicalDisk WMI class.aspx>)
[npm-image]: https://badge.fury.io/js/%40dropb%2Fdiskinfo.svg
[npm-url]: https://www.npmjs.com/package/@dropb/diskinfo
[test-image]: https://github.com/kukhariev/diskinfo/workflows/Node%20CI/badge.svg
[test-url]: https://github.com/kukhariev/diskinfo