/node-lsof

Process lsof parser

Primary LanguageJavaScriptOtherNOASSERTION

lsof For Node

A simple lsof processor for node. This is handy when debugging long apps. You can load this and call it from your status commands to see how many open file descriptors your process has.

Install

npm install lsof

Usage

var lsof = require('../lib/lsof');

lsof.counters(function(data) {
    console.log(data);
    /*
    *
    * { pid: 24231
    *   , user: 'davglass'
    *   , open: 12
    *   , types: { dir: 1, reg: 3, chr: 3, pipe: 5 }
    *   }
    *
    */
});


lsof.raw(function(data) {
    console.log(data);
    /**
    * [ { command: 'node'
    *   , pid: '24231'
    *   , user: 'davglass'
    *   , fd: 'txt'
    *   , type: 'REG'
    *   , device: '14,1'
    *   , 'size/off': '5139784'
    *   , node: '15331212'
    *   , name: '/usr/local/bin/node'
    *   }
    * , { command: 'node'
    *   , pid: '24231'
    *   , user: 'davglass'
    *   , fd: 'txt'
    *   , type: 'REG'
    *   , device: '14,1'
    *   , 'size/off': '1054960'
    *   , node: '7477054'
    *   , name: '/usr/lib/dyld'
    *   }
    * , { command: 'node'
    *   , pid: '24231'
    *   , user: 'davglass'
    *   , fd: 'txt'
    *   , type: 'REG'
    *   , device: '14,1'
    *   , 'size/off': '205565952'
    *   , node: '15630602'
    *   , name: '/private/var/db/dyld/dyld_shared_cache_x86_64'
    *   }
    * , { command: 'node'
    *   , pid: '24231'
    *   , user: 'davglass'
    *   , fd: '0u'
    *   , type: 'CHR'
    *   , device: '16,2'
    *   , 'size/off': '0t183952'
    *   , node: '1355'
    *   , name: '/dev/ttys002'
    *   }
    * ]
    */
});