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 rtl_433 Prometheus exporter #96511

Merged
merged 5 commits into from Oct 23, 2020
Merged

Add rtl_433 Prometheus exporter #96511

merged 5 commits into from Oct 23, 2020

Conversation

@zopieux
Copy link
Contributor

@zopieux zopieux commented Aug 28, 2020

Motivation for this change

NixOS already packages rtl_433, an SDR receiver that among other things can decode metrics broadcast by 433MHz appliances such as thermometers.

This PR adds a lightweight Prometheus exporter written in Go for rtl_433 metrics.

I had to add further pkgs/modules (see first commits) to make that work seamlessly:

  1. upstream rtl-sdr (0.6.0) is using a very permissive udev ruleset that makes devices o+rw, which is not okay, so I backport a commit from their master branch to make it more locked-down
  2. because of 1. I had to make sure the "plugdev" group exists, so I introduce a small hardware.rtl-sdr module that enables said udev rules and ensures the group exists
  3. finally, I add the rtl_433_prometheus package and exporter module
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Copy link
Contributor

@delroth delroth left a comment

Please check https://nixos.org/nixpkgs/manual/#submitting-changes-making-patches re: commit message formatting.

In general it's also preferred to split off package and NixOS module into two separate commits.

@zopieux
Copy link
Contributor Author

@zopieux zopieux commented Aug 28, 2020

Thanks for the quick review. PTAL, refactored how I build the matcher options in the module.

@zopieux zopieux requested a review from delroth Aug 28, 2020
Copy link
Contributor

@delroth delroth left a comment

Just one small issue left.

nixos/modules/hardware/rtl-sdr.nix Outdated Show resolved Hide resolved
@zopieux zopieux force-pushed the rtl_433_prom branch 3 times, most recently from a214c9f to c404562 Aug 29, 2020
@zopieux zopieux marked this pull request as ready for review Aug 29, 2020
@zopieux zopieux requested a review from WilliButz as a code owner Aug 29, 2020
@zopieux zopieux force-pushed the rtl_433_prom branch 2 times, most recently from 92f527f to b73d88d Aug 29, 2020
@delroth
Copy link
Contributor

@delroth delroth commented Sep 19, 2020

FYI I'm now using this successfully on one of my systems. delroth/infra.delroth.net@067c709

@WilliButz any way you could help move this PR forward? I've done some review passes already and I feel like it's in a good shape, modulo one comment on "how to enable the hardware.* support when the exporter is enabled" still pending.

zopieux added 3 commits Sep 30, 2020
rtl-sdr latest release 0.6.0 is from 2018. Six months ago master received
a patch[1] to use improved udev rules that chown to plugdev instead of
making the devices world-read-writable.

This change backports [1] as an upstream patch.

[1] https://osmocom.org/projects/rtl-sdr/repository/revisions/b2814731563be4d5a0a68554ece6454a2c63af12
This is a very thin module to ensure "plugdev" user exists and some udev
rules are enabled, a prerequisite for using rtl-sdr.
@zopieux
Copy link
Contributor Author

@zopieux zopieux commented Sep 30, 2020

Upstream tagged a release, updated to use it instead of commit hash.

@nixos-discourse
Copy link

@nixos-discourse nixos-discourse commented Oct 4, 2020

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/317

Copy link
Member

@WilliButz WilliButz left a comment

Please excuse my delayed review, I made a few small improvement suggestions, otherwise this looks good to me.

Thanks for the contribution 👍

@zopieux zopieux requested a review from WilliButz Oct 23, 2020
Copy link
Member

@WilliButz WilliButz left a comment

👍

@WilliButz WilliButz merged commit 993437d into NixOS:master Oct 23, 2020
19 checks passed
@zopieux zopieux deleted the rtl_433_prom branch Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants