StarryShark / zabbix-promise

Simplified Zabbix API Client for JavaScript Node.js Runtime.
https://sumitgoelpw.github.io/zabbix-promise/
MIT License
39 stars 15 forks source link

Provide stdout for zabbix sender failure #14

Closed alexraddas closed 4 years ago

alexraddas commented 6 years ago

When there is a failed item for zabbix_sender when used as a binary the output is presented when x number for processed and x number for failed items and exits with status 2. When using zabbix-promise it just fails with no stdout even if one of the items succeeds.

Binary Example:

zabbix_sender -z zabbix-dev -s testhost -k testing2 -o 1 ; echo $? 
info from server: "processed: 0; failed: 1; total: 1; seconds spent: 0.000031"
sent: 1; skipped: 0; total: 1
2

zabbix-promise Example:

    zabbix.sender({
        'path': '/usr/local/bin/zabbix_sender',
        'server': 'zabbix-dev',
        'host': 'testhost',
        'values': '- testing 444\n- testing2 111\n',
    })
    .then((value) => console.log(value))
    .catch((reason) => console.log(reason));

Error: /usr/local/bin/zabbix_sender process exited with code 2
    at ChildProcess.cmd.on (/Users/user/test/zabbix-promise-test/node_modules/zabbix-promise/lib/utils.js:61:20)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:567:12)
StarryShark commented 5 years ago

@alexraddas The zabbix-promise project released a major version v2.0.0. The package is written to support JavaScript Promise and Async/await interfaces. Zabbix-promise implements Zabbix sender protocol in pure JavaScript code, and there are no other package dependencies, just the Node.js runtime.

Check it out, and it should resolve the issue.