Compiling watch(1) on SmartOS

Posted by Dave Eddy on Sep 18 2012 - tags: tech

watch - execute a program periodically, showing output fullscreen

Watch

Coming from Linux, I have become used to the watch tool. The program is very simple, it lets you run a command at a given interval, and update the terminal with the output. It’s like a simple while loop that runs a command, but it uses ncurses to update the view, which makes it easy to spot differences.

Compiling it on SmartOS was straight forward, the hardest part was finding the source of watch(1). It turns out it is bundled with a handful of tools for dealing with the Linux proc filesystem. Because of this, most of the tools wont compile (or be useful) on an Illumos based operating system, so the Makefile proved to not be helpful.

Read More...


Trace streams in Node.js

Posted by Dave Eddy on Aug 29 2012 - tags: tech

I was working on my latest module for node, latest, when I encountered a problem. While testing, I noticed output being written to the terminal that I wasn’t generating. This means that some module had the audacity to write directly to the terminal… bad.

My project was only including the npm module, however the npm module included its own handful of other modules, and they included their own modules, and so-on. If I were to look through the source myself to try and find what was outputting to the terminal it would have taken forever, trying to trace what function was calling what. Instead, I decided to override the stdout streams write function, to stack trace when invoked. This means that any function that writes to stdout will cause a stack trace to be printed to the screen.

Read More...


exec - Node Module

Posted by Dave Eddy on Aug 26 2012 - tags: tech

Call a child process with the ease of exec and safety of spawn

View the Project page on GitHub

Why?

This module provides the best of both worlds of spawn and exec

It will simply return 2 strings containing stdout and stderr (like child_process.exec), but will take an array of process arguments (like child_process.spawn) to avoid any nasty shell expansion.

Read More...


Clear - Node Module

Posted by Dave Eddy on Aug 15 2012 - tags: tech

Clear the terminal screen if possible

I wrote up a super small module to mimic clear on the command line for Node.js. I was surprised when I didn’t find a module that already did this in npm.

View the Project page on GitHub

Usage

var clear = require('clear');
clear();

Example

Node Clear

Read More...


Musicnamer

Posted by Dave Eddy on Aug 04 2012 - tags: tech

Organize your music collection

I wrote this module as a way to help organize my collection of flac and mp3 files. It can automatically inspect your music files metadata tags, and rename the files based on them.

Check out musicnamer on GitHub

Description

Rename music files to clean filenames based on their music tags. By default, musicnamer can take your music files and rename them to a format like:

%artist%/%album%/%trackno% - %title%.%ext%

This package is not meant to be used as a Node module, but rather as a command line tool

Read More...


Chromium Install Script for Mac

Posted by Dave Eddy on Jul 25 2012 - tags: tech

Install and upgrade chromium on OS X.

Chromium

I like to have both Chromium and Chrome installed on my mac, but installing Chromium is not as easy as installing Chrome. Chromium required me to find the tarballs that were generated from the Chromium source control, and to make sure that I was only pulling the tarball if my Chromium version was out of date. Because of this, mac-chromium was born.

View the project page on github

Read More...


(De) struct - Node Module

Posted by Dave Eddy on Jul 18 2012 - tags: tech

Easily unpack C Structs and binary buffers

I wrote destruct to tackle the problem of unpacking binary buffers in Node easily. Based off the unpack function in Perl, and inspired by prustat by Brendan Gregg, this module makes it simple to take a binary buffer object, and a format string to unpack values. There were other modules that claimed to have the same functionality, but most of them were too poorly documented with the source code almost unreadable, while the others were overcomplicated and didn’t support a simple format string.

This module does not handle all data types, it has only been tested on SmartOS, and was built for making it easier to extend the proc Node module by @dshaw.

Check out the project page here https://github.com/bahamas10/node-destruct.git

Read More...


Autocast - Node Module

Posted by Dave Eddy on Jul 17 2012 - tags: tech

Easily and automatically cast common datatypes in JavaScript

I was working on parsing output from the command line while creating the Node SMF module. This required me to inspect the elements individually and write case statements to expect certain data types be returned.

What I mean by this is…

When you parse the command line, everything gets returned as a string. So, you must do some post-processing to cast items that look like numbers to numbers, strings that look like keywords to keywords, ie 'false' to false, etc.

So, autocast was born. This module will do all of that inspection for you and return what it thinks the object should be.

Check out the project page here https://github.com/bahamas10/node-autocast

Read More...


Realtime DTrace Visualization

Posted by Dave Eddy on Jul 12 2012 - tags: tech

Check out my YouTube video of realtime latency graphs using DTrace and gnuplot.

Scripts here https://github.com/bahamas10/realtime-dtrace-visualization

The graph on the left shows read system call latency, and the graph on the right shows write system call latency (syscall::read*:entry and syscall::write*:entry respectively). The bottom portion is a modified oneliner to show files opened by a process (excluding gnuplot) taken from Brendan Gregg’s DTrace oneliners.

At 0:45, I induced latency by reading /usr/share/dict/words and writing the contents out to the screen in a 1 second loop. This becomes visible in large spikes on the graph showing write latency, but the read latency graph is almost unaffected.

The X-axis on both graphs show time (ticking every second) in the form of MM:SS. The Y-axis represents the time in milliseconds, and each point is a 1 second average aggregation of the latency.

Because of the nature of gnuplot in this experiment, the Y-axis adapts to the visible metrics, so when the latency is induced, the Y-axis grows from ~.005ms to ~2ms.


Node DTrace Examples on Github

Posted by Dave Eddy on Jun 16 2012 - tags: tech

Working on performance analysis with an interpreted language poses some interesting problems. Fortunately, Node.js has built in support for DTrace thanks to the guys at Joyent. These built-in facilities make it easy to trace Node.js, and profile its time on the CPU to get an in-depth view of the execution of the program. Tools also exist that use DTrace’s ability to profile Node.js to create visual representations of the execution stack, such as Brendan Gregg’s Flame Graph Tool.

However, when tracking latency from an application-aware point-of-view, it is necessary to inject probes into the code itself, setting checkpoints, or entry and return points. Using the DTrace Provider Node.js Module written by Chris Andrews, I’ve created a repository of examples on Github showing the DTrace provider in action.

Check out the repository here https://github.com/bahamas10/node-dtrace-examples/.

Read More...


« Newer Posts 6 of 6 Older Posts