First pass of a way of handling multiple apcupsd hosts.#1
Open
cyberfox wants to merge 1 commit intoAndrolGenhald:masterfrom
Open
First pass of a way of handling multiple apcupsd hosts.#1cyberfox wants to merge 1 commit intoAndrolGenhald:masterfrom
cyberfox wants to merge 1 commit intoAndrolGenhald:masterfrom
Conversation
An example yaml file that would satisfy this would look like this:
```
address: 0.0.0.0:9175
hosts:
- address: 10.0.1.64
port: 3551
slug: ml-server
- address: 127.0.0.1
port: 3551
slug: greybox
```
Owner
|
Thanks for the interest! |
|
I think that this approach is incorrect: there should be labels for the new hosts, not prefixes. Take a look at our fork: purdueLUG/prometheus_exporter_apcupsd@ea49422 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An example yaml file that would satisfy this would look like this:
Without a slug defined, it will default to adding
apcupsd{#}to the front of the metrics lines, otherwise it adds the slug.This version changes the behavior; I can make it so that if there isn't a 'hosts' section, it doesn't prefix anything at all. I may also make it so it accepts hostnames instead of ports, but this works for me really well.
This is (literally) the first Rust code I've ever written, and even read more than a few lines of. My apologies if I've messed something up. The compiler is really surprisingly helpful. :)
Caveat: Once I had it entirely working by hand (only way to learn), I put it into a language model to ask if it was idiomatic, and it suggested some changes. I made some of them manually, and decided not to for others because they fit the style of the existing code more. It did show me how to clean up my absolute mess of clones, as_refs, '&'s and such, which I appreciated. 😅