lorenzosaino / go-sysctl

Go wrapper around the sysctl interface
BSD 3-Clause "New" or "Revised" License
53 stars 9 forks source link

Watching for changes #1

Closed shibumi closed 5 years ago

shibumi commented 5 years ago

Hi, Am I able to watch for sysctl changes with this implementation? I have a specific key in sysctl and I want to watch for changes of this key. Is this doable with good performance or would I run into a lot "file open, file read, file closed" operations?

lorenzosaino commented 5 years ago

Hi @shibumi,

Apologies for the very late reply, I realized I wasn't subscribed to notifications and I just saw your issue by accident.

Probably the answer is no longer timely but I am answering anyway for posterity. The current implementation does not support watching for changes to a sysctl value. I would personally implement this by periodically polling sysctl.Get(...) on the key you are interested in.

To the best of my knowledge, the is actually the only option. I am not aware of a way to subscribe to file changes: fnsotify, which on Linux uses inotify under the hood, does not work with procfs: https://github.com/fsnotify/fsnotify/issues/78

lorenzosaino commented 5 years ago

I am going to close this issue for now. Feel free to reopen if you have further questions.

shibumi commented 5 years ago

@lorenzosaino Sorry for the late reply. No, all questions were answered. Thanks :)