Add number of upstream connections to metrics
This commit is contained in:
parent
7fa8c78122
commit
efc4c62725
@ -100,6 +100,7 @@ type Server struct {
|
|||||||
|
|
||||||
metrics struct {
|
metrics struct {
|
||||||
downstreams int64Gauge
|
downstreams int64Gauge
|
||||||
|
upstreams int64Gauge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +165,11 @@ func (s *Server) registerMetrics() {
|
|||||||
Name: "soju_downstreams_active",
|
Name: "soju_downstreams_active",
|
||||||
Help: "Current number of downstream connections",
|
Help: "Current number of downstream connections",
|
||||||
}, s.metrics.downstreams.Float64)
|
}, s.metrics.downstreams.Float64)
|
||||||
|
|
||||||
|
factory.NewGaugeFunc(prometheus.GaugeOpts{
|
||||||
|
Name: "soju_upstreams_active",
|
||||||
|
Help: "Current number of upstream connections",
|
||||||
|
}, s.metrics.upstreams.Float64)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Shutdown() {
|
func (s *Server) Shutdown() {
|
||||||
@ -343,6 +349,7 @@ func parseForwarded(h http.Header) map[string]string {
|
|||||||
type ServerStats struct {
|
type ServerStats struct {
|
||||||
Users int
|
Users int
|
||||||
Downstreams int64
|
Downstreams int64
|
||||||
|
Upstreams int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Stats() *ServerStats {
|
func (s *Server) Stats() *ServerStats {
|
||||||
@ -351,5 +358,6 @@ func (s *Server) Stats() *ServerStats {
|
|||||||
stats.Users = len(s.users)
|
stats.Users = len(s.users)
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
stats.Downstreams = s.metrics.downstreams.Value()
|
stats.Downstreams = s.metrics.downstreams.Value()
|
||||||
|
stats.Upstreams = s.metrics.upstreams.Value()
|
||||||
return &stats
|
return &stats
|
||||||
}
|
}
|
||||||
|
@ -1035,7 +1035,7 @@ func handleServiceServerStatus(ctx context.Context, dc *downstreamConn, params [
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
serverStats := dc.user.srv.Stats()
|
serverStats := dc.user.srv.Stats()
|
||||||
sendServicePRIVMSG(dc, fmt.Sprintf("%v/%v users, %v downstreams, %v networks, %v channels", serverStats.Users, dbStats.Users, serverStats.Downstreams, dbStats.Networks, dbStats.Channels))
|
sendServicePRIVMSG(dc, fmt.Sprintf("%v/%v users, %v downstreams, %v upstreams, %v networks, %v channels", serverStats.Users, dbStats.Users, serverStats.Downstreams, serverStats.Upstreams, dbStats.Networks, dbStats.Channels))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
user.go
4
user.go
@ -213,6 +213,8 @@ func (net *network) run() {
|
|||||||
net.user.srv.Identd.Store(uc.RemoteAddr().String(), uc.LocalAddr().String(), userIdent(&net.user.User))
|
net.user.srv.Identd.Store(uc.RemoteAddr().String(), uc.LocalAddr().String(), userIdent(&net.user.User))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net.user.srv.metrics.upstreams.Add(1)
|
||||||
|
|
||||||
uc.register()
|
uc.register()
|
||||||
if err := uc.runUntilRegistered(); err != nil {
|
if err := uc.runUntilRegistered(); err != nil {
|
||||||
text := err.Error()
|
text := err.Error()
|
||||||
@ -239,6 +241,8 @@ func (net *network) run() {
|
|||||||
if net.user.srv.Identd != nil {
|
if net.user.srv.Identd != nil {
|
||||||
net.user.srv.Identd.Delete(uc.RemoteAddr().String(), uc.LocalAddr().String())
|
net.user.srv.Identd.Delete(uc.RemoteAddr().String(), uc.LocalAddr().String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net.user.srv.metrics.upstreams.Add(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user