-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,60 @@ | ||
package mpjitsivideobridge | ||
|
||
import ( | ||
"flag" | ||
"strings" | ||
|
||
mp "github.com/mackerelio/go-mackerel-plugin" | ||
) | ||
|
||
// JitsiVideobridgePlugin as Mackerel agent plugin for Jitsi Videobridge | ||
type JitsiVideobridgePlugin struct { | ||
Prefix string | ||
Host string | ||
Port string | ||
} | ||
|
||
// MetricKeyPrefix returns prefix of Jitsi Videobridge metrics | ||
func (p JitsiVideobridgePlugin) MetricKeyPrefix() string { | ||
if p.Prefix == "" { | ||
p.Prefix = "jitsi-videobridge" | ||
} | ||
return p.Prefix | ||
} | ||
|
||
// GraphDefinition returns graph definition | ||
func (p JitsiVideobridgePlugin) GraphDefinition() map[string]mp.Graphs { | ||
labelPrefix := strings.Title(p.MetricKeyPrefix()) | ||
return map[string]mp.Graphs{ | ||
"Audio Channels": { | ||
Label: labelPrefix, | ||
Unit: mp.UnitInteger, | ||
Metrics: []mp.Metrics{ | ||
{Name: "audiochannels", Label: "Audio Channels"}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
// FetchMetrics fetches metrics from Jitsi Videobridge Colibri REST interface | ||
func (p JitsiVideobridgePlugin) FetchMetrics() (map[string]float64, error) { | ||
return map[string]float64{"audiochannels": 0}, nil | ||
} | ||
|
||
// Do the plugin | ||
func Do() { | ||
optPrefix := flag.String("metric-key-prefix", "jitsi-videobridge", "Metric key prefix") | ||
optHost := flag.String("host", "127.0.0.1", "Hostname or IP address of Jitsi Videobridge Colibri REST interface") | ||
optPort := flag.String("port", "80", "Port of Jitsi Videobridge Colibri REST interface") | ||
optTempfile := flag.String("tempfile", "", "Temp file name") | ||
flag.Parse() | ||
|
||
p := JitsiVideobridgePlugin{ | ||
Prefix: *optPrefix, | ||
Host: *optHost, | ||
Port: *optPort, | ||
} | ||
helper := mp.NewMackerelPlugin(p) | ||
helper.Tempfile = *optTempfile | ||
helper.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package mpjitsivideobridge | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestMetricKeyPrefix(t *testing.T) { | ||
var p JitsiVideobridgePlugin | ||
|
||
expected := "jitsi-videobridge" | ||
actual := p.MetricKeyPrefix() | ||
|
||
if actual != expected { | ||
t.Errorf("MetricKeyPrefix: %v should be %v", actual, expected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package main | ||
|
||
import "github.com/tomohiro/mackerel-plugin-jitsi-videobridge/lib" | ||
import mpjitsivideobridge "github.com/tomohiro/mackerel-plugin-jitsi-videobridge/lib" | ||
|
||
func main() { | ||
mpjvb.Do() | ||
mpjitsivideobridge.Do() | ||
} |