mirror of
https://codeberg.org/scip/io-exporter.git
synced 2025-12-19 05:21:01 +01:00
Compare commits
3 Commits
v0.0.6
...
refactor-e
| Author | SHA1 | Date | |
|---|---|---|---|
| 5001dea502 | |||
| d4477972f3 | |||
| 3be1a6be5d |
@@ -6,7 +6,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ncw/directio"
|
"github.com/ncw/directio"
|
||||||
@@ -33,10 +32,7 @@ func NewExporter(conf *Config, alloc *Alloc, metrics *Metrics) *Exporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// starts the primary go-routine, which will run the io checks for ever
|
// starts the primary go-routine, which will run the io checks for ever
|
||||||
func (exp *Exporter) RunIOchecks() *sync.WaitGroup {
|
func (exp *Exporter) RunIOchecks() {
|
||||||
var wg sync.WaitGroup
|
|
||||||
wg.Add(1)
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
var res_r, res_w Result
|
var res_r, res_w Result
|
||||||
@@ -64,8 +60,6 @@ func (exp *Exporter) RunIOchecks() *sync.WaitGroup {
|
|||||||
time.Sleep(time.Duration(exp.conf.Sleeptime) * time.Second)
|
time.Sleep(time.Duration(exp.conf.Sleeptime) * time.Second)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return &wg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// call an io measurement and collect time needed
|
// call an io measurement and collect time needed
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func Run() {
|
|||||||
alloc := NewAlloc()
|
alloc := NewAlloc()
|
||||||
exporter := NewExporter(conf, alloc, metrics)
|
exporter := NewExporter(conf, alloc, metrics)
|
||||||
|
|
||||||
wg := exporter.RunIOchecks()
|
exporter.RunIOchecks()
|
||||||
|
|
||||||
http.Handle("/metrics", promhttp.HandlerFor(
|
http.Handle("/metrics", promhttp.HandlerFor(
|
||||||
metrics.registry,
|
metrics.registry,
|
||||||
@@ -49,8 +49,6 @@ func Run() {
|
|||||||
if err := http.ListenAndServe(fmt.Sprintf(":%d", conf.Port), nil); err != nil {
|
if err := http.ListenAndServe(fmt.Sprintf(":%d", conf.Port), nil); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func report(err error, fd *os.File) bool {
|
func report(err error, fd *os.File) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user