- Timestamp:
- Oct 5, 2021, 5:13:53 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/soju.1.scd
r577 r605 321 321 Delete a soju user. Only admins can delete accounts. 322 322 323 *server status* 324 Show some bouncer statistics. Only admins can query this information. 325 323 326 # AUTHORS 324 327 -
trunk/server.go
r601 r605 56 56 Identd *Identd // can be nil 57 57 58 db Database 59 stopWG sync.WaitGroup 58 db Database 59 stopWG sync.WaitGroup 60 connCount int64 // atomic 60 61 61 62 lock sync.Mutex … … 166 167 167 168 func (s *Server) handle(ic ircConn) { 169 atomic.AddInt64(&s.connCount, 1) 168 170 id := atomic.AddUint64(&lastDownstreamID, 1) 169 171 dc := newDownstreamConn(s, ic, id) … … 178 180 } 179 181 dc.Close() 182 atomic.AddInt64(&s.connCount, -1) 180 183 } 181 184 … … 250 253 return params 251 254 } 255 256 type ServerStats struct { 257 Users int 258 Downstreams int64 259 } 260 261 func (s *Server) Stats() *ServerStats { 262 var stats ServerStats 263 s.lock.Lock() 264 stats.Users = len(s.users) 265 s.lock.Unlock() 266 stats.Downstreams = atomic.LoadInt64(&s.connCount) 267 return &stats 268 } -
trunk/service.go
r577 r605 293 293 }, 294 294 }, 295 "server": { 296 children: serviceCommandSet{ 297 "status": { 298 desc: "show server statistics", 299 handle: handleServiceServerStatus, 300 admin: true, 301 }, 302 }, 303 admin: true, 304 }, 295 305 } 296 306 } … … 1008 1018 return nil 1009 1019 } 1020 1021 func handleServiceServerStatus(dc *downstreamConn, params []string) error { 1022 stats := dc.user.srv.Stats() 1023 sendServicePRIVMSG(dc, fmt.Sprintf("%v users, %v downstreams", stats.Users, stats.Downstreams)) 1024 return nil 1025 }
Note:
See TracChangeset
for help on using the changeset viewer.