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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

56 lines
2.9 KiB

package main
import (
"fmt"
"github.com/denzs/wsjtx_dashboards/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("creating 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": 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("creating 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()
}