thinkable-ducks
Version:
supervisor-controlled image for useful-wind
68 lines (58 loc) • 2.6 kB
JavaScript
// Generated by CoffeeScript 2.4.1
(function() {
var Zappa, build_config, debug, name, pkg, ref, run;
pkg = require('./package');
this.name = `${pkg.name}:munin`;
debug = (require('debug'))(this.name);
// Web Services for Munin
// ======================
run = function(cfg) {
var base, base1, base2, config, port, ref;
if (cfg.munin == null) {
cfg.munin = {};
}
if ((base = cfg.munin).host == null) {
base.host = (ref = process.env.MUNIN_HOST) != null ? ref : '127.0.0.1';
}
port = null;
if (process.env.MUNIN_PORT != null) {
port = parseInt(process.env.MUNIN_PORT);
if (isNaN(port)) {
port = null;
}
}
if ((base1 = cfg.munin).port == null) {
base1.port = port != null ? port : 3950;
}
if ((base2 = cfg.munin).io == null) {
base2.io = false;
}
config = build_config(cfg);
return Zappa(cfg.munin, function() {
this.get('/autoconf', function() {
this.send('yes\n');
});
this.get('/config', function() {
this.send(config);
});
return this.get('/', function() {
var memory, text;
memory = process.memoryUsage();
text = `multigraph ${name}_node_uptime\n${name}_node_uptime.value ${process.uptime()}\n\nmultigraph ${name}_node_memory\n${name}_node_memory_rss.value ${memory.rss}\n${name}_node_memory_heap_total.value ${memory.heapTotal}\n${name}_node_memory_heap_used.value ${memory.heapUsed}\n\nmultigraph ${name}_hugeplay\n`;
return this.send(text);
});
});
};
// Munin Configuration
// ===================
name = (ref = process.env.MUNIN_NAME) != null ? ref : 'freeswitch';
build_config = function(cfg) {
var text;
text = `multigraph ${name}_node_uptime\ngraph_args --base 1000 -l 0\ngraph_category voice\ngraph_scale no\ngraph_title Node.js uptime\ngraph_vlabel seconds\n${name}_node_uptime.label uptime\n${name}_node_uptime.draw AREA\n\nmultigraph ${name}_node_memory\ngraph_args --base 1024 -l 0\ngraph_category voice\ngraph_title Node.js memory\ngraph_vlabel bytes\n${name}_node_memory_rss.label rss\n${name}_node_memory_rss.min 0\n${name}_node_memory_heap_total.label heap (total)\n${name}_node_memory_heap_total.min 0\n${name}_node_memory_heap_used.label heap (used)\n${name}_node_memory_heap_used.min 0\n\nmultigraph ${name}_hugeplay\ngraph_args --base 1000 -l 0\ngraph_category voice\ngraph_title Durations\ngraph_vlabel \${graph_period}\n`;
return text;
};
// Toolbox
// =======
Zappa = require('core-zappa');
module.exports = run;
}).call(this);