diff options
author | Corey Hulen <corey@hulen.com> | 2016-11-28 07:40:02 -0800 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-11-28 10:40:02 -0500 |
commit | 0383c58d01c3f67552e2a3f018e4667206a0363c (patch) | |
tree | 85e607e96837bb8f45b3818fab2e1ccfb8f5bb2f /api/admin.go | |
parent | be0ae364223efb1c32a8a1815583663071f255c5 (diff) | |
download | chat-0383c58d01c3f67552e2a3f018e4667206a0363c.tar.gz chat-0383c58d01c3f67552e2a3f018e4667206a0363c.tar.bz2 chat-0383c58d01c3f67552e2a3f018e4667206a0363c.zip |
PLT-4357 Adding stats to HA (#4638)
* PLT-4357 adding stats to HA
* PLT-4357 adding stats to HA
* Fixing getting stats from the current server
Diffstat (limited to 'api/admin.go')
-rw-r--r-- | api/admin.go | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/api/admin.go b/api/admin.go index 16ec98fcf..d371d2515 100644 --- a/api/admin.go +++ b/api/admin.go @@ -399,9 +399,33 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) { rows[4].Value = float64(r.Data.(int64)) } - rows[5].Value = float64(TotalWebsocketConnections()) - rows[6].Value = float64(Srv.Store.TotalMasterDbConnections()) - rows[7].Value = float64(Srv.Store.TotalReadDbConnections()) + // If in HA mode then aggregrate all the stats + if einterfaces.GetClusterInterface() != nil && *utils.Cfg.ClusterSettings.Enable { + stats, err := einterfaces.GetClusterInterface().GetClusterStats() + if err != nil { + c.Err = err + return + } + + totalSockets := TotalWebsocketConnections() + totalMasterDb := Srv.Store.TotalMasterDbConnections() + totalReadDb := Srv.Store.TotalReadDbConnections() + + for _, stat := range stats { + totalSockets = totalSockets + stat.TotalWebsocketConnections + totalMasterDb = totalMasterDb + stat.TotalMasterDbConnections + totalReadDb = totalReadDb + stat.TotalReadDbConnections + } + + rows[5].Value = float64(totalSockets) + rows[6].Value = float64(totalMasterDb) + rows[7].Value = float64(totalReadDb) + + } else { + rows[5].Value = float64(TotalWebsocketConnections()) + rows[6].Value = float64(Srv.Store.TotalMasterDbConnections()) + rows[7].Value = float64(Srv.Store.TotalReadDbConnections()) + } w.Write([]byte(rows.ToJson())) } else if name == "post_counts_day" { |