Nixfs

November 26, 2019 · View on GitHub

version N-API Maintenance MIT dep size known vulnerabilities Build Status Greenkeeper badge

SlimIO Nixfs is a Node.js binding which bring information about filesystem configuration and consumption. This module has been designed for UNIX systems.

OS Support

LinuxFreeBSDOpenBSDSunMac (OS X)
✔️⚠️⚠️

⚠️ WORK IN PROGRESS

Requirements

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @slimio/nixfs
# or
$ yarn add @slimio/nixfs

Usage example

const Nixfs = require("@slimio/nixfs");

async function main() {
    const mntEntries = await Nixfs.getMountedEntries();
    for (const ent of mntEntries) {
        console.log(`Entry name: ${ent.name}`);
        const fileSystemStat = await Nixfs.getStatFS(ent.dir);
        console.log(fileSystemStat);
        console.log("-----------------\n");
    }
}
main().catch(console.error);

API

getMountedEntries(): Promise< mountentry[] >

Retrieve mounted entries on the local system. Return an array of mountentry object. On FreeBSD the data is retrieved by reading the /etc/fstab file.

interface mountentry {
    dir: string;
    name: string;
    type: string;
    freq: number;
    passno: number;
    options: string[];
}
getStatFS(dir: string): Promise< fsstat >

Retrieve statistic for a given file system directory. Return an fsstat Object. It use UNIX statfs under the hood.

interface fsstat {
    type: string;
    typeId: number;
    bsize: number;
    blocks: number;
    bfree: number;
    bavail: number;
    files: number;
    ffree: number;
    availableSpace: number;
    fsid?: [number, number];
    nameLen: number;
}

Note: fsid is not available on freebsd!

getDiskStats(): Promise< diskstat[] >

Retrieve all Disks statistics. Return an array of diskstat object. The data is retrieved by reading the /proc/diskstats file (a documentation describing this file can be found here)

interface diskstat {
    devName: string;
    major: number;
    minor: number;
    rdIos: number;
    rdMergesOrRdSec: number;
    rdSecOrWrIos: number;
    rdTicksOrWrSec: number;
    wrIos: number;
    wrMerges: number;
    wrSec: number;
    wrTicks: number;
    iosPgr: number;
    totTicks: number;
    rqTicks: number;
}

Contribution Guidelines

To contribute to the project, please read the code of conduct and the guide for N-API compilation.

Dependencies

NameRefactoringSecurity RiskUsage
node-addon-api⚠️MajorLowNode.js C++ addon api
node-gyp-build⚠️MajorLowNode-gyp builder

License

MIT