-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from sumitgoelpw/devel
code refactor and option to pass params directly to request object
- Loading branch information
Showing
21 changed files
with
832 additions
and
484 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 |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
[libs] | ||
|
||
[options] | ||
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe |
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
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
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
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
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
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,10 @@ | ||
const zabbix = require('../index'); | ||
|
||
zabbix.sender({ | ||
'path': '/usr/local/bin/zabbix_sender', | ||
'server': 'zabbix-dev', | ||
'host': 'CloudGenix-Events', | ||
'values': '- testing 444\n- testing 111\n' | ||
}) | ||
.then((value) => console.log(value)) | ||
.catch((reason) => console.log(reason)); |
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
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 |
---|---|---|
@@ -1,12 +1,66 @@ | ||
const Zabbix = require('./api'); | ||
const { exec } = require('child_process'); | ||
|
||
class Client extends Zabbix { | ||
|
||
sendValues() { | ||
static sender(options) { | ||
|
||
console.log(`Coming soon... ${this.url}`); | ||
} | ||
// $FlowFixMe: more research needed | ||
return new Promise((resolve, reject) => { | ||
// eslint-disable-line max-statements, max-len | ||
|
||
} | ||
if (!Object.prototype.hasOwnProperty.call(options, 'path')) { | ||
|
||
reject(new Error('Please provide full path for zabbix_sender ' + 'utility.')); | ||
} // eslint: path | ||
|
||
if (!Object.prototype.hasOwnProperty.call(options, 'server')) { | ||
|
||
reject(new Error('Please provide zabbix server or proxy name.')); | ||
} // eslint: server | ||
|
||
if (!Object.prototype.hasOwnProperty.call(options, 'port')) { | ||
|
||
options.port = '10051'; | ||
} // eslint: port | ||
|
||
if (!Object.prototype.hasOwnProperty.call(options, 'host')) { | ||
|
||
reject(new Error('Please provide the zabbix host name as ' + 'registered in Zabbix frontend.')); | ||
} // eslint: host | ||
|
||
if (!Object.prototype.hasOwnProperty.call(options, 'values')) { | ||
|
||
reject(new Error('Specify values each line contains whitespace ' + 'delimited: - <key> <value>')); | ||
} // eslint: values | ||
|
||
resolve(options); | ||
}).then(val => { | ||
|
||
const { path, server, port, host, values } = val; | ||
|
||
return new Promise((resolve, reject) => { | ||
|
||
let cmd = `printf -- '${values}' | ${path} -vv -z ${server} `; | ||
cmd += `-p ${port} -s ${host} -r -i -`; | ||
|
||
exec(cmd, (error, stdout, stderr) => { | ||
|
||
if (error) { | ||
|
||
return reject(error); | ||
} | ||
|
||
return resolve({ | ||
stdout, | ||
stderr | ||
}); | ||
}); // eslint: exec | ||
}); // eslint: promise | ||
}); // eslint: then | ||
|
||
} // eslint: sender | ||
|
||
} // eslint: Class | ||
|
||
module.exports = Client; |
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
Oops, something went wrong.