added the rpx_sessions counter
This commit is contained in:
@ -111,6 +111,7 @@ type json_out_client_stats struct {
|
||||
ClientPeers int64 `json:"client-peers"`
|
||||
ClientPtySessions int64 `json:"client-pty-sessions"`
|
||||
ClientRptySessions int64 `json:"client-rpty-sessions"`
|
||||
ClientRpxSessions int64 `json:"client-rpx-sessions"`
|
||||
}
|
||||
// ------------------------------------
|
||||
|
||||
@ -1140,6 +1141,7 @@ func (ctl *client_ctl_stats) ServeHTTP(w http.ResponseWriter, req *http.Request)
|
||||
stats.ClientPeers = c.stats.peers.Load()
|
||||
stats.ClientPtySessions = c.stats.pty_sessions.Load()
|
||||
stats.ClientRptySessions = c.stats.rpty_sessions.Load()
|
||||
stats.ClientRpxSessions = c.stats.rpx_sessions.Load()
|
||||
status_code = WriteJsonRespHeader(w, http.StatusOK)
|
||||
if err = je.Encode(stats); err != nil { goto oops }
|
||||
|
||||
|
@ -12,6 +12,7 @@ type ClientCollector struct {
|
||||
ClientPeers *prometheus.Desc
|
||||
PtySessions *prometheus.Desc
|
||||
RptySessions *prometheus.Desc
|
||||
RpxSessions *prometheus.Desc
|
||||
}
|
||||
|
||||
// NewClientCollector returns a new ClientCollector with all prometheus.Desc initialized
|
||||
@ -58,6 +59,11 @@ func NewClientCollector(client *Client) ClientCollector {
|
||||
"Number of rpty sessions",
|
||||
nil, nil,
|
||||
),
|
||||
RpxSessions: prometheus.NewDesc(
|
||||
prefix + "rpx_sessions",
|
||||
"Number of rpx sessions",
|
||||
nil, nil,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,6 +74,7 @@ func (c ClientCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||
ch <- c.ClientPeers
|
||||
ch <- c.PtySessions
|
||||
ch <- c.RptySessions
|
||||
ch <- c.RpxSessions
|
||||
}
|
||||
|
||||
func (c ClientCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
@ -110,4 +117,10 @@ func (c ClientCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
prometheus.GaugeValue,
|
||||
float64(c.client.stats.rpty_sessions.Load()),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.RpxSessions,
|
||||
prometheus.GaugeValue,
|
||||
float64(c.client.stats.rpx_sessions.Load()),
|
||||
)
|
||||
}
|
||||
|
@ -167,6 +167,7 @@ type Client struct {
|
||||
peers atomic.Int64
|
||||
pty_sessions atomic.Int64
|
||||
rpty_sessions atomic.Int64
|
||||
rpx_sessions atomic.Int64
|
||||
}
|
||||
|
||||
pty_user string
|
||||
@ -1892,6 +1893,7 @@ done:
|
||||
cts.rpx_mtx.Lock()
|
||||
delete(cts.rpx_map, crpx.id)
|
||||
cts.rpx_mtx.Unlock()
|
||||
cts.C.stats.rpx_sessions.Add(-1)
|
||||
}
|
||||
|
||||
func (cts *ClientConn) StartRpx(id uint64, data []byte, wg *sync.WaitGroup) error {
|
||||
@ -1914,6 +1916,7 @@ func (cts *ClientConn) StartRpx(id uint64, data []byte, wg *sync.WaitGroup) erro
|
||||
crpx.ctx, crpx.cancel = context.WithCancel(cts.C.Ctx)
|
||||
|
||||
cts.rpx_mtx.Unlock()
|
||||
cts.C.stats.rpx_sessions.Add(1)
|
||||
|
||||
wg.Add(1)
|
||||
go cts.RpxLoop(crpx, data, wg)
|
||||
@ -2262,6 +2265,7 @@ func NewClient(ctx context.Context, name string, logger Logger, cfg *ClientConfi
|
||||
c.stats.peers.Store(0)
|
||||
c.stats.pty_sessions.Store(0)
|
||||
c.stats.rpty_sessions.Store(0)
|
||||
c.stats.rpx_sessions.Store(0)
|
||||
|
||||
return &c
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ type json_out_server_stats struct {
|
||||
SshProxySessions int64 `json:"pxy-ssh-sessions"`
|
||||
ServerPtySessions int64 `json:"server-pty-sessions"`
|
||||
ServerRptySessions int64 `json:"server-rpty-sessions"`
|
||||
ServerRpxSessions int64 `json:"server-rpx-sessions"`
|
||||
}
|
||||
|
||||
// this is a more specialized variant of json_in_notice
|
||||
@ -923,6 +924,7 @@ func (ctl *server_ctl_stats) ServeHTTP(w http.ResponseWriter, req *http.Request)
|
||||
stats.SshProxySessions = s.stats.ssh_proxy_sessions.Load()
|
||||
stats.ServerPtySessions = s.stats.pty_sessions.Load()
|
||||
stats.ServerRptySessions = s.stats.rpty_sessions.Load()
|
||||
stats.ServerRpxSessions = s.stats.rpx_sessions.Load()
|
||||
status_code = WriteJsonRespHeader(w, http.StatusOK)
|
||||
if err = je.Encode(stats); err != nil { goto oops }
|
||||
|
||||
|
@ -13,6 +13,7 @@ type ServerCollector struct {
|
||||
SshProxySessions *prometheus.Desc
|
||||
PtySessions *prometheus.Desc
|
||||
RptySessions *prometheus.Desc
|
||||
RpxSessions *prometheus.Desc
|
||||
}
|
||||
|
||||
// NewServerCollector returns a new ServerCollector with all prometheus.Desc initialized
|
||||
@ -64,6 +65,11 @@ func NewServerCollector(server *Server) ServerCollector {
|
||||
"Number of rpty session",
|
||||
nil, nil,
|
||||
),
|
||||
RpxSessions: prometheus.NewDesc(
|
||||
prefix + "rpx_sessions",
|
||||
"Number of rpx session",
|
||||
nil, nil,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,6 +81,7 @@ func (c ServerCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||
ch <- c.SshProxySessions
|
||||
ch <- c.PtySessions
|
||||
ch <- c.RptySessions
|
||||
ch <- c.RpxSessions
|
||||
}
|
||||
|
||||
func (c ServerCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
@ -123,4 +130,10 @@ func (c ServerCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
prometheus.GaugeValue,
|
||||
float64(c.server.stats.rpty_sessions.Load()),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.RpxSessions,
|
||||
prometheus.GaugeValue,
|
||||
float64(c.server.stats.rpx_sessions.Load()),
|
||||
)
|
||||
}
|
||||
|
@ -211,6 +211,7 @@ func (rpx *server_rpx) alloc_server_rpx(cts *ServerConn, req *http.Request) (*Se
|
||||
cts.rpx_map[assigned_id] = srpx
|
||||
|
||||
cts.rpx_mtx.Unlock()
|
||||
cts.S.stats.rpx_sessions.Add(1)
|
||||
return srpx, nil
|
||||
}
|
||||
|
||||
@ -247,6 +248,7 @@ func (rpx *server_rpx) ServeHTTP(w http.ResponseWriter, req *http.Request) (int,
|
||||
cts.rpx_mtx.Lock()
|
||||
delete(cts.rpx_map, srpx.id)
|
||||
cts.rpx_mtx.Unlock()
|
||||
cts.S.stats.rpx_sessions.Add(-1)
|
||||
}()
|
||||
|
||||
ws_upgrade = strings.EqualFold(req.Header.Get("Upgrade"), "websocket") && strings.Contains(strings.ToLower(req.Header.Get("Connection")), "upgrade");
|
||||
|
@ -172,6 +172,7 @@ type Server struct {
|
||||
ssh_proxy_sessions atomic.Int64
|
||||
pty_sessions atomic.Int64
|
||||
rpty_sessions atomic.Int64
|
||||
rpx_sessions atomic.Int64
|
||||
}
|
||||
|
||||
wpx_resp_tf ServerWpxResponseTransformer
|
||||
@ -1902,6 +1903,7 @@ func NewServer(ctx context.Context, name string, logger Logger, cfg *ServerConfi
|
||||
s.stats.ssh_proxy_sessions.Store(0)
|
||||
s.stats.pty_sessions.Store(0)
|
||||
s.stats.rpty_sessions.Store(0)
|
||||
s.stats.rpx_sessions.Store(0)
|
||||
|
||||
return &s, nil
|
||||
|
||||
|
Reference in New Issue
Block a user