mirror of
https://github.com/datarhei/core.git
synced 2025-10-02 06:42:25 +08:00

Commits (Ingo Oppermann): - Add experimental SRT connection stats and logs - Hide /config/reload endpoint in reade-only mode - Add SRT server - Create v16 in go.mod - Fix data races, tests, lint, and update dependencies - Add trailing slash for routed directories (datarhei/restreamer#340) - Allow relative URLs in content in static routes Co-Authored-By: Ingo Oppermann <57445+ioppermann@users.noreply.github.com>
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package monitor
|
|
|
|
import (
|
|
"github.com/datarhei/core/v16/io/fs"
|
|
"github.com/datarhei/core/v16/monitor/metric"
|
|
)
|
|
|
|
type filesystemCollector struct {
|
|
fs fs.Filesystem
|
|
name string
|
|
limitDescr *metric.Description
|
|
usageDescr *metric.Description
|
|
filesDescr *metric.Description
|
|
}
|
|
|
|
func NewFilesystemCollector(name string, fs fs.Filesystem) metric.Collector {
|
|
c := &filesystemCollector{
|
|
fs: fs,
|
|
name: name,
|
|
}
|
|
|
|
c.limitDescr = metric.NewDesc("filesystem_limit", "", []string{"name"})
|
|
c.usageDescr = metric.NewDesc("filesystem_usage", "", []string{"name"})
|
|
c.filesDescr = metric.NewDesc("filesystem_files", "", []string{"name"})
|
|
|
|
return c
|
|
}
|
|
|
|
func (c *filesystemCollector) Prefix() string {
|
|
return "filesystem"
|
|
}
|
|
|
|
func (c *filesystemCollector) Describe() []*metric.Description {
|
|
return []*metric.Description{
|
|
c.limitDescr,
|
|
c.usageDescr,
|
|
c.filesDescr,
|
|
}
|
|
}
|
|
|
|
func (c *filesystemCollector) Collect() metric.Metrics {
|
|
size, limit := c.fs.Size()
|
|
files := c.fs.Files()
|
|
|
|
metrics := metric.NewMetrics()
|
|
|
|
metrics.Add(metric.NewValue(c.limitDescr, float64(limit), c.name))
|
|
metrics.Add(metric.NewValue(c.usageDescr, float64(size), c.name))
|
|
metrics.Add(metric.NewValue(c.filesDescr, float64(files), c.name))
|
|
|
|
return metrics
|
|
}
|
|
|
|
func (c *filesystemCollector) Stop() {}
|