* Resolve a few bugs in the Stats Collector
** Update limiter logic reversed * Resolve a few bugs in the Viewer Stats collector ** Catch the logoff ViewerStats post (darn those caps deregistrations) ** Check the type of the correct map when checking * Resolve a leak in Prototype_distributor ** .Close, .Dispose()!0.6.2-post-fixes
parent
c6294efdbb
commit
0cd0a9bdb1
|
@ -46,6 +46,8 @@ namespace OpenSim.Region.UserStatistics
|
||||||
{
|
{
|
||||||
StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/prototype.js", FileMode.Open));
|
StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/prototype.js", FileMode.Open));
|
||||||
prototypejs = fs.ReadToEnd();
|
prototypejs = fs.ReadToEnd();
|
||||||
|
fs.Close();
|
||||||
|
fs.Dispose();
|
||||||
}
|
}
|
||||||
pResult["js"] = prototypejs;
|
pResult["js"] = prototypejs;
|
||||||
return pResult;
|
return pResult;
|
||||||
|
|
|
@ -114,6 +114,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
reports.Add("activelogajax.ajax", ajLogLines);
|
reports.Add("activelogajax.ajax", ajLogLines);
|
||||||
|
|
||||||
scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest);
|
scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest);
|
||||||
|
scene.CommsManager.HttpServer.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -135,7 +136,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
{
|
{
|
||||||
// Ignore the update if there's a report running right now
|
// Ignore the update if there's a report running right now
|
||||||
// ignore the update if there hasn't been a hit in 30 seconds.
|
// ignore the update if there hasn't been a hit in 30 seconds.
|
||||||
if (concurrencyCounter > 0 && System.Environment.TickCount - lastHit < 30000)
|
if (concurrencyCounter > 0 || System.Environment.TickCount - lastHit > 30000)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((updateLogCounter++ % updateLogMod) == 0)
|
if ((updateLogCounter++ % updateLogMod) == 0)
|
||||||
|
@ -156,6 +157,20 @@ namespace OpenSim.Region.UserStatistics
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Hashtable HandleUnknownCAPSRequest(Hashtable request)
|
||||||
|
{
|
||||||
|
string regpath = request["uri"].ToString();
|
||||||
|
int response_code = 200;
|
||||||
|
string contenttype = "text/html";
|
||||||
|
UpdateUserStats(ParseViewerStats(request["body"].ToString(), UUID.Zero), dbConn);
|
||||||
|
Hashtable responsedata = new Hashtable();
|
||||||
|
|
||||||
|
responsedata["int_response_code"] = response_code;
|
||||||
|
responsedata["content_type"] = contenttype;
|
||||||
|
responsedata["keepalive"] = false;
|
||||||
|
responsedata["str_response_string"] = string.Empty;
|
||||||
|
return responsedata;
|
||||||
|
}
|
||||||
|
|
||||||
public Hashtable HandleStatsRequest(Hashtable request)
|
public Hashtable HandleStatsRequest(Hashtable request)
|
||||||
{
|
{
|
||||||
|
@ -338,16 +353,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
|
|
||||||
public void OnMakeChildAgent(ScenePresence agent)
|
public void OnMakeChildAgent(ScenePresence agent)
|
||||||
{
|
{
|
||||||
lock (m_sessions)
|
|
||||||
{
|
|
||||||
if (m_sessions.ContainsKey(agent.UUID))
|
|
||||||
{
|
|
||||||
if (m_sessions[agent.UUID].region_id == GetRegionUUIDFromHandle(agent.RegionHandle))
|
|
||||||
{
|
|
||||||
m_sessions.Remove(agent.UUID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -426,30 +432,78 @@ namespace OpenSim.Region.UserStatistics
|
||||||
public string ViewerStatsReport(string request, string path, string param,
|
public string ViewerStatsReport(string request, string path, string param,
|
||||||
UUID agentID, Caps caps)
|
UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
m_log.Debug(request);
|
//m_log.Debug(request);
|
||||||
UserSessionID uid;
|
|
||||||
UserSessionData usd;
|
|
||||||
|
|
||||||
|
UpdateUserStats(ParseViewerStats(request,agentID), dbConn);
|
||||||
|
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserSessionID ParseViewerStats(string request, UUID agentID)
|
||||||
|
{
|
||||||
|
UserSessionID uid = new UserSessionID();
|
||||||
|
UserSessionData usd;
|
||||||
|
OSD message = OSDParser.DeserializeLLSDXml(request);
|
||||||
|
OSDMap mmap;
|
||||||
lock (m_sessions)
|
lock (m_sessions)
|
||||||
{
|
{
|
||||||
|
if (agentID != UUID.Zero)
|
||||||
|
{
|
||||||
|
|
||||||
if (!m_sessions.ContainsKey(agentID))
|
if (!m_sessions.ContainsKey(agentID))
|
||||||
{
|
{
|
||||||
m_log.Warn("[VS]: no session for stat disclosure");
|
m_log.Warn("[VS]: no session for stat disclosure");
|
||||||
return string.Empty;
|
return new UserSessionID();
|
||||||
}
|
}
|
||||||
uid = m_sessions[agentID];
|
uid = m_sessions[agentID];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// parse through the beginning to locate the session
|
||||||
|
if (message.Type != OSDType.Map)
|
||||||
|
return new UserSessionID();
|
||||||
|
|
||||||
|
mmap = (OSDMap)message;
|
||||||
|
{
|
||||||
|
UUID sessionID = mmap["session_id"].AsUUID();
|
||||||
|
|
||||||
|
if (sessionID == UUID.Zero)
|
||||||
|
return new UserSessionID();
|
||||||
|
|
||||||
|
|
||||||
|
// search through each session looking for the owner
|
||||||
|
foreach (UUID usersessionid in m_sessions.Keys)
|
||||||
|
{
|
||||||
|
// got it!
|
||||||
|
if (m_sessions[usersessionid].session_id == sessionID)
|
||||||
|
{
|
||||||
|
agentID = usersessionid;
|
||||||
|
uid = m_sessions[usersessionid];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// can't find a session
|
||||||
|
if (agentID == UUID.Zero)
|
||||||
|
{
|
||||||
|
return new UserSessionID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
usd = uid.session_data;
|
usd = uid.session_data;
|
||||||
|
|
||||||
OSD message = OSDParser.DeserializeLLSDXml(request);
|
|
||||||
if (message.Type != OSDType.Map)
|
|
||||||
return String.Empty;
|
|
||||||
|
|
||||||
OSDMap mmap = (OSDMap) message;
|
|
||||||
|
if (message.Type != OSDType.Map)
|
||||||
|
return new UserSessionID();
|
||||||
|
|
||||||
|
mmap = (OSDMap)message;
|
||||||
{
|
{
|
||||||
if (mmap["agent"].Type != OSDType.Map)
|
if (mmap["agent"].Type != OSDType.Map)
|
||||||
return String.Empty;
|
return new UserSessionID();
|
||||||
OSDMap agent_map = (OSDMap)mmap["agent"];
|
OSDMap agent_map = (OSDMap)mmap["agent"];
|
||||||
usd.agent_id = agentID;
|
usd.agent_id = agentID;
|
||||||
usd.name_f = uid.name_f;
|
usd.name_f = uid.name_f;
|
||||||
|
@ -469,7 +523,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
(float)agent_map["fps"].AsReal());
|
(float)agent_map["fps"].AsReal());
|
||||||
|
|
||||||
if (mmap["downloads"].Type != OSDType.Map)
|
if (mmap["downloads"].Type != OSDType.Map)
|
||||||
return String.Empty;
|
return new UserSessionID();
|
||||||
OSDMap downloads_map = (OSDMap)mmap["downloads"];
|
OSDMap downloads_map = (OSDMap)mmap["downloads"];
|
||||||
usd.d_object_kb = (float)downloads_map["object_kbytes"].AsReal();
|
usd.d_object_kb = (float)downloads_map["object_kbytes"].AsReal();
|
||||||
usd.d_texture_kb = (float)downloads_map["texture_kbytes"].AsReal();
|
usd.d_texture_kb = (float)downloads_map["texture_kbytes"].AsReal();
|
||||||
|
@ -479,7 +533,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
usd.session_id = mmap["session_id"].AsUUID();
|
usd.session_id = mmap["session_id"].AsUUID();
|
||||||
|
|
||||||
if (mmap["system"].Type != OSDType.Map)
|
if (mmap["system"].Type != OSDType.Map)
|
||||||
return String.Empty;
|
return new UserSessionID();
|
||||||
OSDMap system_map = (OSDMap)mmap["system"];
|
OSDMap system_map = (OSDMap)mmap["system"];
|
||||||
|
|
||||||
usd.s_cpu = system_map["cpu"].AsString();
|
usd.s_cpu = system_map["cpu"].AsString();
|
||||||
|
@ -488,12 +542,13 @@ namespace OpenSim.Region.UserStatistics
|
||||||
usd.s_ram = system_map["ram"].AsInteger();
|
usd.s_ram = system_map["ram"].AsInteger();
|
||||||
|
|
||||||
if (mmap["stats"].Type != OSDType.Map)
|
if (mmap["stats"].Type != OSDType.Map)
|
||||||
return String.Empty;
|
return new UserSessionID();
|
||||||
|
|
||||||
OSDMap stats_map = (OSDMap)mmap["stats"];
|
OSDMap stats_map = (OSDMap)mmap["stats"];
|
||||||
{
|
{
|
||||||
if (mmap["failures"].Type != OSDType.Map)
|
|
||||||
return String.Empty;
|
if (stats_map["failures"].Type != OSDType.Map)
|
||||||
|
return new UserSessionID();
|
||||||
OSDMap stats_failures = (OSDMap)stats_map["failures"];
|
OSDMap stats_failures = (OSDMap)stats_map["failures"];
|
||||||
usd.f_dropped = stats_failures["dropped"].AsInteger();
|
usd.f_dropped = stats_failures["dropped"].AsInteger();
|
||||||
usd.f_failed_resends = stats_failures["failed_resends"].AsInteger();
|
usd.f_failed_resends = stats_failures["failed_resends"].AsInteger();
|
||||||
|
@ -501,19 +556,19 @@ namespace OpenSim.Region.UserStatistics
|
||||||
usd.f_resent = stats_failures["resent"].AsInteger();
|
usd.f_resent = stats_failures["resent"].AsInteger();
|
||||||
usd.f_send_packet = stats_failures["send_packet"].AsInteger();
|
usd.f_send_packet = stats_failures["send_packet"].AsInteger();
|
||||||
|
|
||||||
if (mmap["net"].Type != OSDType.Map)
|
if (stats_map["net"].Type != OSDType.Map)
|
||||||
return String.Empty;
|
return new UserSessionID();
|
||||||
OSDMap stats_net = (OSDMap)stats_map["net"];
|
OSDMap stats_net = (OSDMap)stats_map["net"];
|
||||||
{
|
{
|
||||||
if (mmap["in"].Type != OSDType.Map)
|
if (stats_net["in"].Type != OSDType.Map)
|
||||||
return String.Empty;
|
return new UserSessionID();
|
||||||
|
|
||||||
OSDMap net_in = (OSDMap)stats_net["in"];
|
OSDMap net_in = (OSDMap)stats_net["in"];
|
||||||
usd.n_in_kb = (float)net_in["kbytes"].AsReal();
|
usd.n_in_kb = (float)net_in["kbytes"].AsReal();
|
||||||
usd.n_in_pk = net_in["packets"].AsInteger();
|
usd.n_in_pk = net_in["packets"].AsInteger();
|
||||||
|
|
||||||
if (mmap["out"].Type != OSDType.Map)
|
if (stats_net["out"].Type != OSDType.Map)
|
||||||
return String.Empty;
|
return new UserSessionID();
|
||||||
OSDMap net_out = (OSDMap)stats_net["out"];
|
OSDMap net_out = (OSDMap)stats_net["out"];
|
||||||
|
|
||||||
usd.n_out_kb = (float)net_out["kbytes"].AsReal();
|
usd.n_out_kb = (float)net_out["kbytes"].AsReal();
|
||||||
|
@ -526,13 +581,14 @@ namespace OpenSim.Region.UserStatistics
|
||||||
|
|
||||||
uid.session_data = usd;
|
uid.session_data = usd;
|
||||||
m_sessions[agentID] = uid;
|
m_sessions[agentID] = uid;
|
||||||
UpdateUserStats(uid, dbConn);
|
return uid;
|
||||||
|
|
||||||
return String.Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateUserStats(UserSessionID uid, SqliteConnection db)
|
public void UpdateUserStats(UserSessionID uid, SqliteConnection db)
|
||||||
{
|
{
|
||||||
|
if (uid.session_id == UUID.Zero)
|
||||||
|
return;
|
||||||
|
|
||||||
lock (db)
|
lock (db)
|
||||||
{
|
{
|
||||||
SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db);
|
SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db);
|
||||||
|
|
Loading…
Reference in New Issue