Monitor you bus.io apps with bus.io-monitor
.
var bus = require('bus.io')(3000);
var monitor = require('bus.io-monitor');
bus.use(monitor());
A full list of options.
The monitor sends messages to the bus so you can configure how it delivers the messages.
var bus = require('bus.io')(3000);
var monitor = require('bus.io-monitor');
bus.use(monitor({actor:'bus monitor', target:'bus monitor', action:'monitoring stuff', interval:1000}));
The monitor
will collect stats about your bus.io
app. It keeps track of messages going
in the bus, on the bus, and going to the socket. It will trigger a report
event at an
interval. You can pass the interval
as an option.
var monitor = require('bus.io-monitor');
bus.use(monitor({interval:1000});
You can listen to the report
event and consume it however you best see fit.
var events = require('events');
var monitor = require('bus.io-monitor')();
monitor.on('report', function (report) {
console.log(report.data());
});
bus.use(monitor);
The monitor
has a built-in cheesy app that will aggregate reports
and send them to its clients.
var monitor = require('bus.io-monitor');
monitor.app().listen(3030);
You can also just run the app too.
$ cd bus.io-monitor
$ npm install
$ PORT=3000 node app/
var monitor = require('bus.io-monitor')();
Create a new monitor
given these options.
var monitor = require('bus.io-monitor')({actor:'me', target:'me', action:'report', interval:1000});
Access the current report
the monitor
is populating.
var report = monitor.report();
Setst he report to a new one.
monitor.report(Report());
Gets the built-in application that visual reports the data.
monitor.app().listen(3030);
You can flush the current report
and publish it by calling tick()
;
monitor.on('report', function (report) {
console.log('report', report.data());
});
monitor.tick();
This will stop the tick()
method from being called each interval.
monitor.clearInterval();
This method is called whenever you attach the monitor
to a bus
. However, you
can always start it again if you happen to clear it.
monitor.setInterval();
Triggered each time we collect data from a message
.
monitor.on('data', function (data) {
console.log('data');
});
Triggered each time the tick()
method is invoked.
monitor.on('report', function (report) {
console.log(report.data());
});
A monitor
populates a report
with data it receives from the data
event.
var Report = require('bus.io-monitor').Report;
Makes a new report
.
var report = Report();
Returns the passed in report
.
var a = Report();
var b = Report(a);
assert.equal(a, b);
Creates a new report given the data
.
var data = { 'a':1, 'a.b':2, 'a.b.c': 3 };
var report = Report(data);
assert.equal(report.data(), data);
Gets all the data for the report.
report.data();
Gets the value for the given key
.
report.data('some.key');
Sets the value
for the given key
.
report.data('some.key', 1);
Combines the values from the given report
into the current report
.
var a = Report();
a.data('some.key', 1);
var b = Report();
b.data('some.key', 1);
a.combine(b);
assert.equal(a.data('some.key'), 2);
Converts the array of elements into a key that will be used in our report.
var data = ['organism', 'insect', 'cricket'];
var key = report.key(data);
assert.equal(key, 'organism.insect.crieck');
Populates a report by incrementing the values given the points. Or if they do not already exist sets them to 1. This may sound confusing so look at the example below.
var data = ['organism', 'insect', 'cricket'];
report.populate(data);
Now if you call data()
you will get this output.
{
"animal": 1,
"animal.insect":1,
"animal.insect.cricket":1
}
Install node.js (See download and install instructions here: http://nodejs.org/).
Clone this repository
> git clone [email protected]:turbonetix/bus.io-monitor.git
cd into the directory and install the dependencies
> cd bus.io-monitor
> npm install && npm shrinkwrap --dev
Install coffee-script
> npm install coffee-script -g
Tests are run using grunt. You must first globally install the grunt-cli with npm.
> sudo npm install -g grunt-cli
To run the tests, just run grunt
> grunt spec