Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return value is True even if value is not actually sent #5

Open
gmichels opened this issue Oct 1, 2014 · 4 comments
Open

Return value is True even if value is not actually sent #5

gmichels opened this issue Oct 1, 2014 · 4 comments

Comments

@gmichels
Copy link

gmichels commented Oct 1, 2014

Hey,

The function for sending data only evaluates if the response from the Zabbix server was valid or not:

if resp.get('response') != 'success':

There are cases where the response is successful though actually sending the value failed:

[Dbg]>>> print resp.get('info')
processed: 0; failed: 1; total: 1; seconds spent: 0.000022
[Dbg]>>> print resp.get('response')
success

Maybe you could add another condition for the evaluation, something as simple as:

if resp.get('response') != 'success' or resp.get('info').find('failed: 1') != -1:

Thanks

@pistolero
Copy link
Owner

I don't really want to parse plain text in order to get this information, unless there is a good use-case where this is required.

@gmichels
Copy link
Author

gmichels commented Oct 2, 2014

The use case is clear, the information is sent however the host/key did not exist, therefore sending the value failed, although the actual connection was successful (which is why 'response' is 'success').

I know that was a quick and dirty way to solve it, I also think the response should be properly parsed and then evaluated. Just didn't have the time to do it, but I'll get to it and let you know, if you still believe it's something you would allow to be implemented.

Thanks

@pistolero
Copy link
Owner

If you could make a small patch to implement this, that would be great.

@gmichels
Copy link
Author

gmichels commented Oct 2, 2014

        logger.info(resp.get('info'))
        resp_info = dict(u.split(": ") for u in resp.get('info').split("; "))
        if resp.get('response') != 'success' or int(resp_info['failed']) > 0:
            logger.error('Got error from Zabbix: %s', resp)
59,60c60,61
<         if resp.get('response') != 'success':
---
>         resp_info = dict(u.split(": ") for u in resp.get('info').split("; "))
>         if resp.get('response') != 'success' or int(resp_info['failed']) > 0:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants