You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
3.0 KiB
57 lines
3.0 KiB
4 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/denzs/wsjtx-exporter/shared/wsjtx"
|
||
|
"github.com/prometheus/client_golang/prometheus"
|
||
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||
|
log "github.com/sirupsen/logrus"
|
||
|
)
|
||
|
|
||
|
var wsjtx_received_total *prometheus.CounterVec
|
||
|
//var wsjtx_received_call_total *prometheus.CounterVec
|
||
|
|
||
|
func handlePrometheus(result wsjtx.Result) {
|
||
|
incr_wsjtx_received_total(result)
|
||
|
// if promcalls {
|
||
|
// incr_wsjtx_received_callsigns_total(result)
|
||
|
// }
|
||
|
}
|
||
|
|
||
|
|
||
|
func incr_wsjtx_received_total(result wsjtx.Result) {
|
||
|
if(wsjtx_received_total == nil) {
|
||
|
log.Printf("init prometheus metric wsjtx_received_total..")
|
||
|
wsjtx_received_total = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "wsjtx_received_total", Help: "DXCCs ordery by labels",
|
||
|
}, []string{"num","signal","name","continent","cqzone","ituzone","band","mode","geohash","station"},)
|
||
|
}
|
||
|
wsjtx_received_total.With(prometheus.Labels{"num":fmt.Sprintf("%d",result.Ent.DXCC),"signal":fmt.Sprintf("%d",result.Signal),
|
||
|
"band":result.Band,
|
||
|
"name":result.Ent.Entity,
|
||
|
"continent":result.Ent.Continent,
|
||
|
"cqzone":fmt.Sprintf("%d",result.Ent.CQZone),
|
||
|
"mode":result.Mode,
|
||
|
"geohash":result.GeoHash,
|
||
|
"station": result.Station,
|
||
|
"ituzone":fmt.Sprintf("%d",result.Ent.ITUZone)}).Inc()
|
||
|
}
|
||
|
|
||
|
|
||
|
//func incr_wsjtx_received_callsigns_total(result wsjtx.Result) {
|
||
|
// if(wsjtx_received_call_total == nil) {
|
||
|
// log.Printf("inicreating wsjtx_received_call_total..")
|
||
|
// wsjtx_received_call_total = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "wsjtx_received_call_total", Help: "DXCCs ordery by labels",
|
||
|
// }, []string{"num","signal","name","continent","cqzone","ituzone","band","call","mode","geohash","station"},)
|
||
|
// }
|
||
|
// wsjtx_received_call_total.With(prometheus.Labels{"num":fmt.Sprintf("%d",result.Ent.DXCC),"signal":fmt.Sprintf("%d",result.Signal),
|
||
|
// "band":result.Band,
|
||
|
// "name":result.Ent.Entity,
|
||
|
// "continent":result.Ent.Continent,
|
||
|
// "cqzone":fmt.Sprintf("%d",result.Ent.CQZone),
|
||
|
// "mode":result.Mode,
|
||
|
// "call":result.Call,
|
||
|
// "geohash":result.GeoHash,
|
||
|
// "station": station,
|
||
|
// "ituzone":fmt.Sprintf("%d",result.Ent.ITUZone)}).Inc()
|
||
|
//}
|