npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iostat-wrapper

v0.0.4

Published

A simple wrapper in NodeJS. Wrap iostat outputs into array of object for monitoring i/o usage on a unix machine. package sysstat is necessary.

Downloads

4

Readme

iostat-wrapper

Wrap iostat outputs into array of object.

Introduction

Wrapper around iostat for Node, providing 3 methods. Methods providing EventEmitter/Promise to get information, and an extra method only for data conversion.

Methods

RunIOStat(args): Run iostat and provide an EventEmitter to handle the output from iostat.

Data comes back as an event 'data'. You can bind the event like

    iostat.RunIOStat().on('data', (data, error)=>{
        console.log(data);
    });

Process(args): Provide an Promise to wrap RunIOStat method. This is to facilitate the use of .then() and await.

    iostat.Process(['-x']).then(data => {
        console.log(data);
    })

ToObject(rawOutput): Convert raw string output of iostat into array of objects. Returns an array.

Data schema

As the returned value, data would be an Array of Objects of this kind of form :

    [{ 
        Cpu: 
        { 
            '%user': 1.11,
            '%nice': 0.01,
            '%system': 1.11,
            '%iowait': 0.1,
            '%steal': 0,
            '%idle': 97.67 
        },
        Device: 
        { 
            'sda': 
            { 
                'rrqm/s': 1.23,
                'wrqm/s': 1.23,
                'r/s': 1.23,
                'w/s': 1.23,
                'rMB/s': 1.23,
                'wMB/s': 1.23,
                'rsec/s': 123.4,
                'wsec/s': 123.4,
                'avgrq-sz': 12.3,
                'avgqu-sz': 0.12,
                'await': 12.34,
                '%util': 12.34
            } 
        } 
    }]

The schema of data would be different according to the output of iostat. Only parameters in the returned table title of iostat cmdlet is included.

error will give out the error message if there is anything wrong with running iostat.

If need to run iostat in continuous mode, like with arguments ['-x','-m','1','2'], you will recieve an array of 2 objects. For now, this package can only return converted value after the iostat process is over. That is to say, when you run iostat with args like ['-x', '1'], the wrapper cannot give you any return value but keep waiting.

Takes iostat arguments as an array, ['-x', '-m'] by default. e.g : iostat.RunIOStat(['-x','-m', '1','2']) is to actually run iostat -x -m 1 2, and register an event emitter to return the output value after converted it into array of objects.

Examples

    var iostat = require('iostat-wrapper');
    iostat.RunIOStat(['-x','-m','1','2']).on('data', function(data, error) {
        console.log(stats);
        if (stats[0].Device.sda && stats[0].Device.sda["%util"] > 1)
            console("Too Heavy");
    });
    var iostat = require('iostat-wrapper');
    var data = await iostat.Process(['-x','-m','1','2']);
    console.log(100 - data[1].Cpu['%idle']);