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

zutil

v2.0.2

Published

A SunOS/illumos-specific binding to some zone.h and libzonecfg.h APIs

Downloads

24

Readme

node-zutil is a small library specific to SunOS/Solaris/Illumos/SmartOS that provides a wrapper over all three APIs in zone.h and one from libzonecfg.h.

"libzonecfg" is not documented in illumos and hence (IIUC) considered "unstable". That's a significant reason why bindings for more of its API is not provided here.

Version 2 of this lib is a significant departure from earlier versions. See the changelog entry.

Usage

Assuming "5d4f7599-a991-6b35-dd44-d91936957a6b" is your current zone.

> var zutil = require('zutil')

From zone.h:

> id =  zutil.getzoneid()               // get your current zone numeric ID
403

> zonename = zutil.getzonenamebyid(id)  // get the zonename from a zone ID
'5d4f7599-a991-6b35-dd44-d91936957a6b'

> zutil.getzoneidbyname(zonename)
403

As a convenience, because working zone name is more common, this API is added by this module:

> zutil.getzonename()
'5d4f7599-a991-6b35-dd44-d91936957a6b'

From libzonecfg.h:

> zutil.getzonestate('5d4f7599-a991-6b35-dd44-d91936957a6b')
'running'

Install

npm install zutil

Reference

getzoneid()

Gets the integer zone ID for the current process. In the global zone the id is zero (0).

getzonenamebyid(<id>)

Gets the string zonename for the given zone id.

Parameters

  • id - Integer zone id.

Examples

> zutil.getzonenamebyid(403)
'5d4f7599-a991-6b35-dd44-d91936957a6b'

getzoneidbyname(<zonename>)

Gets the integer zone id from the zonename.

Parameters

  • zonename - String zone name. Typically on SmartOS this is 'global' or a UUID.

Examples

> zutil.getzoneidbyname('5d4f7599-a991-6b35-dd44-d91936957a6b')
403

getzonename()

A convenience function that gets the current zonename.

Examples

> zutil.getzonename()
'5d4f7599-a991-6b35-dd44-d91936957a6b'

getzonestate(<zonename>)

Gets the zone state string (e.g. "running", "configured") for the given zonename string. Throws an Error on any failure. If you are in a non-global zone, you may only get a successful result for the current zone. Other zones will appear to not exist.

At the time of writing the possible zone state strings in illumos are the ZONE_STATE_STR_... vars defined here plus "unknown".

As stated above, "libzonecfg" is undocumented. This function name is made up. It combines the C zone_get_state and zone_state_str functions.

Parameters

  • zonename - String zone name. Typically on SmartOS this is 'global' or a UUID.

Examples

> zutil.getzonestate('5d4f7599-a991-6b35-dd44-d91936957a6b')
'running'

> zutil.getzonestate('global')      # errors if no in the global zone
Error: could not get zone "global" state: No such zone configured
    at Error (native)
    ...

> zutil.getzonestate('nosuchzone')
Error: could not get zone "nosuchzone" state: No such zone configured
    at Error (native)
    ...

Development

npm install

Note: If you are running as root you will see this warning (see npm/npm#3497):

npm WARN lifecycle [email protected]~install: cannot run in wd [email protected] node-gyp rebuild (wd=...)

You then need to use:

npm install --unsafe-perm

License

MIT.