Skip to content

Commit

Permalink
even more cleaning and tidying.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steev Hise committed Sep 5, 2017
1 parent 744316a commit 9a7af2a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/zabbix.js
Expand Up @@ -34,10 +34,6 @@ var zabbixStats = {};

var post_stats = function zabbix_post_stats(statString) {
if (zabbixHost) {
if (debug) {
util.log('statsString: ' + statString);
}

if(zabbixCmd) {
// we're spawning a child process to run the shell zabbix_sender command
try {
Expand All @@ -64,12 +60,16 @@ var post_stats = function zabbix_post_stats(statString) {
var statArray = statString.split('\n');
statArray.forEach(function (v, i, array) {
var data = v.split(' ', 4);
// third one is always the timestamp so leave that out.
Sender.addItem([data[0], data[1]].join('.'), data[3]);
if (debug) {
util.log([data[0], data[1]].join('.'), data[3]);
if (data[1]) { // there might be a blank line at the end.
// third one is always the timestamp so leave that out.
Sender.addItem([data[0], data[1]].join('.'), data[3]);
if (debug) {
util.log([data[0], data[1]].join('.'), data[3]);
}
}
});


Sender.send(function (err, res) {
if (err) {
throw err;
Expand All @@ -80,6 +80,9 @@ var post_stats = function zabbix_post_stats(statString) {
util.log(res);
}
});



} catch (e) {
if (debug) {
util.log('node-zabbix-sender error: ' + e);
Expand Down

0 comments on commit 9a7af2a

Please sign in to comment.