You've already forked prometheus-fail2ban-exporter
refactor: create new collector folder
Create a new `collector` folder to store the code for the different collectors. Move the existing f2b and textfile collectors to this folder. Minor refactors to the f2b collector to better match the code style of the newer textfile collector.
This commit is contained in:
20
src/collector/textfile/writer.go
Normal file
20
src/collector/textfile/writer.go
Normal file
@ -0,0 +1,20 @@
|
||||
package textfile
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (c *Collector) WriteTextFileMetrics(w http.ResponseWriter, r *http.Request) {
|
||||
if !c.enabled {
|
||||
return
|
||||
}
|
||||
|
||||
for _, f := range c.fileMap {
|
||||
_, err := w.Write(f.fileContents)
|
||||
if err != nil {
|
||||
c.appendErrorForPath(f.fileName)
|
||||
log.Printf("error writing file contents to response writer '%s': %v", f.fileName, err)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user