This repository has been archived by the owner on Jul 2, 2022. It is now read-only.
forked from Redpill-Linpro/node-munin-client
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b6e2055
Showing
8 changed files
with
504 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./muninClient'); |
Oops, something went wrong.