Skip to content
/ statmap Public

Output recursive directory stats as JSON for visualization and analysis.

License

Notifications You must be signed in to change notification settings

dmotz/statmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

statmap

Output recursive directory stats as JSON for visualization and analysis.

Dan Motzenbecker, MIT License

@dcmotz

Installation and Usage

As a system executable:

$ npm install -g statmap

When used as an executable, statmap returns JSON over stdout.

To map the current directory:

$ statmap > stats.json

Pass an optional argument for a different directory:

$ statmap .. > parent.json

The JSON will contain a recursive representation of the directory and all children. Each key is a file or directory name with a corresponding value containing a stats object and a children object if it is a directory. Directories also are also given a sum property which reflects the size of all children recursively, unlike the typical size property of directory's stats object.

Here's an excerpt of the output for the package itself:

{
  "statmap": {
    "stats": {
      "dev": 16777220,
      "mode": 16877,
      "nlink": 9,
      "uid": 501,
      "gid": 80,
      "rdev": 0,
      "blksize": 4096,
      "ino": 141035615,
      "size": 306,
      "blocks": 0,
      "atime": "2013-11-25T01:02:05.000Z",
      "mtime": "2013-11-25T01:02:05.000Z",
      "ctime": "2013-11-25T01:02:05.000Z"
    },
    "sum": 165329,
    "children": {
      "README.md": {
        "stats": {
          "dev": 16777220,
          "mode": 33188,
          "nlink": 1,
          "uid": 501,
          "gid": 80,
          "rdev": 0,
          "blksize": 4096,
          "ino": 141057002,
          "size": 550,
          "blocks": 8,
          "atime": "2013-11-25T01:02:05.000Z",
          "mtime": "2013-11-25T01:01:52.000Z",
          "ctime": "2013-11-25T01:01:54.000Z"
        }
      },
      "index.js": {
        "stats": {
          "dev": 16777220,
          "mode": 33188,
          "nlink": 1,
          "uid": 501,
          "gid": 80,
          "rdev": 0,
          "blksize": 4096,
          "ino": 141035626,
          "size": 1180,
          "blocks": 8,
          "atime": "2013-11-25T01:02:06.000Z",
          "mtime": "2013-11-25T00:51:31.000Z",
          "ctime": "2013-11-25T00:51:31.000Z"
        }
      },
      "node_modules": {
        "stats": {
          "dev": 16777220,
          "mode": 16877,
          "nlink": 3,
          "uid": 501,
          "gid": 20,
          "rdev": 0,
          "blksize": 4096,
          "ino": 141036545,
          "size": 102,
          "blocks": 0,
          "atime": "2013-11-25T00:53:55.000Z",
          "mtime": "2013-11-24T23:00:54.000Z",
          "ctime": "2013-11-24T23:00:54.000Z"
        },
        "sum": 124651,
        "children": {
          "async": {
            "stats": {
        //...

Using this data, you could create something like a D3 zoomable treemap of your hard drive.

As a library:

$ npm install --save statmap

Pass a path and a callback:

var statmap = require('statmap');

statmap('./spells', function(err, stats) {
  console.log(utils.inspect(stats, { color: true, depth: null }));
});

When used as a library, a live object is returned rather than a JSON string.

About

Output recursive directory stats as JSON for visualization and analysis.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published