qiangmzsx / bind_stats_exporter

Get BIND DNS stats from named_stats file and prometheus
Apache License 2.0
4 stars 0 forks source link

[FEAT] Obsolete stats.sh #2

Open SchoolGuy opened 7 months ago

SchoolGuy commented 7 months ago

This package comes with a script called stats.sh. I would love to understand why this approach was chosen instead of calling the corresponding commands directly from golang.

If there is no particular reason I would love to try and contribute code to replace it (it might take a good long while though due to my load atm).

qiangmzsx commented 7 months ago

The reason for using the -stats.sh approach is to make it easier for the user to configure the specified bind, and also to customize some other additional actions on that script.

If you have other good ideas, you can discuss them together!

SchoolGuy commented 7 months ago

The script requires the following information:

The golang binary currently has already information in a configurable manner about the first thing. In my eyes it is acceptable to introduce a new option called bind.binary with a default of /usr/sbin/rndc.

Here we could then directly call the command and add an unlink command to the stats file beforehand:

https://github.com/qiangmzsx/bind_stats_exporter/blob/8c3d511269f67c217cb8d9a413301d187ebe7e1d/bind_exporter_stats.go#L347

qiangmzsx commented 7 months ago

The script requires the following information:

  • location of the stats file (currently hardcoded in the script)
  • location of rndc (currently hardcoded in the script)

The golang binary currently has already information in a configurable manner about the first thing. In my eyes it is acceptable to introduce a new option called bind.binary with a default of /usr/sbin/rndc.

Here we could then directly call the command and add an unlink command to the stats file beforehand:

https://github.com/qiangmzsx/bind_stats_exporter/blob/8c3d511269f67c217cb8d9a413301d187ebe7e1d/bind_exporter_stats.go#L347

I think it's possible, you can realize it. It's going to be very rewarding!