Skip to content

Commit

Permalink
Added some probes
Browse files Browse the repository at this point in the history
  • Loading branch information
ymettier committed Nov 6, 2014
1 parent 282e810 commit ad80557
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Version 1.3.2

- Move from windows-cpu to perfmon due to crashs with windows-cpu (wmic cpu get loadpercentage)
- Added some probes in collectdCompat plugin

Version 1.3.1

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CollectM",
"version": "1.3.2",
"version": "1.3.2-rc1",
"author": "Cyril Feraudet",
"license": "GPLv2",
"dependancies": {
Expand Down
36 changes: 24 additions & 12 deletions src/plugins/collectdCompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ var each = function(obj, block) {
}
};

var perfmonCounterToPlugin = function(pm, p, pi, t, ti) {
// Note : do not use this function if you have more than one pm for the same (p,pi)
var plugin = client.plugin(p, pi);
perfmon(pm, function(err, data) {
plugin.addCounter(t, ti, data.counters[pm]);
});
};

var perfmonGaugeToPlugin = function(pm, p, pi, t, ti) {
// Note : do not use this function if you have more than one pm for the same (p,pi)
var plugin = client.plugin(p, pi);
perfmon(pm, function(err, data) {
plugin.setGauge(t, ti, data.counters[pm]);
});
};

function get_cpu() {
var cpus = os.cpus();
var user = 0;
Expand Down Expand Up @@ -59,6 +75,8 @@ function get_memory() {
var free = os.freemem();
plugin.setGauge('memory', 'free', parseInt(free));
plugin.setGauge('memory', 'used', parseInt(os.totalmem()) - parseInt(free));
perfmonGaugeToPlugin('\\Memory\\Pool Nonpaged Allocs', 'memory', '', 'memory', 'pool_nonpaged_allocs');
perfmonCounterToPlugin('\\Server\\Pool Paged Failures', 'memory', '', 'swap_io', 'pool_paged_failures');
}

function get_df() {
Expand Down Expand Up @@ -238,10 +256,7 @@ function get_interface() {
}

function get_load() {
var plugin = client.plugin('load', '');
perfmon('\\processor(_total)\\% processor time', function(err, data) {
plugin.setGauge('percent', '', data.counters['\\processor(_total)\\% processor time']);
});
perfmonGaugeToPlugin('\\processor(_total)\\% processor time', 'load', '', 'percent', '');
}

function get_uptime() {
Expand All @@ -250,17 +265,14 @@ function get_uptime() {
}

function get_process() {
var plugin = client.plugin('processes', '');
perfmon('\\Thread(_Total/_Total)\\Context Switches/sec', function(err, data) {
plugin.addCounter('contextswitch', '', data.counters['\\Thread(_Total/_Total)\\Context Switches/sec']);
});
perfmonCounterToPlugin('\\Thread(_Total/_Total)\\Context Switches/sec', 'processes', '', 'contextswitch', '');
perfmonGaugeToPlugin('\\Process(_Total)\\Pool Nonpaged Bytes', 'processes', '', 'bytes', 'pool_nonpaged');
perfmonGaugeToPlugin('\\Process(services)\\% Privileged Time', 'processes', 'services', 'percent', 'privileged_time');
perfmonGaugeToPlugin('\\Process(csrss)\\% Privileged Time', 'processes', 'csrss', 'percent', 'privileged_time');
}

function get_swap() {
var plugin = client.plugin('swap', '');
perfmon('\\Paging File(_Total)\\% Usage', function(err, data) {
plugin.setGauge('percent', '', data.counters['\\Paging File(_Total)\\% Usage']);
});
perfmonGaugeToPlugin('\\Paging File(_Total)\\% Usage', 'swap', '', 'percent', '');
}

exports.configShow = function() {
Expand Down

0 comments on commit ad80557

Please sign in to comment.