Add terminal service session info (#1525)

This commit is contained in:
Jan-Otto Kröpke
2024-07-24 11:18:08 +02:00
committed by GitHub
parent fa8d28c181
commit 7044b556c2
8 changed files with 409 additions and 120 deletions

View File

@@ -242,7 +242,7 @@ func (c *collector) collectRemoteFXNetworkCount(ctx *types.ScrapeContext, ch cha
for _, d := range dst {
// only connect metrics for remote named sessions
n := strings.ToLower(d.Name)
n := strings.ToLower(normalizeSessionName(d.Name))
if n == "" || n == "services" || n == "console" {
continue
}
@@ -250,81 +250,81 @@ func (c *collector) collectRemoteFXNetworkCount(ctx *types.ScrapeContext, ch cha
c.BaseTCPRTT,
prometheus.GaugeValue,
utils.MilliSecToSec(d.BaseTCPRTT),
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.BaseUDPRTT,
prometheus.GaugeValue,
utils.MilliSecToSec(d.BaseUDPRTT),
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.CurrentTCPBandwidth,
prometheus.GaugeValue,
(d.CurrentTCPBandwidth*1000)/8,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.CurrentTCPRTT,
prometheus.GaugeValue,
utils.MilliSecToSec(d.CurrentTCPRTT),
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.CurrentUDPBandwidth,
prometheus.GaugeValue,
(d.CurrentUDPBandwidth*1000)/8,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.CurrentUDPRTT,
prometheus.GaugeValue,
utils.MilliSecToSec(d.CurrentUDPRTT),
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.TotalReceivedBytes,
prometheus.CounterValue,
d.TotalReceivedBytes,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.TotalSentBytes,
prometheus.CounterValue,
d.TotalSentBytes,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.UDPPacketsReceivedPersec,
prometheus.CounterValue,
d.UDPPacketsReceivedPersec,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.UDPPacketsSentPersec,
prometheus.CounterValue,
d.UDPPacketsSentPersec,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.FECRate,
prometheus.GaugeValue,
d.FECRate,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.LossRate,
prometheus.GaugeValue,
d.LossRate,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.RetransmissionRate,
prometheus.GaugeValue,
d.RetransmissionRate,
d.Name,
normalizeSessionName(d.Name),
)
}
return nil
@@ -352,7 +352,7 @@ func (c *collector) collectRemoteFXGraphicsCounters(ctx *types.ScrapeContext, ch
for _, d := range dst {
// only connect metrics for remote named sessions
n := strings.ToLower(d.Name)
n := strings.ToLower(normalizeSessionName(d.Name))
if n == "" || n == "services" || n == "console" {
continue
}
@@ -360,60 +360,65 @@ func (c *collector) collectRemoteFXGraphicsCounters(ctx *types.ScrapeContext, ch
c.AverageEncodingTime,
prometheus.GaugeValue,
utils.MilliSecToSec(d.AverageEncodingTime),
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.FrameQuality,
prometheus.GaugeValue,
d.FrameQuality,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.FramesSkippedPerSecondInsufficientResources,
prometheus.CounterValue,
d.FramesSkippedPerSecondInsufficientClientResources,
d.Name,
normalizeSessionName(d.Name),
"client",
)
ch <- prometheus.MustNewConstMetric(
c.FramesSkippedPerSecondInsufficientResources,
prometheus.CounterValue,
d.FramesSkippedPerSecondInsufficientNetworkResources,
d.Name,
normalizeSessionName(d.Name),
"network",
)
ch <- prometheus.MustNewConstMetric(
c.FramesSkippedPerSecondInsufficientResources,
prometheus.CounterValue,
d.FramesSkippedPerSecondInsufficientServerResources,
d.Name,
normalizeSessionName(d.Name),
"server",
)
ch <- prometheus.MustNewConstMetric(
c.GraphicsCompressionratio,
prometheus.GaugeValue,
d.GraphicsCompressionratio,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.InputFramesPerSecond,
prometheus.CounterValue,
d.InputFramesPerSecond,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.OutputFramesPerSecond,
prometheus.CounterValue,
d.OutputFramesPerSecond,
d.Name,
normalizeSessionName(d.Name),
)
ch <- prometheus.MustNewConstMetric(
c.SourceFramesPerSecond,
prometheus.CounterValue,
d.SourceFramesPerSecond,
d.Name,
normalizeSessionName(d.Name),
)
}
return nil
}
// normalizeSessionName ensure that the session is the same between WTS API and performance counters
func normalizeSessionName(sessionName string) string {
return strings.Replace(sessionName, "RDP-tcp", "RDP-Tcp", 1)
}