Skip to content

Commit

Permalink
#71 Fix vpn connection stats
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenRover committed Jun 26, 2024
1 parent 01d2b8e commit 1ff44e0
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 35 deletions.
7 changes: 0 additions & 7 deletions semp/getVpnSemp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ func (e *Semp) GetVpnSemp1(ch chan<- PrometheusMetric, vpnFilter string) (ok flo
TotalLocalUniqueSubscriptions float64 `xml:"total-local-unique-subscriptions"`
TotalRemoteUniqueSubscriptions float64 `xml:"total-remote-unique-subscriptions"`
TotalUniqueSubscriptions float64 `xml:"total-unique-subscriptions"`
ConnectionsAmqService float64 `xml:"connections-service-amqp"`
ConnectionsSmfService float64 `xml:"connections-service-smf"`
Connections float64 `xml:"connections"`
QuotaConnections float64 `xml:"max-connections"`
} `xml:"vpn"`
} `xml:"message-vpn"`
} `xml:"show"`
Expand Down Expand Up @@ -67,10 +64,6 @@ func (e *Semp) GetVpnSemp1(ch chan<- PrometheusMetric, vpnFilter string) (ok flo
ch <- e.NewMetric(MetricDesc["Vpn"]["vpn_total_local_unique_subscriptions"], prometheus.GaugeValue, vpn.TotalLocalUniqueSubscriptions, vpn.Name)
ch <- e.NewMetric(MetricDesc["Vpn"]["vpn_total_remote_unique_subscriptions"], prometheus.GaugeValue, vpn.TotalRemoteUniqueSubscriptions, vpn.Name)
ch <- e.NewMetric(MetricDesc["Vpn"]["vpn_total_unique_subscriptions"], prometheus.GaugeValue, vpn.TotalUniqueSubscriptions, vpn.Name)
ch <- e.NewMetric(MetricDesc["Vpn"]["vpn_connections_service_amqp"], prometheus.GaugeValue, vpn.ConnectionsAmqService, vpn.Name)
ch <- e.NewMetric(MetricDesc["Vpn"]["vpn_connections_service_smf"], prometheus.GaugeValue, vpn.ConnectionsSmfService, vpn.Name)
ch <- e.NewMetric(MetricDesc["Vpn"]["vpn_connections"], prometheus.GaugeValue, vpn.Connections, vpn.Name)
ch <- e.NewMetric(MetricDesc["Vpn"]["vpn_quota_connections"], prometheus.GaugeValue, vpn.QuotaConnections, vpn.Name)
}

return 1, nil
Expand Down
35 changes: 31 additions & 4 deletions semp/getVpnStatsSemp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,23 @@ func (e *Semp) GetVpnStatsSemp1(ch chan<- PrometheusMetric, vpnFilter string) (o
Show struct {
MessageVpn struct {
Vpn []struct {
Name string `xml:"name"`
LocalStatus string `xml:"local-status"`
Connections float64 `xml:"connections"`
Stats struct {
Name string `xml:"name"`
LocalStatus string `xml:"local-status"`
Connections float64 `xml:"connections"`
QuotaConnections float64 `xml:"max-connections"`
QuotaConnectionsSmf float64 `xml:"max-connections-service-smf"`
QuotaConnectionsWeb float64 `xml:"max-connections-service-web"`
QuotaConnectionsMqtt float64 `xml:"max-connections-service-mqtt"`
QuotaConnectionsAmqp float64 `xml:"max-connections-service-amqp"`
QuotaConnectionsRestIn float64 `xml:"max-connections-service-rest-incoming"`
QuotaConnectionsRestOut float64 `xml:"max-connections-service-rest-outgoing"`
ConnectionsAmqService float64 `xml:"connections-service-amqp"`
ConnectionsSmfService float64 `xml:"connections-service-smf"`
ConnectionsWebService float64 `xml:"connections-service-web"`
ConnectionsMqttService float64 `xml:"connections-service-mqtt"`
ConnectionsRestInService float64 `xml:"connections-service-rest-incoming"`
ConnectionsRestOutService float64 `xml:"connections-service-rest-outgoing"`
Stats struct {
DataRxByteCount float64 `xml:"client-data-bytes-received"`
DataRxMsgCount float64 `xml:"client-data-messages-received"`
DataTxByteCount float64 `xml:"client-data-bytes-sent"`
Expand Down Expand Up @@ -72,6 +85,20 @@ func (e *Semp) GetVpnStatsSemp1(ch chan<- PrometheusMetric, vpnFilter string) (o
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_tx_bytes_total"], prometheus.CounterValue, vpn.Stats.DataTxByteCount, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_rx_discarded_msgs_total"], prometheus.CounterValue, vpn.Stats.IngressDiscards.DiscardedRxMsgCount, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_tx_discarded_msgs_total"], prometheus.CounterValue, vpn.Stats.EgressDiscards.DiscardedTxMsgCount, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_connections"], prometheus.GaugeValue, vpn.Connections, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_connections_service_amqp"], prometheus.GaugeValue, vpn.ConnectionsAmqService, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_connections_service_mqtt"], prometheus.GaugeValue, vpn.ConnectionsMqttService, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_connections_service_smf"], prometheus.GaugeValue, vpn.ConnectionsSmfService, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_connections_service_web"], prometheus.GaugeValue, vpn.ConnectionsWebService, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_connections_service_rest_in"], prometheus.GaugeValue, vpn.ConnectionsRestInService, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_connections_service_rest_out"], prometheus.GaugeValue, vpn.ConnectionsRestOutService, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_quota_connections"], prometheus.GaugeValue, vpn.QuotaConnections, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_quota_connections_smf"], prometheus.GaugeValue, vpn.QuotaConnectionsSmf, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_quota_connections_web"], prometheus.GaugeValue, vpn.QuotaConnectionsWeb, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_quota_connections_amqp"], prometheus.GaugeValue, vpn.QuotaConnectionsAmqp, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_quota_connections_mqtt"], prometheus.GaugeValue, vpn.QuotaConnectionsMqtt, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_quota_connections_rest_in"], prometheus.GaugeValue, vpn.QuotaConnectionsRestIn, vpn.Name)
ch <- e.NewMetric(MetricDesc["VpnStats"]["vpn_quota_connections_rest_out"], prometheus.GaugeValue, vpn.QuotaConnectionsRestOut, vpn.Name)
}

return 1, nil
Expand Down
58 changes: 34 additions & 24 deletions semp/metricDesc.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,22 @@ var MetricDesc = map[string]Descriptions{
"system_spool_files_utilization_percent": NewSemDesc("system_spool_files_utilization_percent", NoSempV2Ready, "Utilization of spool files in percent.", nil),
"system_spool_message_count_utilization_percent": NewSemDesc("system_spool_message_count_utilization_percent", NoSempV2Ready, "Utilization of queue message resource in percent.", nil),

"system_spool_ingress_flows_quota": NewSemDesc("system_spool_ingress_flows_quota", NoSempV2Ready, "Number of maximal possible ingress flows.", nil),
"system_spool_ingress_flows_count": NewSemDesc("system_spool_ingress_flows_count", NoSempV2Ready, "Number of used ingress flows.", nil),
"system_spool_egress_flows_quota": NewSemDesc("system_spool_egress_flows_quota", NoSempV2Ready, "Number of maximal possible egress flows.", nil),
"system_spool_egress_flows_count": NewSemDesc("system_spool_egress_flows_count", NoSempV2Ready, "Number of used egress flows.", nil),
"system_spool_egress_flows_active": NewSemDesc("system_spool_egress_flows_active", NoSempV2Ready, "Number of used egress flows in state active.", nil),
"system_spool_egress_flows_inactive": NewSemDesc("system_spool_egress_flows_inactive", NoSempV2Ready, "Number of used egress flows in state inactive.", nil),
"system_spool_egress_flows_browser": NewSemDesc("system_spool_egress_flows_browser", NoSempV2Ready, "Number of used egress flows in queue browser mode.", nil),
"system_spool_endpoints_quota": NewSemDesc("system_spool_endpoints_quota", NoSempV2Ready, "Number of maximal possible queue or topic endpoints.", nil),
"system_spool_endpoints_queue": NewSemDesc("system_spool_endpoints_queue", NoSempV2Ready, "Number of existing queue endpoints.", nil),
"system_spool_endpoints_dte": NewSemDesc("system_spool_endpoints_dte", NoSempV2Ready, "Number of existing topic endpoints.", nil),
"system_spool_transacted_sessions_quota": NewSemDesc("system_spool_transacted_sessions_quota", NoSempV2Ready, "Number of maximal possible transacted sessions.", nil),
"system_spool_transacted_sessions_used": NewSemDesc("system_spool_transacted_sessions_used", NoSempV2Ready, "Number of used transacted sessions.", nil),
"system_spool_ingress_flows_quota": NewSemDesc("system_spool_ingress_flows_quota", NoSempV2Ready, "Number of maximal possible ingress flows.", nil),
"system_spool_ingress_flows_count": NewSemDesc("system_spool_ingress_flows_count", NoSempV2Ready, "Number of used ingress flows.", nil),
"system_spool_egress_flows_quota": NewSemDesc("system_spool_egress_flows_quota", NoSempV2Ready, "Number of maximal possible egress flows.", nil),
"system_spool_egress_flows_count": NewSemDesc("system_spool_egress_flows_count", NoSempV2Ready, "Number of used egress flows.", nil),
"system_spool_egress_flows_active": NewSemDesc("system_spool_egress_flows_active", NoSempV2Ready, "Number of used egress flows in state active.", nil),
"system_spool_egress_flows_inactive": NewSemDesc("system_spool_egress_flows_inactive", NoSempV2Ready, "Number of used egress flows in state inactive.", nil),
"system_spool_egress_flows_browser": NewSemDesc("system_spool_egress_flows_browser", NoSempV2Ready, "Number of used egress flows in queue browser mode.", nil),
"system_spool_endpoints_quota": NewSemDesc("system_spool_endpoints_quota", NoSempV2Ready, "Number of maximal possible queue or topic endpoints.", nil),
"system_spool_endpoints_queue": NewSemDesc("system_spool_endpoints_queue", NoSempV2Ready, "Number of existing queue endpoints.", nil),
"system_spool_endpoints_dte": NewSemDesc("system_spool_endpoints_dte", NoSempV2Ready, "Number of existing topic endpoints.", nil),
"system_spool_transacted_sessions_quota": NewSemDesc("system_spool_transacted_sessions_quota", NoSempV2Ready, "Number of maximal possible transacted sessions.", nil),
"system_spool_transacted_sessions_used": NewSemDesc("system_spool_transacted_sessions_used", NoSempV2Ready, "Number of used transacted sessions.", nil),
"system_spool_queue_topic_subscriptions_quota": NewSemDesc("system_spool_queue_topic_subscriptions_quota", NoSempV2Ready, "Number of maximal possible topic subscriptions of all queues.", nil),
"system_spool_queue_topic_subscriptions_used": NewSemDesc("system_spool_queue_topic_subscriptions_used", NoSempV2Ready, "Number of used topic subscriptions of all queues.", nil),
"system_spool_transactions_quota": NewSemDesc("system_spool_transactions_quota", NoSempV2Ready, "Number of maximal possible transactions.", nil),
"system_spool_transactions_used": NewSemDesc("system_spool_transactions_used", NoSempV2Ready, "Number of used transactions.", nil),
"system_spool_transactions_quota": NewSemDesc("system_spool_transactions_quota", NoSempV2Ready, "Number of maximal possible transactions.", nil),
"system_spool_transactions_used": NewSemDesc("system_spool_transactions_used", NoSempV2Ready, "Number of used transactions.", nil),

"system_spool_usage_adb_bytes": NewSemDesc("system_spool_usage_adb_bytes", NoSempV2Ready, "Spool total persisted usage in adb.", nil),
"system_spool_messages_currently_spooled_adb": NewSemDesc("system_spool_messages_currently_spooled_adb", NoSempV2Ready, "Messages stored in adb.", nil),
Expand Down Expand Up @@ -185,10 +185,6 @@ var MetricDesc = map[string]Descriptions{
"vpn_total_local_unique_subscriptions": NewSemDesc("vpn_total_local_unique_subscriptions", NoSempV2Ready, "Total unique local subscriptions count", variableLabelsVpn),
"vpn_total_remote_unique_subscriptions": NewSemDesc("vpn_total_remote_unique_subscriptions", NoSempV2Ready, "Total unique remote subscriptions count", variableLabelsVpn),
"vpn_total_unique_subscriptions": NewSemDesc("vpn_total_unique_subscriptions", NoSempV2Ready, "Total unique subscriptions count", variableLabelsVpn),
"vpn_connections_service_amqp": NewSemDesc("vpn_connections_service_amqp", NoSempV2Ready, "Total number of amq connections", variableLabelsVpn),
"vpn_connections_service_smf": NewSemDesc("vpn_connections_service_smf", NoSempV2Ready, "Total number of smf connections", variableLabelsVpn),
"vpn_connections": NewSemDesc("vpn_connections", NoSempV2Ready, "Number of connections.", variableLabelsVpn),
"vpn_quota_connections": NewSemDesc("vpn_quota_connections", NoSempV2Ready, "Maximum number of connections.", variableLabelsVpn),
},
"VpnReplication": {
"vpn_replication_admin_state": NewSemDesc("vpn_replication_admin_state", NoSempV2Ready, "Replication Admin Status (0-shutdown, 1-enabled, 2-n/a)", variableLabelsVpn),
Expand Down Expand Up @@ -286,12 +282,26 @@ var MetricDesc = map[string]Descriptions{
"unacked_messages": NewSemDesc("client_egress_unacked_messages", NoSempV2Ready, "Number of unacknowledged messages.", variableLabelsVpnClientFlow),
},
"VpnStats": {
"vpn_rx_msgs_total": NewSemDesc("vpn_rx_msgs_total", NoSempV2Ready, "Number of received messages.", variableLabelsVpn),
"vpn_tx_msgs_total": NewSemDesc("vpn_tx_msgs_total", NoSempV2Ready, "Number of transmitted messages.", variableLabelsVpn),
"vpn_rx_bytes_total": NewSemDesc("vpn_rx_bytes_total", NoSempV2Ready, "Number of received bytes.", variableLabelsVpn),
"vpn_tx_bytes_total": NewSemDesc("vpn_tx_bytes_total", NoSempV2Ready, "Number of transmitted bytes.", variableLabelsVpn),
"vpn_rx_discarded_msgs_total": NewSemDesc("vpn_rx_discarded_msgs_total", NoSempV2Ready, "Number of discarded received messages.", variableLabelsVpn),
"vpn_tx_discarded_msgs_total": NewSemDesc("vpn_tx_discarded_msgs_total", NoSempV2Ready, "Number of discarded transmitted messages.", variableLabelsVpn),
"vpn_rx_msgs_total": NewSemDesc("vpn_rx_msgs_total", NoSempV2Ready, "Number of received messages.", variableLabelsVpn),
"vpn_tx_msgs_total": NewSemDesc("vpn_tx_msgs_total", NoSempV2Ready, "Number of transmitted messages.", variableLabelsVpn),
"vpn_rx_bytes_total": NewSemDesc("vpn_rx_bytes_total", NoSempV2Ready, "Number of received bytes.", variableLabelsVpn),
"vpn_tx_bytes_total": NewSemDesc("vpn_tx_bytes_total", NoSempV2Ready, "Number of transmitted bytes.", variableLabelsVpn),
"vpn_rx_discarded_msgs_total": NewSemDesc("vpn_rx_discarded_msgs_total", NoSempV2Ready, "Number of discarded received messages.", variableLabelsVpn),
"vpn_tx_discarded_msgs_total": NewSemDesc("vpn_tx_discarded_msgs_total", NoSempV2Ready, "Number of discarded transmitted messages.", variableLabelsVpn),
"vpn_connections_service_amqp": NewSemDesc("vpn_connections_service_amqp", NoSempV2Ready, "Total number of amq connections", variableLabelsVpn),
"vpn_connections_service_mqtt": NewSemDesc("vpn_connections_service_mqtt", NoSempV2Ready, "Total number of mqtt connections", variableLabelsVpn),
"vpn_connections_service_smf": NewSemDesc("vpn_connections_service_smf", NoSempV2Ready, "Total number of smf connections", variableLabelsVpn),
"vpn_connections_service_web": NewSemDesc("vpn_connections_service_web", NoSempV2Ready, "Total number of smf-web connections", variableLabelsVpn),
"vpn_connections_service_rest_in": NewSemDesc("vpn_connections_service_rest_in", NoSempV2Ready, "Total number of inbound rest connections", variableLabelsVpn),
"vpn_connections_service_rest_out": NewSemDesc("vpn_connections_service_rest_out", NoSempV2Ready, "Total number of outbound rest connections", variableLabelsVpn),
"vpn_connections": NewSemDesc("vpn_connections", NoSempV2Ready, "Number of connections.", variableLabelsVpn),
"vpn_quota_connections": NewSemDesc("vpn_quota_connections", NoSempV2Ready, "Maximum number of connections.", variableLabelsVpn),
"vpn_quota_connections_amqp": NewSemDesc("vpn_quota_connections_amqp", NoSempV2Ready, "Maximum number of amqp connections.", variableLabelsVpn),
"vpn_quota_connections_smf": NewSemDesc("vpn_quota_connections_smf", NoSempV2Ready, "Maximum number of smf connections.", variableLabelsVpn),
"vpn_quota_connections_web": NewSemDesc("vpn_quota_connections_web", NoSempV2Ready, "Maximum number of smf-web connections.", variableLabelsVpn),
"vpn_quota_connections_mqtt": NewSemDesc("vpn_quota_connections_mqtt", NoSempV2Ready, "Maximum number of mqtt connections.", variableLabelsVpn),
"vpn_quota_connections_rest_in": NewSemDesc("vpn_quota_connections_rest_in", NoSempV2Ready, "Maximum number of inbound rest connections.", variableLabelsVpn),
"vpn_quota_connections_rest_out": NewSemDesc("vpn_quota_connections_rest_out", NoSempV2Ready, "Maximum number of outbound rest connections.", variableLabelsVpn),
},
"BridgeStats": {
"bridge_client_num_subscriptions": NewSemDesc("bridge_client_num_subscriptions", NoSempV2Ready, "Bridge Client Subscription", variableLabelsBridgeStats),
Expand Down

0 comments on commit 1ff44e0

Please sign in to comment.