From beefbb46d22d318d1964af16b3e4601e7e23709f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 28 Jan 2008 22:00:38 +0000 Subject: [PATCH] * Add total logouts (and total logins) to server side user stats * Passing the stats collector through object chains is not ideal - this will change when more stats come in * This change will need a prebuild --- .../Communications/UserManagerBase.cs | 26 +++++++++++++++++++ .../Framework/Statistics/UserStatsReporter.cs | 20 +++++++++++--- OpenSim/Grid/UserServer/Main.cs | 9 +++---- OpenSim/Grid/UserServer/UserManager.cs | 13 +++++++--- OpenSim/Region/Application/OpenSimMain.cs | 2 +- .../Communications/Local/LocalUserServices.cs | 12 ++++++++- OpenSim/Region/Examples/SimpleApp/Program.cs | 2 +- prebuild.xml | 1 + 8 files changed, 69 insertions(+), 16 deletions(-) diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 7e1047f021..4967cd988c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -34,6 +34,7 @@ using libsecondlife; using libsecondlife.StructuredData; using Nwc.XmlRpc; using OpenSim.Framework.Console; +using OpenSim.Framework.Statistics; namespace OpenSim.Framework.UserManagement { @@ -44,7 +45,18 @@ namespace OpenSim.Framework.UserManagement { public UserConfig _config; private Dictionary _plugins = new Dictionary(); + protected UserStatsReporter _stats; + /// + /// Constructor. + /// + /// Can be null if stats collection is not required. + /// + public UserManagerBase(UserStatsReporter statsCollector) + { + _stats = statsCollector; + } + /// /// Adds a new user server plugin - user servers will be requested in the order they were loaded. /// @@ -411,8 +423,21 @@ namespace OpenSim.Framework.UserManagement profile.currentAgent = agent; } + + /// + /// Process a user logoff from OpenSim. + /// + /// + /// + /// + /// + /// + /// public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz) { + if (_stats != null) + _stats.AddLogout(); + UserProfileData userProfile; UserAgentData userAgent; LLVector3 currentPos = new LLVector3(posx, posy, posz); @@ -450,6 +475,7 @@ namespace OpenSim.Framework.UserManagement MainLog.Instance.Warn("LOGOUT", "Unknown User logged out"); } } + public void CreateAgent(UserProfileData profile, LLSD request) { UserAgentData agent = new UserAgentData(); diff --git a/OpenSim/Framework/Statistics/UserStatsReporter.cs b/OpenSim/Framework/Statistics/UserStatsReporter.cs index 9b3a13fccd..bd4f95b418 100644 --- a/OpenSim/Framework/Statistics/UserStatsReporter.cs +++ b/OpenSim/Framework/Statistics/UserStatsReporter.cs @@ -42,7 +42,13 @@ namespace OpenSim.Framework.Statistics public int SuccessfulLoginsToday { get { return successfulLoginsToday; } } private int successfulLoginsYesterday; - public int SuccessfulLoginsYesterday { get { return successfulLoginsYesterday; } } + public int SuccessfulLoginsYesterday { get { return successfulLoginsYesterday; } } + + private int successfulLogins; + public int SuccessfulLogins { get { return successfulLogins; } } + + private int logouts; + public int Logouts { get { return logouts; } } public UserStatsReporter() { @@ -64,8 +70,14 @@ namespace OpenSim.Framework.Statistics /// public void AddSuccessfulLogin() { + successfulLogins++; successfulLoginsToday++; } + + public void AddLogout() + { + logouts++; + } /// /// Report back collected statistical information. @@ -74,9 +86,9 @@ namespace OpenSim.Framework.Statistics public string Report() { return string.Format( -@"Successful logins today : {0} -Successful logins yesterday : {1}", - SuccessfulLoginsToday, SuccessfulLoginsYesterday); +@"Successful logins total : {0}, today : {1}, yesterday : {2} + Logouts total : {3}", + SuccessfulLogins, SuccessfulLoginsToday, SuccessfulLoginsYesterday, Logouts); } } } diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 1ae4bee4a5..265069439b 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -44,7 +44,6 @@ namespace OpenSim.Grid.UserServer { private UserConfig Cfg; - public UserManager m_userManager; public UserLoginService m_loginService; public MessageServersConnector m_messagesService; @@ -89,13 +88,13 @@ namespace OpenSim.Grid.UserServer public void Startup() { Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); + + m_stats = new UserStatsReporter(); MainLog.Instance.Verbose("REGION", "Establishing data connection"); - m_userManager = new UserManager(); + m_userManager = new UserManager(m_stats); m_userManager._config = Cfg; - m_userManager.AddPlugin(Cfg.DatabaseProvider); - - m_stats = new UserStatsReporter(); + m_userManager.AddPlugin(Cfg.DatabaseProvider); m_loginService = new UserLoginService( m_userManager, new LibraryRootFolder(), m_stats, Cfg, Cfg.DefaultStartupMsg); diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 3f2aa5b91a..778aec15e9 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -32,16 +32,21 @@ using System.Text.RegularExpressions; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework; +using OpenSim.Framework.Statistics; using OpenSim.Framework.UserManagement; namespace OpenSim.Grid.UserServer { public class UserManager : UserManagerBase - { - public UserManager() + { + /// + /// Constructor. + /// + /// Can be null if stats collection is not required. + /// + public UserManager(UserStatsReporter statsCollector) : base(statsCollector) { - } - + } /// /// Deletes an active agent session diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 9484e15d68..a620bd4f35 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -317,7 +317,7 @@ namespace OpenSim LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, - m_networkServersInfo.DefaultHomeLocY, inventoryService); + m_networkServersInfo.DefaultHomeLocY, inventoryService, null); userService.AddPlugin(m_standaloneUserPlugin); LocalBackEndServices backendService = new LocalBackEndServices(); diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs index e02a6009ad..8a4d4e7a48 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs @@ -30,6 +30,7 @@ using System; using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.Statistics; using OpenSim.Framework.UserManagement; namespace OpenSim.Region.Communications.Local @@ -42,8 +43,17 @@ namespace OpenSim.Region.Communications.Local private IInventoryServices m_inventoryService; + /// + /// + /// + /// + /// + /// + /// + /// Can be null if stats collection is not required. public LocalUserServices(NetworkServersInfo serversInfo, uint defaultHomeLocX, uint defaultHomeLocY, - IInventoryServices inventoryService) + IInventoryServices inventoryService, UserStatsReporter statsCollector) + : base(statsCollector) { m_serversInfo = serversInfo; diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 485d6578bc..ff29b11140 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -77,7 +77,7 @@ namespace SimpleApp LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, - m_networkServersInfo.DefaultHomeLocY, inventoryService); + m_networkServersInfo.DefaultHomeLocY, inventoryService, null); userService.AddPlugin(m_userPlugin); LocalBackEndServices backendService = new LocalBackEndServices(); diff --git a/prebuild.xml b/prebuild.xml index f0004551da..4201b9648e 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1363,6 +1363,7 @@ +