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

Always reset counter metrics when automation restart wireguard interface #85

Open
rahmadsandy opened this issue Dec 8, 2021 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@rahmadsandy
Copy link

Hello @MindFlavor , honesty this amazing project

could this exporter save all metrics from the beginning with ignoring how often we restarted wireguard interface?
or could be store stats into file or some databases

i used this wireguard framework to manage https://github.com/vx3r/wg-gen-web
everytime do CUD (Create, Update and Delete) automatically restart wireguard interface
image

i think its could be good if this exporter could save from beginning depends from exporter systemd file status
image

image

@rahmadsandy rahmadsandy changed the title Always reset counter matrics when automation restart wireguard interface Always reset counter metrics when automation restart wireguard interface Dec 8, 2021
@MindFlavor
Copy link
Owner

Hello @rahmadsandy,
please correct me if I misunderstood. You are suggesting to persist the output of wg show all dump to use in case wireguard is restarting?

@rahmadsandy
Copy link
Author

sorry replying lately,
yes correct @MindFlavor

but i have tried after restarting wireguard service wg show all dump also resetting all data

@MindFlavor
Copy link
Owner

We can cache the last wg show all dump output but I am not sure it would help: the counters will get reset anyway at the next poll. I'll try and think about an alternative. If anyone in the community can chip in, it would be most welcome!

@MindFlavor MindFlavor added the help wanted Extra attention is needed label Jan 18, 2022
@rahmadsandy
Copy link
Author

thank you @MindFlavor still waiting your progress 🚀

@Lukeid
Copy link

Lukeid commented May 18, 2024

I'm in the same scenario. I would like to keep stats.

Maybe you can store last stats and:

For wireguard_sent_bytes_total: If new_wireguard_sent_bytes_total < last_wireguard_sent_bytes_total then wireguard_sent_bytes_total = new_wireguard_sent_bytes_total + last_wireguard_sent_bytes_total else wireguard_sent_bytes_total = new_wireguard_sent_bytes_total

For wireguard_received_bytes_totall: If new_wireguard_received_bytes_total < last_wireguard_received_bytes_total then wireguard_received_bytes_total = new_wireguard_received_bytes_total + last_wireguard_received_bytes_totall else wireguard_received_bytes_tota l= new_wireguard_received_bytes_total

For wireguard_latest_handshake_seconds:l: If new_wireguard_latest_handshake_seconds > last_wireguard_latest_handshake_seconds then wireguard_sent_bytes_total = last_wireguard_sent_bytes_total else wireguard_latest_handshake_seconds = new_wireguard_latest_handshake_seconds

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants