-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
ffmpeg.go
50 lines (38 loc) · 1.25 KB
/
ffmpeg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package monitor
import (
"github.com/datarhei/core/ffmpeg"
"github.com/datarhei/core/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() {}