{"_id":"dbmon","_rev":"25-487b9ab0b8d7896eb444e44df3cf0221","name":"dbmon","description":"Database and Filesystem Monitor Utilities for Real Time Apps","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.2":{"name":"dbmon","version":"1.0.2","description":"Database Monitor Utilities for Real Time Apps","keywords":["dbmon","monitoring","postgresql","mysql","oracle","polling","rdbms"],"author":{"name":"Strx","email":"f@strx.it"},"main":"./index.js","dependencies":{"pg":">= 0.6.2","step":">= 0.0.4","underscore":">= 1.2.0"},"devDependencies":{"colors":">= 0.5.1"},"homepage":"https://github.com/straps/node-dbmon","repository":{"type":"git","url":"git://github.com/straps/node-dbmon.git"},"scripts":{"test":"node test/test-*"},"_npmUser":{"name":"straps","email":"fstraps@gmail.com"},"_id":"dbmon@1.0.2","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.99","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"d433b40285657d98204cd2e5f194c10ff02fa181","tarball":"https://registry.npmjs.org/dbmon/-/dbmon-1.0.2.tgz","integrity":"sha512-KrW2uBOHRgSPJ/82JoI/zBdCjPWGgLxbyuOIa40d/tJrHX5jy2k7rgexVK7aMZGDdiwYuLqpUIKP6Ak+gAvUbA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH51CWKdZzTNlX06PHlvYepTAdrXHjnjm5WO+9NlLNnyAiBct7xphi4YR/6kzSInOY49ZwiGkodk1QJxzA7dhoVokA=="}]},"maintainers":[{"name":"straps","email":"fstraps@gmail.com"}],"directories":{}},"1.0.4":{"name":"dbmon","version":"1.0.4","description":"Database and Filesystem Monitor Utilities for Real Time Apps","keywords":["dbmon","monitoring","postgresql","mysql","oracle","polling","rdbms","faye"],"author":{"name":"Strx","email":"f@strx.it"},"main":"./index.js","dependencies":{"pg":">= 0.6.0","faye":">= 0.6.5","step":">= 0.0.4","underscore":">= 1.2.0"},"devDependencies":{"colors":">= 0.5.1"},"homepage":"https://github.com/straps/node-dbmon","repository":{"type":"git","url":"git://github.com/straps/node-dbmon.git"},"scripts":{"test":"make test"},"_npmUser":{"name":"straps","email":"fstraps@gmail.com"},"_id":"dbmon@1.0.4","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.99","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"687ebd9cda921cb5bcaa7bc55551c6d2d5e59a6c","tarball":"https://registry.npmjs.org/dbmon/-/dbmon-1.0.4.tgz","integrity":"sha512-WwObwKAtfGW4Jy6rEfo0VqWGul1NDK3lD+tCk5YTx4NKMzFhfrCUXfDUr0dIt+Bh+Kq4WeVioJWDjNGgOwdciA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCXx3HU3epJbemzdtwE/D+N2iKc0kWFqwVP3D4FuKUNhQIhAJYPNsT5wNE0HJfHXACG/JkOSFlGOnUUz7DDq9tzpAnN"}]},"maintainers":[{"name":"straps","email":"fstraps@gmail.com"}],"directories":{}},"1.0.5":{"name":"dbmon","version":"1.0.5","description":"Database and Filesystem Monitor Utilities for Real Time Apps","keywords":["dbmon","monitoring","postgresql","mysql","oracle","polling","rdbms","faye","nowjs"],"author":{"name":"Strx","email":"f@strx.it"},"main":"./index.js","dependencies":{"pg":">= 0.6.0","faye":">= 0.6.5","now":">= 0.6.5","step":">= 0.0.4","underscore":">= 1.2.0"},"devDependencies":{"colors":">= 0.5.1"},"homepage":"https://github.com/straps/node-dbmon","repository":{"type":"git","url":"git://github.com/straps/node-dbmon.git"},"scripts":{"test":"make test"},"_npmUser":{"name":"straps","email":"fstraps@gmail.com"},"_id":"dbmon@1.0.5","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.99","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"893f34215880936a8fad09e5b6c3891023b2a0d3","tarball":"https://registry.npmjs.org/dbmon/-/dbmon-1.0.5.tgz","integrity":"sha512-Bdp+4maD07UL4wXybqd3R4rs8IF7M6oSn+sFKusxWCBl5x64KrSlkjasTtnphlC1ij3KIM9AEgLSA4nOKAhgpg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEfE4wmg4T+CqQnX9jwWn7SeMKspvhr5kHyx+uRbmw7IAiEApyRGM8VMHNhs5jb+HtOeTizbWAVz0V5gmyglGrl1zmM="}]},"maintainers":[{"name":"straps","email":"fstraps@gmail.com"}],"directories":{}},"1.0.6":{"name":"dbmon","version":"1.0.6","description":"Database and Filesystem Monitor Utilities for Real Time Apps","keywords":["dbmon","monitoring","postgresql","mysql","oracle","polling","rdbms","faye","nowjs"],"author":{"name":"Strx","email":"f@strx.it"},"main":"./index.js","dependencies":{"pg":">= 0.6.0","faye":">= 0.6.5","now":">= 0.6.5","step":">= 0.0.4","underscore":">= 1.2.0"},"devDependencies":{"colors":">= 0.5.1"},"homepage":"https://github.com/straps/node-dbmon","repository":{"type":"git","url":"git://github.com/straps/node-dbmon.git"},"scripts":{"test":"make test"},"_npmUser":{"name":"straps","email":"fstraps@gmail.com"},"_id":"dbmon@1.0.6","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.99","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"16febc0233b3e9267f413b62964731f02c3cf05e","tarball":"https://registry.npmjs.org/dbmon/-/dbmon-1.0.6.tgz","integrity":"sha512-crHPMVnuRntngBUix+8lWxfLrj7irwTnM4kJfa7K4ggjW7d/p2O8cMIJRshzD+3TNift9OL2vgo4cia9MKBkEA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDmjal5HOdiWNZt0Sgpv96qX9AKOFqajpL2Qx4PbcjyAwIgAhKf8hC9YB0GauwZRL4pOFfyVcvmIxcgasw4Bja8lTw="}]},"maintainers":[{"name":"straps","email":"fstraps@gmail.com"}],"directories":{}},"1.0.7":{"name":"dbmon","version":"1.0.7","description":"Database and Filesystem Monitor Utilities for Real Time Apps","keywords":["dbmon","monitoring","postgresql","mysql","oracle","polling","rdbms","faye","nowjs"],"author":{"name":"Strx","email":"f@strx.it"},"main":"./index.js","dependencies":{"pg":">= 0.6.0","faye":">= 0.6.5","now":">= 0.6.5","step":">= 0.0.4","underscore":">= 1.2.0"},"devDependencies":{"colors":">= 0.5.1"},"homepage":"https://github.com/straps/node-dbmon","repository":{"type":"git","url":"git://github.com/straps/node-dbmon.git"},"scripts":{"test":"make test"},"_npmUser":{"name":"straps","email":"fstraps@gmail.com"},"_id":"dbmon@1.0.7","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.99","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"bfb6b17b1febe1857103125236a26b20167a5652","tarball":"https://registry.npmjs.org/dbmon/-/dbmon-1.0.7.tgz","integrity":"sha512-CdAlZA0O3MgpBuLfcz0LfwVNc4wefRMOiWG9Vihn17HTp2hF6ZbMwIAHWYxVLUqxqSl3KjbrCzbdO1tZ+W/6YQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAsvvwwGHkNeIvFO4D+ijUsRMnb+mJ5B9ysDt8I5887xAiEA71l7xa/jNp3jVTkyVKP7s+jfAGrfK8ouwNfNNYShlhE="}]},"maintainers":[{"name":"straps","email":"fstraps@gmail.com"}],"directories":{}},"1.1.0":{"name":"dbmon","version":"1.1.0","description":"Database and Filesystem Monitor Utilities for Real Time Apps","keywords":["dbmon","monitoring","postgresql","mysql","oracle","polling","rdbms","faye","nowjs","realtime"],"author":{"name":"Strx","email":"f@strx.it"},"main":"./index.js","dependencies":{"pg":">= 0.6.0","faye":">= 0.6.5","now":">= 0.6.5","step":">= 0.0.4","underscore":">= 1.2.0","optimist":">= 0.0.0"},"devDependencies":{"colors":">= 0.5.1"},"homepage":"https://github.com/straps/node-dbmon","repository":{"type":"git","url":"git://github.com/straps/node-dbmon.git"},"scripts":{"test":"make test"},"bin":{"dbmon":"./bin/dbmon"},"engines":{"node":"*"},"readme":"# Database and Filesystem monitor utilities for nodejs\n\nIf you are trying to update a GUI when a database table changes (_insert_, _update_, _delete_) or when a file is being created/modified/deleted/moved, this library is for you.\n\nThis is a node.js module supporting a growing number of database drivers and notification transports\nyou can extend and improve.\n\nIt is designed to be easily extended with simple sintax by anyone and, where possibile,\nto notify of changes without classic polling, but with real-time notification mechanism\n\n\n## Usage sample\n\nThis is a short example of the PostgreSQL driver; you can find more on `test/test-postgresql.js`\n\nInstall a local postgresql database server; grant temporary trust access to the postgresql\nuser editing the pg_hba.conf file and create a test table like this `create table testtable(id integer primary key, val varchar(10));`\nthen run the following\n\n    var pg=require('pg'), cli=new pg.Client('tcp://postgres@localhost/template1'), dbmon=require('dbmon');\n\n    cli.connect();\n    //uncomment if you want node to create the temporary table for you\n    //cli.query('drop table if exists testtable; create table testtable(id integer primary key, val varchar(10));');\n\n    var channel=dbmon.channel({\n      driver:'postgresql',\n      driverOpts:{\n        postgresql:{\n          cli:cli\n        }\n      },\n      table:'testtable',\n      monitor:'all',\n      keyfld:{\n        name:'id',type:'integer'\n      }\n    });\n\nNow monitor the console and execute some insert/update/delete and see what happens...\n\nYou should see come console messages saying you are modifiyng `testtable` like this\n\n    Console Transport Notification: insert, row={\"op\":\"i\",\"k\":2,\"oldk\":2,\"id\":1}\n\nIn this case I've executed a simple insert like `insert into testtable values(2,'TWO');`.\nConsole says that the type of notification is an insert and the row modified\nfrom last notification is `{\"op\":\"i\",\"k\":2,\"oldk\":2,\"id\":1}` where fields means:\n\n  - *op* is the operation type; can be *i* for insert, *u* for update, *d* for delete and *t* for truncate\n  - *k* is the key inserted/updated/deleted based on what specified in `keyfld.name`\n  - *oldk* is the old key value, see what happens executing `update testtable set id=20, val='twenty' where id=2`\n  - *id* is an internal change sequence id, an ordered number useful to keep track of modifications\n\nIt is very interesting to know that if you update 2 or more rows in the same transaction, there will\narrive 2 ore more notifications based on the number or rows being modified\n\nAnother good thing is that for PostgreSQL, *dbmon* is powered by the NOTIFY/LISTEN constructs. It means\nthat, when something changes, the server that contacts node and node notify listeners via the transports specified, making\nit really real-time, not like other polling-based alternatives.\n\nTo see the complete list of options see [lib/channelDefaults.js](https://github.com/straps/node-dbmon/blob/master/lib/channelDefaults.js)\n\n### Dbmon cli\n\nDbmon has also an executable called `dbmon`.\n\nWith it you can start a socket.io server or a console db monitoring program without writing a single line of code.\n\nSample usage:\n\n    dbmon --driver=postgresql --driverOpts-postgresql-connStr=tcp://user:pwd@127.0.0.1:5432/db --driverOpts-postgresql-baseObjectsName=test_dbmon_cli --table=mytable --keyfld-name=id --keyfld-type=integer --transports=console,socketio --transportsOpts-socketio-port=8888\n\nParameters are tranformed to a JSON object as expected by dbmon and like discussed before.\n\nIn this case, the resulting json will be:\n\n    {\n      \"driver\": \"postgresql\",\n      \"driverOpts\": {\n        \"postgresql\": {\n          \"connStr\": \"tcp://user:pwd@127.0.0.1:5432/db\",\n          \"baseObjectsName\": \"test_dbmon_cli\"\n        }\n      },\n      \"table\": \"mytable\",\n      \"keyfld\": {\n        \"name\": \"id\",\n        \"type\": \"integer\"\n      },\n      \"transports\": \"console,socketio\",\n      \"transportsOpts\": {\n        \"socketio\": {\n          \"port\": 8888\n        }\n      }\n    }\n\ndbmon will start a channel passing that object as input, will monitor for *mytable* changes and will run a socket.io websocket on port 8888 for real-time web updates. Simple as effective...\n\n\n### Sample for the new filesystem driver\n\nOn linux, you can experiment the new `filesystem` driver. It is based on `inotifywait`, a linux command line utility\nthat helps you monitor for file changes; on ubuntu you can install it by typing\n\n    sudo apt-get install inotify-tools\n\nNow Execute this code\n\n    require('dbmon').channel({\n      driver:'filesystem',\n      driverOpts:{filesystem:{root:'/home'}},\n      method:'inotifywait',\n      transports:'console'\n    });\n\nand monitor the console when you create/modify/delete files on your home directory or subdirectories (Desktop too). FUN\n\n## Structure and Naming Conventions\n\nDbmon is designed to be dynamic and easily extensible; there are 3 main actors to extend it\n\n  - **transports**, in [lib/transports](https://github.com/straps/node-dbmon/tree/master/lib/transports) are the way dbmon notify events. You can use how many tranports you want separating them by comma. The name specified in the options object have to match the name of the file followed by `-tranport.js` in the `transports` foler, like the `console` transport in the example above.\n  - **providers**, in [lib/providers](https://github.com/straps/node-dbmon/tree/master/lib/providers), have to initialize their method to fetch data and notify transports whene something happen; in most cases (surely for postgresql case) they should only require the `generic-driver` that dynamiccaly instantiate the method and notify transports\n  - **methods**, in [lib/methods](https://github.com/straps/node-dbmon/tree/master/lib/methods), are the core of the system; their implementation depends upon the driver and the method specified in the configuration object and their name should respect `DRIVER-METHOD-method.js` convention (ie: postgresql-trigger-method.js). Methods init function return an `EventEmitter` inherited object that notify listeners where data changes firing the event notification chain\n\n\n### How To Create a new Transport\n\nCreating a new transport is very simple; the node module have to export a single function `init` that `dbmon` will call passing the global options object.\n\nThe `init` function have to return an object with a `notify` method, magically called from drivers, when something server side changes.\n\nSay we want a generic TCP Socket transport to communicate with another application, transmitting db update notification.\n\nCreate the file `lib/transports/tcpsocket.js` and insert the following lines:\n\n    //TCP Socket Tranport\n    var init=function init(opts){\n      console.log('TCP Socket Transport init');\n      var me={\n        notify:function(type, row){\n          opts.transportsOpts.tcpsocket.client.write(JSON.stringify(row));\n          return me;\n        }\n      };\n      return me;\n    };\n    module.exports={init:init};\n\nNow use it from your node.js server socket app:\n\n    var net = require('net');\n    var server = net.createServer(function (c) {\n      c.on('data', function(data){\n        console.log('DATA FROM SOCKET HURRAAA --> '+data);\n      });\n    });\n    server.listen(8124, 'localhost', function(){\n      var client=new net.Socket();\n      client.connect(8124, 'localhost', function(){\n        console.log('connected');\n\n        var pg=require('pg'), cli=new pg.Client('tcp://postgres@localhost/template1'), dbmon=require('dbmon');\n        cli.connect();\n\n        dbmon.channel({\n          driver:'postgresql',\n          driverOpts:{\n            postgresql:{\n              cli:cli\n            }\n          },\n          table:'testtable',\n          method:'trigger',\n          transports:'tcpsocket',\n          transportsOpts:{\n            tcpsocket:{\n              client:client\n            }\n          },\n          keyfld:{ name:'id', type:'integer'}\n        });\n      });\n    });\n\nIn 20 lines of (uncompressed) code you can create and use a new tranport, contribute to the library and make others happy (me too :)\n\nCreating a new driver and a new driver method, could be some more complicated, but I thing, in next releases will be a generic\nmixed trigger/polling based driver I'm thinking on.\n\n\n## Testing\n\nTest cases are home-made and could not be complete or well done, so feel free to fork and improve tests too.\n\nIn any case, you can test the library doing a `make test` from main directory\n\n\n## Installation\n\nUsing npm: `npm install dbmon`\n\nOr `npm install dbmon -g` and `npm link dbmon` if you prefer linking a global installation\n\nOr you can download/fork and copy on a local folder inside your project\n\n\n### External Dependencies, automatically installed if you use npm\n\n  - [Underscore.js](http://documentcloud.github.com/underscore/) (`npm install underscore`)\n  - [Step](https://github.com/creationix/step) (`npm install step`)\n\nDatabase drivers, depends on the driver you use, including\n\n  - [Pg](https://github.com/brianc/node-postgres) (`npm install pg`)\n  - [inotifywait](https://github.com/rvoicilas/inotify-tools/wiki/) (`sudo apt-get install inotify-tools`); required for `{driver:'filesystem',method:'inotifywait',...}`\n\nTransports drivers, depends on the transports you use, including\n\n  - [Faye](http://faye.jcoglan.com/) (`npm install faye`)\n  - [Nowjs](http://nowjs.com/) (`npm install now`)\n\nOnly for test\n\n  - [Colors](https://github.com/Marak/colors.js) (`npm install colors`)\n\n\n\n## ToDo\n  - Develop other drivers (MySQL, Oracle, MsSQL, etc...)\n  - Develop other transports (Hook.io, etc..)\n  - Write better unit tests\n\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2011 Francesco Strappini <f@strx.it>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"Readme.md","_id":"dbmon@1.1.0","dist":{"shasum":"b5ab41b27ff38fa9cf0ce7cf28ca46ff7f778bb6","tarball":"https://registry.npmjs.org/dbmon/-/dbmon-1.1.0.tgz","integrity":"sha512-eFhIVOROmEcsjMFVYrDDASS3puKy+tIWiSKcvz2XityalvMe+GSKo90ybLVbGouyL4YWygCHIjhxFX+g/B9MRQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHo9O0xIu8bh3K4ZZsAYRLbiztTa5bIhqv0HQqf41YtIAiBkzQQdAyoiKE9/5Gg0W9t18GtjFjuQJgkQYneyspVYlA=="}]},"_npmVersion":"1.1.65","_npmUser":{"name":"straps","email":"fstraps@gmail.com"},"maintainers":[{"name":"straps","email":"fstraps@gmail.com"}]}},"maintainers":[{"name":"straps","email":"fstraps@gmail.com"}],"time":{"modified":"2022-06-14T21:12:04.633Z","created":"2011-10-25T13:55:12.415Z","1.0.2":"2011-10-25T13:55:14.512Z","1.0.4":"2011-11-02T08:01:36.292Z","1.0.5":"2011-11-05T16:30:57.474Z","1.0.6":"2011-11-08T13:36:15.019Z","1.0.7":"2012-01-14T14:24:38.023Z","1.1.0":"2013-06-21T10:55:40.318Z"},"author":{"name":"Strx","email":"f@strx.it"},"repository":{"type":"git","url":"git://github.com/straps/node-dbmon.git"},"users":{}}