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

Add initial wifi collector #413

Merged
merged 1 commit into from
Jan 12, 2017
Merged

Add initial wifi collector #413

merged 1 commit into from
Jan 12, 2017

Conversation

mdlayher
Copy link
Contributor

@mdlayher mdlayher commented Jan 9, 2017

Depends on #412 .

No idea how to test this honestly. I've been developing by copying the binary over to my laptop and poking at it there. Can CI tests be done with a virtual wireless device of some sort?

@mdlayher
Copy link
Contributor Author

mdlayher commented Jan 9, 2017

Fixes #326 .

@discordianfish
Copy link
Member

Yes, testing is in general not easy with the node-exporter.. Only option I see is to mock what your library returns but even then it's hard to test. I'd say it's okay to merge it without tests though.

If you based this PR on #412, the tests should parse. But we can also merge that first and rebase this here. Whatever you prefer.

@mdlayher
Copy link
Contributor Author

@discordianfish Yep, my plan was to just rebase once #412 was merged. Keeps things simple.

@mdlayher
Copy link
Contributor Author

For some of my personal exporters, I've been using this pattern for testing: https://github.com/mdlayher/unifi_exporter/blob/master/unifiexporter_test.go#L27-L48.

Seems to work well. You'd just construct the collector with an interface that can use the system implementation or a mocked one, and then parse the output and see if you get the metrics you expect.

@discordianfish
Copy link
Member

@mdlayher That's from the idea similar to the end-to-end-tests.sh. But mocking the whole collector doesn't really make sense, mocking your package's functions would make more sense I guess.
Other collectors that just read a bunch of files from /proc or /sys have a flag where you can point them to some fixtures. Maybe something similar would be possible as well? Not really familiar with the netlink interface.

@mdlayher
Copy link
Contributor Author

mdlayher commented Jan 10, 2017

I can do a -collector.wifi="collector/fixtures/wifi" if that works. It isn't ideal and I'd have to parse out text files (probably JSON), but it'd work.

@discordianfish
Copy link
Member

@mdlayher Probably better than having no tests.. Wouldn't know a better way without being able to actually emulate wifi devices.

Googling for this brought up though https://github.com/martinpitt/umockdev though. Probably doesn't help but maybe worth having a look?

@mdlayher
Copy link
Contributor Author

@discordianfish updated with a flag for end-to-end tests that uses JSON fixture files.

Once #412 is merged, does this look good?

@mdlayher
Copy link
Contributor Author

@discordianfish @SuperQ all fixed up! Take a look!

),

StationReceiveBitrateBPS: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_receive_bitrate_bps"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe station_receive_bits_per_second?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

),

StationTransmitRetriesTotal: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_transmit_retries_total"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there is no count for all transmit/attempts? Would be nice to also have the successful transmits.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux does expose a "transmitted packets" metric via nl80211, but I believe this would be redundant with node_network_transmit_packets.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm good point but wouldn't that apply to drops/errs as well? Or are they different from failed metrics here? But yeah, either way it probably makes sense to keep these as they are for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately nl80211 isn't super clear about it: http://lxr.free-electrons.com/source/include/uapi/linux/nl80211.h#L2620.

* @NL80211_STA_INFO_TX_FAILED: total failed packets (MPDUs)
*      (u32, to this station)

For the time being, at least it'll be useful to see if/when a number of transmission failures and beacon losses start occurring, so a weak connection can be easily identified.

@discordianfish
Copy link
Member

See @SuperQ's comment and my question, but looking good in general!

@mdlayher
Copy link
Contributor Author

I appear to have paused CircleCI because of a few quick amends and pushes. Oops.

https://circleci.com/gh/prometheus/node_exporter/457

Hopefully it kicks off on its own soon.

Copy link
Member

@discordianfish discordianfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@discordianfish discordianfish merged commit 3b6b5df into prometheus:master Jan 12, 2017
@mdlayher mdlayher deleted the wifi branch January 12, 2017 15:03
@SuperQ SuperQ mentioned this pull request Jan 15, 2017
@grobie grobie mentioned this pull request Mar 7, 2017
tamcore pushed a commit to gitgrave/node_exporter that referenced this pull request Oct 22, 2024
* fixed arp table mac address parsing

- Added ARPEntry.Flags field related to entry flags
- Added ARPEntry.IsComplete() to check if entry is complete
- Fixed mac address parsing and error handling
- Test improved with incomplete entry information
Closes prometheus#413.

Signed-off-by: Serhii Zasenko <sergii@zasenko.name>

* Arp flag const names cleanup

Signed-off-by: Serhii Zasenko <sergii@zasenko.name>
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

Successfully merging this pull request may close these issues.

3 participants