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

turtle-race

v1.0.7

Published

Real-time metric graphs in the terminal

Downloads

717

Readme

Turtle Race

Real-time metric graphs in the terminal.

anim

Installation

npm install turtle-race -g

If you don't know what npm is, read this.

Usage

Usage: <command> | turtle-race [-c config-file]

The turtle-race command reads metrics from the standard input. On line per value formatted as follows:

<name> <value>

Example:

(while true; do echo one $RANDOM; echo two $RANDOM; sleep 0.5; done) | turtle-race

anim

Keys

  • Left/Right: scroll
  • Home/End: scroll to start/end
  • Ctrl-C or q: quit

Configuration

{
  "interval": 500,                // sampling period in ms (default: 1000)
  "seconds" : true,               // shows only number of seconds since start
  "keep": true,                   // keeps showing the last value
  "pattern": "([^-]*)-(.*)",      // pattern to parse the metric name (see metric groups below)
  "metrics": {                    // specific configuration for a given metric
    "<metric-name>": {            // the metric name (without group, see below)
      "aggregator": "growth",     // function aggregating values (see aggregators below)
      "color": "yellow,bold",     // zibar configuration (see customizing below)
      ...
    }
  }
}

Metric Groups

Metrics can be grouped. By default, the group name prefixes the metric name, separated with a dot. So the metric line format is:

<group>.<name> <value>

When using a metric source with a different format, you can specify in the pattern configuration value the regular expression that will be used to parse the metric group and name. It should provide one or two capture groups, for the group name and the metric name.

Customizing

Graphs can be customized using zibar configuration.

Aggregators

When multiples values are received during the sampling period, they are combined using an aggregator function.

  • avg (default)
  • last
  • sum
  • min
  • max
  • count

Additionally, for values that are only growing, like counters, it may be interesting to show only the difference in each sample. This is actually a non-zero derivative.

  • growth

Marking values

In addition to values, the input can contain zibar markers and styling for the current value. Example:

nginx.cpu red,bold       # styles the graph bar  
mysql.requests ▼         # place a mark above the graph
redis.memory |white      # draws a vertical line

marking values

Using as a library

npm install turtle-race --save
var config = {
  seconds : true,
  interval: 500,
  keep: true,
  pattern: "[^-]*-(.*)",
  metrics: {
    one: {
      aggregator: "growth",
      color: "yellow,bold"
    }
  }
}

var turtle = require('turtle-race')(config);

turtle.metric("one").push(5.4);  // metric without group
turtle.metric("nginx", "cpu").push(5.4); // metric with group
turtle.metric("nginx", "cpu").push(5.4).color("red,bold"); // fluent api

var metric = turtle.metric("nginx", "cpu");
metric.push(5.4);
metric.mark("▼");  // marker above graph
metric.mark({ symbol:"▼", color: "yellow,bold" }); // styled marker
metric.vline("white"); // vertical line

Auto-Start

By default, the rendering starts automatically. You can control it yourself with the config parameter noAutoStart: true then start it when appropriate.

turtle.start();

Status message

A message can be displayed in the bottom line.

turtle.message("hello");

Custom Aggregator Function

In the metric configuration, additionally to the named builtin aggregators, you can use a custom function. For example, an aggregator using the first value received during the sampling period.

aggregator: function(values, context) { return values[0] }

The context parameter is an object associated to the metric. You can use it to store data you want to use across calls, e.g. to implement statistics windows.

Blessed Integration

As turtle-race is based on blessed, you can embed it in an existing node by specifying it as container parameter in the config.