* 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
ThreadPoolClientBranch
Justin Clarke Casey 2008-01-28 22:00:38 +00:00
parent fa5fe6b7f6
commit beefbb46d2
8 changed files with 69 additions and 16 deletions

View File

@ -34,6 +34,7 @@ using libsecondlife;
using libsecondlife.StructuredData; using libsecondlife.StructuredData;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Statistics;
namespace OpenSim.Framework.UserManagement namespace OpenSim.Framework.UserManagement
{ {
@ -44,6 +45,17 @@ namespace OpenSim.Framework.UserManagement
{ {
public UserConfig _config; public UserConfig _config;
private Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>(); private Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>();
protected UserStatsReporter _stats;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="statsCollector">Can be null if stats collection is not required.
/// </param>
public UserManagerBase(UserStatsReporter statsCollector)
{
_stats = statsCollector;
}
/// <summary> /// <summary>
/// Adds a new user server plugin - user servers will be requested in the order they were loaded. /// 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; profile.currentAgent = agent;
} }
/// <summary>
/// Process a user logoff from OpenSim.
/// </summary>
/// <param name="userid"></param>
/// <param name="regionid"></param>
/// <param name="regionhandle"></param>
/// <param name="posx"></param>
/// <param name="posy"></param>
/// <param name="posz"></param>
public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz) public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz)
{ {
if (_stats != null)
_stats.AddLogout();
UserProfileData userProfile; UserProfileData userProfile;
UserAgentData userAgent; UserAgentData userAgent;
LLVector3 currentPos = new LLVector3(posx, posy, posz); LLVector3 currentPos = new LLVector3(posx, posy, posz);
@ -450,6 +475,7 @@ namespace OpenSim.Framework.UserManagement
MainLog.Instance.Warn("LOGOUT", "Unknown User logged out"); MainLog.Instance.Warn("LOGOUT", "Unknown User logged out");
} }
} }
public void CreateAgent(UserProfileData profile, LLSD request) public void CreateAgent(UserProfileData profile, LLSD request)
{ {
UserAgentData agent = new UserAgentData(); UserAgentData agent = new UserAgentData();

View File

@ -44,6 +44,12 @@ namespace OpenSim.Framework.Statistics
private int successfulLoginsYesterday; 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() public UserStatsReporter()
{ {
ageStatsTimer.Elapsed += new ElapsedEventHandler(OnAgeing); ageStatsTimer.Elapsed += new ElapsedEventHandler(OnAgeing);
@ -64,9 +70,15 @@ namespace OpenSim.Framework.Statistics
/// </summary> /// </summary>
public void AddSuccessfulLogin() public void AddSuccessfulLogin()
{ {
successfulLogins++;
successfulLoginsToday++; successfulLoginsToday++;
} }
public void AddLogout()
{
logouts++;
}
/// <summary> /// <summary>
/// Report back collected statistical information. /// Report back collected statistical information.
/// </summary> /// </summary>
@ -74,9 +86,9 @@ namespace OpenSim.Framework.Statistics
public string Report() public string Report()
{ {
return string.Format( return string.Format(
@"Successful logins today : {0} @"Successful logins total : {0}, today : {1}, yesterday : {2}
Successful logins yesterday : {1}", Logouts total : {3}",
SuccessfulLoginsToday, SuccessfulLoginsYesterday); SuccessfulLogins, SuccessfulLoginsToday, SuccessfulLoginsYesterday, Logouts);
} }
} }
} }

View File

@ -44,7 +44,6 @@ namespace OpenSim.Grid.UserServer
{ {
private UserConfig Cfg; private UserConfig Cfg;
public UserManager m_userManager; public UserManager m_userManager;
public UserLoginService m_loginService; public UserLoginService m_loginService;
public MessageServersConnector m_messagesService; public MessageServersConnector m_messagesService;
@ -90,13 +89,13 @@ namespace OpenSim.Grid.UserServer
{ {
Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
m_stats = new UserStatsReporter();
MainLog.Instance.Verbose("REGION", "Establishing data connection"); MainLog.Instance.Verbose("REGION", "Establishing data connection");
m_userManager = new UserManager(); m_userManager = new UserManager(m_stats);
m_userManager._config = Cfg; m_userManager._config = Cfg;
m_userManager.AddPlugin(Cfg.DatabaseProvider); m_userManager.AddPlugin(Cfg.DatabaseProvider);
m_stats = new UserStatsReporter();
m_loginService = new UserLoginService( m_loginService = new UserLoginService(
m_userManager, new LibraryRootFolder(), m_stats, Cfg, Cfg.DefaultStartupMsg); m_userManager, new LibraryRootFolder(), m_stats, Cfg, Cfg.DefaultStartupMsg);

View File

@ -32,17 +32,22 @@ using System.Text.RegularExpressions;
using libsecondlife; using libsecondlife;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Statistics;
using OpenSim.Framework.UserManagement; using OpenSim.Framework.UserManagement;
namespace OpenSim.Grid.UserServer namespace OpenSim.Grid.UserServer
{ {
public class UserManager : UserManagerBase public class UserManager : UserManagerBase
{ {
public UserManager() /// <summary>
/// Constructor.
/// </summary>
/// <param name="statsCollector">Can be null if stats collection is not required.
/// </param>
public UserManager(UserStatsReporter statsCollector) : base(statsCollector)
{ {
} }
/// <summary> /// <summary>
/// Deletes an active agent session /// Deletes an active agent session
/// </summary> /// </summary>

View File

@ -317,7 +317,7 @@ namespace OpenSim
LocalUserServices userService = LocalUserServices userService =
new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX,
m_networkServersInfo.DefaultHomeLocY, inventoryService); m_networkServersInfo.DefaultHomeLocY, inventoryService, null);
userService.AddPlugin(m_standaloneUserPlugin); userService.AddPlugin(m_standaloneUserPlugin);
LocalBackEndServices backendService = new LocalBackEndServices(); LocalBackEndServices backendService = new LocalBackEndServices();

View File

@ -30,6 +30,7 @@ using System;
using libsecondlife; using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Statistics;
using OpenSim.Framework.UserManagement; using OpenSim.Framework.UserManagement;
namespace OpenSim.Region.Communications.Local namespace OpenSim.Region.Communications.Local
@ -42,8 +43,17 @@ namespace OpenSim.Region.Communications.Local
private IInventoryServices m_inventoryService; private IInventoryServices m_inventoryService;
/// <summary>
///
/// </summary>
/// <param name="serversInfo"></param>
/// <param name="defaultHomeLocX"></param>
/// <param name="defaultHomeLocY"></param>
/// <param name="inventoryService"></param>
/// <param name="statsCollector">Can be null if stats collection is not required.</param>
public LocalUserServices(NetworkServersInfo serversInfo, uint defaultHomeLocX, uint defaultHomeLocY, public LocalUserServices(NetworkServersInfo serversInfo, uint defaultHomeLocX, uint defaultHomeLocY,
IInventoryServices inventoryService) IInventoryServices inventoryService, UserStatsReporter statsCollector)
: base(statsCollector)
{ {
m_serversInfo = serversInfo; m_serversInfo = serversInfo;

View File

@ -77,7 +77,7 @@ namespace SimpleApp
LocalUserServices userService = LocalUserServices userService =
new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX,
m_networkServersInfo.DefaultHomeLocY, inventoryService); m_networkServersInfo.DefaultHomeLocY, inventoryService, null);
userService.AddPlugin(m_userPlugin); userService.AddPlugin(m_userPlugin);
LocalBackEndServices backendService = new LocalBackEndServices(); LocalBackEndServices backendService = new LocalBackEndServices();

View File

@ -1363,6 +1363,7 @@
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Data"/> <Reference name="OpenSim.Framework.Data"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Region.Physics.Manager"/> <Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Framework.Servers"/> <Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Region.Environment"/> <Reference name="OpenSim.Region.Environment"/>