Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
kvisle committed Apr 10, 2013
0 parents commit b6e2055
Show file tree
Hide file tree
Showing 8 changed files with 504 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
9 changes: 9 additions & 0 deletions .travis.yml
@@ -0,0 +1,9 @@
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq munin-node
- sudo npm install vows
- sudo npm install vows -g
language: node_js
node_js:
- 0.8
- 0.6
99 changes: 99 additions & 0 deletions README.md
@@ -0,0 +1,99 @@
# node-munin-client

A Munin-client written in Node.

## Usage

```javascript
var muninClient = require('node-munin-client');

var mc = new muninClient('localhost', 4949);

mc.connect(function () {
console.log('Connected!');

mc.fetch('cpu', function (data) {
console.log(data);
});
});
```

## Reference

```
var mc = new muninClient(server, port, true)
```

### connect

Connects to the munin-node.

```
mc.connect( function () { } );
```

### getNodes

Asks for a list of nodes. First argument of callback will be an array of nodes.

```
mc.getNodes( function (nodes) { } );
```

### getList

Asks for a list of plugins belonging to node. First argument of callback will be an array of plugins. Second argument will be the node.

```
mc.getList(node, function (plugins, node) { } );
```

### getConfig

Asks for configuration of plugin. First argument of callback will be an object with structured configuration data. Second argument will be the plugin.

```
mc.getConfig(plugin, function (config, plugin) { } );
```

### getMetrics

Asks for metrics of plugin. First argument of callback will be an object of metrics. Second argument will be the plugin.

```
mc.getMetrics(plugin, function (metrics, plugin) { } );
```

### quit

Ends the connection.

```
mc.quit();
```


## LICENSE

(MIT)

> Copyright (C) 2013 Trygve Vea
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of
> this software and associated documentation files (the "Software"), to deal in
> the Software without restriction, including without limitation the rights to
> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
> of the Software, and to permit persons to whom the Software is furnished to do
> so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
43 changes: 43 additions & 0 deletions example.js
@@ -0,0 +1,43 @@
/*
This is an example which connects to a munin-node, asks for all the data and
pushes them into handler functions.
*/
var mc = require('./') //require('node-munin-client')

var myclient = new mc('localhost', 4949, true);


myclient.connect(function () {

myclient.getNodes(nodeResHandler);

});

function nodeResHandler(n) {
for (var a in n) {
var node = n[a];

myclient.getList(node, listResHandler);
}
}

function listResHandler(p, node) {
console.log('got list from node ' + node);
for (var b in p) {
var plugin = p[b];

myclient.getMetrics(plugin, metricResHandler);
myclient.getConfig(plugin, configResHandler);
}
myclient.quit();
}

function metricResHandler(r, plugin) {
console.log('result of ' + plugin);
console.log(r);
}

function configResHandler(rc, plugin) {
console.log('config of ' + plugin);
console.log(rc);
}
1 change: 1 addition & 0 deletions index.js
@@ -0,0 +1 @@
module.exports = require('./muninClient');

0 comments on commit b6e2055

Please sign in to comment.