akpw / mktxp

Prometheus Exporter for Mikrotik RouterOS devices
Other
504 stars 100 forks source link

mktxp routeros 7.5 POE collector not working #51

Closed dmqgit closed 1 year ago

dmqgit commented 1 year ago

Thanks for sharing your software.

I have an issue with the POE collector. I am running the mktxp (not the whole stack) inside of a docker environment.

I get the following error and no POE information:

docker logs mon_mktxp 
Connecting to router br-hvac@172.N.M.X
2022-12-06 15:18:08 Connection to router br-hvac@172.N.M.X has been established
2022-12-06 15:18:08 Running HTTP metrics server on port 49090
Error getting PoE info from routerbr@172.N.M.X: 'str' object is not callable
Error getting PoE info from routerbr@172.N.M.X: 'str' object is not callable
Error getting PoE info from routerbr@172.N.M.X: 'str' object is not callable

Mikrotik 960PGS hex POE, 7.5.

Can you reproduce this behavior?

One additonal question: can I request the values directly through "mktxp print" (I also installed it outside of docker env).

Thank you very much

akpw commented 1 year ago

@dmqgit are you on the latest mktxp version? since there were some POE-related fixes a couple of versions back

Regarding adding to mktxp print, OK makes sense

dmqgit commented 1 year ago

@akpw: thank you. I am on:

Prometheus Exporter for Mikrotik RouterOS, version 0.40

Should be the latest version (I guess).

What I meant with "mktxp print": is it possible to run commands with stdout to the cli (i.e. gather information about poe directly) or is it "just" for the implemented parameter "-cc" "-wc" und "-dc".

The routeros commands, like "/interface/ethernet/poe (...)" are working in the routeros shell.

Can I run the python scripts directly to verify / debug at which position the error happens?

Thanks again.

dmqgit commented 1 year ago

@akpw I think the error happens in poe_ds.py in the 'include_comments' section at:

comment = lambda interface: interface['comment'] if interface.get('comment') else ''

After the function call the value of comment is:

<function POEMetricsDataSource.metric_records.<locals>.<lambda> at 0x7f8c7ae3edc0>

This leads to an exception.

When I comment the block 'include comments' out, everything is working.

What is interesting: I also can set the configuraiton value 'use_comments_over_names' to 'False' - but event then it runs in this error state.

akpw commented 1 year ago

@dmqgit thanks for investigating. the lambda function definition looks OK, though there indeed seems to be a naming problem a couple of lines later when the function is actually called (for multiple POE records, it gets overridden with the result of its first call).

renaming the function to smth like: comment_fn = lambda interface: interface['comment'] if interface.get('comment') else makes things work as expected. I'll submit a fix later today or tomorrow, thanks again for helping track it down.

I also can set the configuration value 'use_comments_over_names' to 'False' - but even then it runs in this error state.

that is currently as designed, in case of False the comment does not replace interface name but still gets used alongside it.

What I meant with "mktxp print": is it possible to run commands with stdout to the cli (i.e. gather information about poe directly) or is it "just" for the implemented parameter "-cc" "-wc" und "-dc".

this needs to be implemented for each individual parameter, completely different output format. I can add it for POE and a few other things where it make sense to get the info directly via cli

akpw commented 1 year ago

@dmqgit

I'll submit a fix later today or tomorrow

done, pls feel free to try out with the latest

dmqgit commented 1 year ago

@akpw thank you very much for the fast fix and again for the effort and publishing. The latest release works as expected.

this needs to be implemented for each individual parameter, completely different output format. I can add it for POE and a few other things where it make sense to get the info directly via cli

Thanks for clarifying. I think it would be a good enhancement for the future.

Have a nice day - I will close the issue.

dmqgit commented 1 year ago

Issue resolved by @akpw