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

osx

v0.1.0

Published

A Mac OS X library for NodeJS to get system information.

Downloads

117

Readme

OSX

This module provides access to Mac OS X system information for access in Javascript via node.js

It provides a set of functions that allow programmatic access to information that you might find from the Mac Activity Monitor or linux command line utilities such as ps, top, df, who, dscl, and netstat.

For example, get_procs returns a list of all running processes along with relevant properties.

If you're looking for this type of stuff you should also check out the standard os module which contains similar functionality for cpus, hostname, load average, release, memory, and uptime. This module is not intended to duplicate any of that functionality.

Dependencies

This was specifically developed for Mac OS X, though it could be extended to work on other systems, and might work on them already. I've only tested it on Darwin 11.2.

This module relies on APIs that Apple considers unsupported, such as sysctl and its extensions, which are subject to change from release to release.

Installation

From npm:

npm install osx

From source:

node-waf configure build
npm link

Usage

Example: print out the pid and command of every running process

var osx = require('osx');
var procs = osx.procs();
for (id in procs) {
    console.log(procs[id].pid + ' ' + procs[id].command);
}

API

  • procs() : array of process objects - all running processes
    • pid : integer - process id
    • parent_pid : integer - parent process id
    • uid : integer - user id of the user who owns the process
    • username : string - name of the user with uid
    • command : string - name of the executable that started the process
    • starttime : number (milliseconds) - time the process started
  • procArgs(pid) : array of string - get the command line arguments of the process with pid
    • NOTE: This is likely to throw an exception if you don't have privileges to that process. Use the command property of the process objects from get_procs instead in that case.
  • mountInfo() : array of mount objects - all mounted devices
    • name : string
    • size : number (bytes)
    • free : number (bytes)
    • pct_free : number (percent free)
    • NOTE: only returns mounts that start with /dev/
  • who() : array of user objects - all users logged in
    • name : string - username
    • line : string - type of device
    • host : string - hostname, if remote session
    • starttime : Date (of session start)
  • users() : array of string - all users logged in
    • NOTE: like who but only a list of unique names
  • accounts() : array of user objects - all users with accounts on this system
    • uid : integer - user id
    • gid : integer - group id
    • name : string - user name
    • dir : string - home directory
  • interfaces() : array of interface objects
    • name : string
    • family : string - type (e.g. IPv4, IPv6)
    • address : string - numeric internet address
    • up : boolean - interface is active or not
    • running : boolean
    • loopback : boolean
  • networkActivity() : activity object
    • packetsSent : number
    • packetsReceived : number
    • bytesSent : number
    • bytesReceived : number