@@ -21,8 +21,35 @@ type sshServerMetrics struct {
21
21
// X11
22
22
x11SocketDirError prometheus.Counter
23
23
x11XauthorityError prometheus.Counter
24
+
25
+ sessions sessionMetrics
24
26
}
25
27
28
+ type sessionMetricsObject struct {
29
+ // Agent sessions
30
+ agentCreateCommandError prometheus.Counter
31
+ agentListenerError prometheus.Counter
32
+ startPTYSession prometheus.Counter
33
+ startNonPTYSession prometheus.Counter
34
+ sessionError prometheus.Counter
35
+
36
+ // Non-PTY sessions
37
+ nonPTYStdinPipeError prometheus.Counter
38
+ nonPTYStdinIoCopyError prometheus.Counter
39
+ nonPTYCmdStartError prometheus.Counter
40
+
41
+ // PTY sessions
42
+ ptyMotdError prometheus.Counter
43
+ ptyCmdStartError prometheus.Counter
44
+ ptyCloseError prometheus.Counter
45
+ ptyResizeError prometheus.Counter
46
+ ptyInputIoCopyError prometheus.Counter
47
+ ptyOutputIoCopyError prometheus.Counter
48
+ ptyWaitError prometheus.Counter
49
+ }
50
+
51
+ type sessionMetrics map [string ]sessionMetricsObject
52
+
26
53
func newSSHServerMetrics (registerer prometheus.Registerer ) * sshServerMetrics {
27
54
connectionFailedCallback := prometheus .NewCounter (prometheus.CounterOpts {
28
55
Namespace : "agent" , Subsystem : "ssh_server" , Name : "connection_failed_callback" ,
@@ -69,6 +96,8 @@ func newSSHServerMetrics(registerer prometheus.Registerer) *sshServerMetrics {
69
96
})
70
97
registerer .MustRegister (x11XauthorityError )
71
98
99
+ sessions := newSessionMetrics (registerer )
100
+
72
101
return & sshServerMetrics {
73
102
connectionFailedCallback : connectionFailedCallback ,
74
103
localPortForwardingCallback : localPortForwardingCallback ,
@@ -79,34 +108,11 @@ func newSSHServerMetrics(registerer prometheus.Registerer) *sshServerMetrics {
79
108
sftpServerError : sftpServerError ,
80
109
x11SocketDirError : x11SocketDirError ,
81
110
x11XauthorityError : x11XauthorityError ,
82
- }
83
- }
84
-
85
- type sessionMetricsObject struct {
86
- // Agent sessions
87
- agentCreateCommandError prometheus.Counter
88
- agentListenerError prometheus.Counter
89
- startPTYSession prometheus.Counter
90
- startNonPTYSession prometheus.Counter
91
- sessionError prometheus.Counter
92
-
93
- // Non-PTY sessions
94
- nonPTYStdinPipeError prometheus.Counter
95
- nonPTYStdinIoCopyError prometheus.Counter
96
- nonPTYCmdStartError prometheus.Counter
97
111
98
- // PTY sessions
99
- ptyMotdError prometheus.Counter
100
- ptyCmdStartError prometheus.Counter
101
- ptyCloseError prometheus.Counter
102
- ptyResizeError prometheus.Counter
103
- ptyInputIoCopyError prometheus.Counter
104
- ptyOutputIoCopyError prometheus.Counter
105
- ptyWaitError prometheus.Counter
112
+ sessions : sessions ,
113
+ }
106
114
}
107
115
108
- type sessionMetrics map [string ]sessionMetricsObject
109
-
110
116
func newSessionMetrics (registerer prometheus.Registerer ) sessionMetrics {
111
117
sm := sessionMetrics {}
112
118
for _ , magicType := range []string {MagicSessionTypeVSCode , MagicSessionTypeJetBrains , "ssh" , "unknown" } {
0 commit comments