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

os-toolbox

v0.2.10

Published

Operating-system toolbox to get system metrics.

Downloads

69

Readme

OS Toolbox

NPM version Build Status

Installation

$ npm install os-toolbox

Usage

var ostb = require( 'os-toolbox' );

Before use

/!\ All functions use promises !

Get platform

Get platform name.

ostb.platform(); //ex : linux

Get uptime

Get system uptime in seconds.

ostb.uptime(); //ex : 419419

Get CPU load

Get cpu load percentage.

ostb.cpuLoad().then(function(cpuusage){
   console.log(cpuusage); //ex: 34 (percent)
});

Get memory usage

Get memory usage percentage.

ostb.memoryUsage().then(function(memusage){
   console.log(memusage); //ex: 93 (percent)
}, function(error){
    //errors here
});

Get current processes

Get current running processes.

ostb.currentProcesses().then(function(processes){
   console.log(processes);
}, function(error){
    //errors here
});

Using sort :

Results could be sort by each attributes (cpu, memory, pid ...) (cf example)

Sort param format:

  • type: pid, name, cpu or mem
  • order: asc or desc
   { 
       type: 'cpu', 
       order: 'desc'
    }

Exemple:

ostb.currentProcesses(sort).then(function(processes){
   console.log(processes);
}, function(error){
    //errors here
});

The following is an example current processes output :

[ { pid: 2316, name: 'code', cpu: 4, mem: 1.114957060891639 },
  { pid: 2310, name: 'nautilus', cpu: 8, mem: 0.989467485779745 },
  { pid: 3867, name: 'notify-osd', cpu: 0, mem: 0.8229067957850149 },
  { pid: 2312, name: 'albert', cpu: 1, mem: 0.8190965839223904 },
  { pid: 1716, name: 'code', cpu: 0.3, mem: 0.8020248554469948 },
  { pid: 2457, name: 'code', cpu: 1.6, mem: 0.7947013313474048 }
]

Get system services list (Linux only)

Get system services list.

ostb.services().then(function (result) {
   console.log(result);
}, function(error){
    //errors here
});

Using filters :

Results could be filtered by service name (cf example)

Filters param format:

   [{name: 'service'}, {name: ....]

Exemple:

ostb.services(filters).then(function (result) {
   console.log(result);
}, function(error){
    //errors here
});

The following is an example system services output :

[ { name: 'apache2', runing: false },
  { name: 'cron', runing: true },
  { name: 'dbus', runing: false },
  { name: 'exim4', runing: false },
  { name: 'nginx', runing: false },
  { name: 'php5-fpm', runing: false },
  { name: 'postgresql', runing: false },
  { name: 'procps', runing: false },
  { name: 'rabbitmq-server', runing: false },
  { name: 'redis-server', runing: false },
  { name: 'resolvconf', runing: true },
  { name: 'rsync', runing: false },
  { name: 'rsyslog', runing: false },
  { name: 'sudo', runing: false },
  { name: 'udev', runing: false },
  { name: 'unattended-upgrades', runing: false },
  { name: 'urandom', runing: false },
  { name: 'x11-common', runing: false } ]

License

MIT license.