Files
core/monitor/ffmpeg.go
Jan Stabenow eb1cc37456 Add GoSRT & improvements (repo-merge)
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>
2022-06-23 22:13:58 +02:00

51 lines
1.3 KiB
Go

package monitor
import (
"github.com/datarhei/core/v16/ffmpeg"
"github.com/datarhei/core/v16/monitor/metric"
)
type ffmpegCollector struct {
prefix string
ffmpeg ffmpeg.FFmpeg
processDescr *metric.Description
}
func NewFFmpegCollector(f ffmpeg.FFmpeg) metric.Collector {
c := &ffmpegCollector{
prefix: "ffmpeg",
ffmpeg: f,
}
c.processDescr = metric.NewDesc("ffmpeg_process", "", []string{"state"})
return c
}
func (c *ffmpegCollector) Prefix() string {
return c.prefix
}
func (c *ffmpegCollector) Describe() []*metric.Description {
return []*metric.Description{
c.processDescr,
}
}
func (c *ffmpegCollector) Collect() metric.Metrics {
metrics := metric.NewMetrics()
states := c.ffmpeg.States()
metrics.Add(metric.NewValue(c.processDescr, float64(states.Finished), "finished"))
metrics.Add(metric.NewValue(c.processDescr, float64(states.Starting), "starting"))
metrics.Add(metric.NewValue(c.processDescr, float64(states.Running), "running"))
metrics.Add(metric.NewValue(c.processDescr, float64(states.Finishing), "finishing"))
metrics.Add(metric.NewValue(c.processDescr, float64(states.Failed), "failed"))
metrics.Add(metric.NewValue(c.processDescr, float64(states.Killed), "killed"))
return metrics
}
func (c *ffmpegCollector) Stop() {}