aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/UserStatistics/Prototype_distributor.cs2
-rw-r--r--OpenSim/Region/UserStatistics/WebStatsModule.cs174
2 files changed, 117 insertions, 59 deletions
diff --git a/OpenSim/Region/UserStatistics/Prototype_distributor.cs b/OpenSim/Region/UserStatistics/Prototype_distributor.cs
index cdefef8..749831e 100644
--- a/OpenSim/Region/UserStatistics/Prototype_distributor.cs
+++ b/OpenSim/Region/UserStatistics/Prototype_distributor.cs
@@ -46,6 +46,8 @@ namespace OpenSim.Region.UserStatistics
46 { 46 {
47 StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/prototype.js", FileMode.Open)); 47 StreamReader fs = new StreamReader(new FileStream(Util.dataDir() + "/data/prototype.js", FileMode.Open));
48 prototypejs = fs.ReadToEnd(); 48 prototypejs = fs.ReadToEnd();
49 fs.Close();
50 fs.Dispose();
49 } 51 }
50 pResult["js"] = prototypejs; 52 pResult["js"] = prototypejs;
51 return pResult; 53 return pResult;
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index da9149e..705e77f 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -114,6 +114,7 @@ namespace OpenSim.Region.UserStatistics
114 reports.Add("activelogajax.ajax", ajLogLines); 114 reports.Add("activelogajax.ajax", ajLogLines);
115 115
116 scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest); 116 scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest);
117 scene.CommsManager.HttpServer.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
117 118
118 119
119 } 120 }
@@ -135,7 +136,7 @@ namespace OpenSim.Region.UserStatistics
135 { 136 {
136 // Ignore the update if there's a report running right now 137 // Ignore the update if there's a report running right now
137 // ignore the update if there hasn't been a hit in 30 seconds. 138 // ignore the update if there hasn't been a hit in 30 seconds.
138 if (concurrencyCounter > 0 && System.Environment.TickCount - lastHit < 30000) 139 if (concurrencyCounter > 0 || System.Environment.TickCount - lastHit > 30000)
139 return; 140 return;
140 141
141 if ((updateLogCounter++ % updateLogMod) == 0) 142 if ((updateLogCounter++ % updateLogMod) == 0)
@@ -156,6 +157,20 @@ namespace OpenSim.Region.UserStatistics
156 157
157 } 158 }
158 } 159 }
160 public Hashtable HandleUnknownCAPSRequest(Hashtable request)
161 {
162 string regpath = request["uri"].ToString();
163 int response_code = 200;
164 string contenttype = "text/html";
165 UpdateUserStats(ParseViewerStats(request["body"].ToString(), UUID.Zero), dbConn);
166 Hashtable responsedata = new Hashtable();
167
168 responsedata["int_response_code"] = response_code;
169 responsedata["content_type"] = contenttype;
170 responsedata["keepalive"] = false;
171 responsedata["str_response_string"] = string.Empty;
172 return responsedata;
173 }
159 174
160 public Hashtable HandleStatsRequest(Hashtable request) 175 public Hashtable HandleStatsRequest(Hashtable request)
161 { 176 {
@@ -285,7 +300,7 @@ namespace OpenSim.Region.UserStatistics
285 300
286 public void OnDeRegisterCaps(UUID agentID, Caps caps) 301 public void OnDeRegisterCaps(UUID agentID, Caps caps)
287 { 302 {
288 303
289 } 304 }
290 305
291 protected virtual void AddHandlers() 306 protected virtual void AddHandlers()
@@ -338,16 +353,7 @@ namespace OpenSim.Region.UserStatistics
338 353
339 public void OnMakeChildAgent(ScenePresence agent) 354 public void OnMakeChildAgent(ScenePresence agent)
340 { 355 {
341 lock (m_sessions) 356
342 {
343 if (m_sessions.ContainsKey(agent.UUID))
344 {
345 if (m_sessions[agent.UUID].region_id == GetRegionUUIDFromHandle(agent.RegionHandle))
346 {
347 m_sessions.Remove(agent.UUID);
348 }
349 }
350 }
351 } 357 }
352 358
353 359
@@ -426,61 +432,109 @@ namespace OpenSim.Region.UserStatistics
426 public string ViewerStatsReport(string request, string path, string param, 432 public string ViewerStatsReport(string request, string path, string param,
427 UUID agentID, Caps caps) 433 UUID agentID, Caps caps)
428 { 434 {
429 m_log.Debug(request); 435 //m_log.Debug(request);
430 UserSessionID uid; 436
431 UserSessionData usd; 437 UpdateUserStats(ParseViewerStats(request,agentID), dbConn);
438
439 return String.Empty;
440 }
432 441
442 public UserSessionID ParseViewerStats(string request, UUID agentID)
443 {
444 UserSessionID uid = new UserSessionID();
445 UserSessionData usd;
446 OSD message = OSDParser.DeserializeLLSDXml(request);
447 OSDMap mmap;
433 lock (m_sessions) 448 lock (m_sessions)
434 { 449 {
435 if (!m_sessions.ContainsKey(agentID)) 450 if (agentID != UUID.Zero)
436 { 451 {
437 m_log.Warn("[VS]: no session for stat disclosure"); 452
438 return string.Empty; 453 if (!m_sessions.ContainsKey(agentID))
454 {
455 m_log.Warn("[VS]: no session for stat disclosure");
456 return new UserSessionID();
457 }
458 uid = m_sessions[agentID];
439 } 459 }
440 uid = m_sessions[agentID]; 460 else
441 } 461 {
462 // parse through the beginning to locate the session
463 if (message.Type != OSDType.Map)
464 return new UserSessionID();
442 465
466 mmap = (OSDMap)message;
467 {
468 UUID sessionID = mmap["session_id"].AsUUID();
469
470 if (sessionID == UUID.Zero)
471 return new UserSessionID();
472
473
474 // search through each session looking for the owner
475 foreach (UUID usersessionid in m_sessions.Keys)
476 {
477 // got it!
478 if (m_sessions[usersessionid].session_id == sessionID)
479 {
480 agentID = usersessionid;
481 uid = m_sessions[usersessionid];
482 break;
483 }
484
485 }
486
487 // can't find a session
488 if (agentID == UUID.Zero)
489 {
490 return new UserSessionID();
491 }
492 }
493 }
494 }
495
443 usd = uid.session_data; 496 usd = uid.session_data;
444 497
445 OSD message = OSDParser.DeserializeLLSDXml(request); 498
499
446 if (message.Type != OSDType.Map) 500 if (message.Type != OSDType.Map)
447 return String.Empty; 501 return new UserSessionID();
448 502
449 OSDMap mmap = (OSDMap) message; 503 mmap = (OSDMap)message;
450 { 504 {
451 if (mmap["agent"].Type != OSDType.Map) 505 if (mmap["agent"].Type != OSDType.Map)
452 return String.Empty; 506 return new UserSessionID();
453 OSDMap agent_map = (OSDMap) mmap["agent"]; 507 OSDMap agent_map = (OSDMap)mmap["agent"];
454 usd.agent_id = agentID; 508 usd.agent_id = agentID;
455 usd.name_f = uid.name_f; 509 usd.name_f = uid.name_f;
456 usd.name_l = uid.name_l; 510 usd.name_l = uid.name_l;
457 usd.region_id = uid.region_id; 511 usd.region_id = uid.region_id;
458 usd.a_language = agent_map["language"].AsString(); 512 usd.a_language = agent_map["language"].AsString();
459 usd.mem_use = (float) agent_map["mem_use"].AsReal(); 513 usd.mem_use = (float)agent_map["mem_use"].AsReal();
460 usd.meters_traveled = (float) agent_map["meters_traveled"].AsReal(); 514 usd.meters_traveled = (float)agent_map["meters_traveled"].AsReal();
461 usd.regions_visited = agent_map["regions_visited"].AsInteger(); 515 usd.regions_visited = agent_map["regions_visited"].AsInteger();
462 usd.run_time = (float) agent_map["run_time"].AsReal(); 516 usd.run_time = (float)agent_map["run_time"].AsReal();
463 usd.start_time = (float) agent_map["start_time"].AsReal(); 517 usd.start_time = (float)agent_map["start_time"].AsReal();
464 usd.client_version = agent_map["version"].AsString(); 518 usd.client_version = agent_map["version"].AsString();
465 519
466 UserSessionUtil.UpdateMultiItems(ref usd, agent_map["agents_in_view"].AsInteger(), 520 UserSessionUtil.UpdateMultiItems(ref usd, agent_map["agents_in_view"].AsInteger(),
467 (float) agent_map["ping"].AsReal(), 521 (float)agent_map["ping"].AsReal(),
468 (float) agent_map["sim_fps"].AsReal(), 522 (float)agent_map["sim_fps"].AsReal(),
469 (float) agent_map["fps"].AsReal()); 523 (float)agent_map["fps"].AsReal());
470 524
471 if (mmap["downloads"].Type != OSDType.Map) 525 if (mmap["downloads"].Type != OSDType.Map)
472 return String.Empty; 526 return new UserSessionID();
473 OSDMap downloads_map = (OSDMap) mmap["downloads"]; 527 OSDMap downloads_map = (OSDMap)mmap["downloads"];
474 usd.d_object_kb = (float) downloads_map["object_kbytes"].AsReal(); 528 usd.d_object_kb = (float)downloads_map["object_kbytes"].AsReal();
475 usd.d_texture_kb = (float) downloads_map["texture_kbytes"].AsReal(); 529 usd.d_texture_kb = (float)downloads_map["texture_kbytes"].AsReal();
476 usd.d_world_kb = (float) downloads_map["workd_kbytes"].AsReal(); 530 usd.d_world_kb = (float)downloads_map["workd_kbytes"].AsReal();
477 531
478 532
479 usd.session_id = mmap["session_id"].AsUUID(); 533 usd.session_id = mmap["session_id"].AsUUID();
480 534
481 if (mmap["system"].Type != OSDType.Map) 535 if (mmap["system"].Type != OSDType.Map)
482 return String.Empty; 536 return new UserSessionID();
483 OSDMap system_map = (OSDMap) mmap["system"]; 537 OSDMap system_map = (OSDMap)mmap["system"];
484 538
485 usd.s_cpu = system_map["cpu"].AsString(); 539 usd.s_cpu = system_map["cpu"].AsString();
486 usd.s_gpu = system_map["gpu"].AsString(); 540 usd.s_gpu = system_map["gpu"].AsString();
@@ -488,51 +542,53 @@ namespace OpenSim.Region.UserStatistics
488 usd.s_ram = system_map["ram"].AsInteger(); 542 usd.s_ram = system_map["ram"].AsInteger();
489 543
490 if (mmap["stats"].Type != OSDType.Map) 544 if (mmap["stats"].Type != OSDType.Map)
491 return String.Empty; 545 return new UserSessionID();
492 546
493 OSDMap stats_map = (OSDMap) mmap["stats"]; 547 OSDMap stats_map = (OSDMap)mmap["stats"];
494 { 548 {
495 if (mmap["failures"].Type != OSDType.Map) 549
496 return String.Empty; 550 if (stats_map["failures"].Type != OSDType.Map)
497 OSDMap stats_failures = (OSDMap) stats_map["failures"]; 551 return new UserSessionID();
552 OSDMap stats_failures = (OSDMap)stats_map["failures"];
498 usd.f_dropped = stats_failures["dropped"].AsInteger(); 553 usd.f_dropped = stats_failures["dropped"].AsInteger();
499 usd.f_failed_resends = stats_failures["failed_resends"].AsInteger(); 554 usd.f_failed_resends = stats_failures["failed_resends"].AsInteger();
500 usd.f_invalid = stats_failures["invalid"].AsInteger(); 555 usd.f_invalid = stats_failures["invalid"].AsInteger();
501 usd.f_resent = stats_failures["resent"].AsInteger(); 556 usd.f_resent = stats_failures["resent"].AsInteger();
502 usd.f_send_packet = stats_failures["send_packet"].AsInteger(); 557 usd.f_send_packet = stats_failures["send_packet"].AsInteger();
503 558
504 if (mmap["net"].Type != OSDType.Map) 559 if (stats_map["net"].Type != OSDType.Map)
505 return String.Empty; 560 return new UserSessionID();
506 OSDMap stats_net = (OSDMap) stats_map["net"]; 561 OSDMap stats_net = (OSDMap)stats_map["net"];
507 { 562 {
508 if (mmap["in"].Type != OSDType.Map) 563 if (stats_net["in"].Type != OSDType.Map)
509 return String.Empty; 564 return new UserSessionID();
510 565
511 OSDMap net_in = (OSDMap) stats_net["in"]; 566 OSDMap net_in = (OSDMap)stats_net["in"];
512 usd.n_in_kb = (float) net_in["kbytes"].AsReal(); 567 usd.n_in_kb = (float)net_in["kbytes"].AsReal();
513 usd.n_in_pk = net_in["packets"].AsInteger(); 568 usd.n_in_pk = net_in["packets"].AsInteger();
514 569
515 if (mmap["out"].Type != OSDType.Map) 570 if (stats_net["out"].Type != OSDType.Map)
516 return String.Empty; 571 return new UserSessionID();
517 OSDMap net_out = (OSDMap) stats_net["out"]; 572 OSDMap net_out = (OSDMap)stats_net["out"];
518 573
519 usd.n_out_kb = (float) net_out["kbytes"].AsReal(); 574 usd.n_out_kb = (float)net_out["kbytes"].AsReal();
520 usd.n_out_pk = net_out["packets"].AsInteger(); 575 usd.n_out_pk = net_out["packets"].AsInteger();
521 } 576 }
522 577
523 578
524 } 579 }
525 } 580 }
526 581
527 uid.session_data = usd; 582 uid.session_data = usd;
528 m_sessions[agentID] = uid; 583 m_sessions[agentID] = uid;
529 UpdateUserStats(uid, dbConn); 584 return uid;
530
531 return String.Empty;
532 } 585 }
533 586
534 public void UpdateUserStats(UserSessionID uid, SqliteConnection db) 587 public void UpdateUserStats(UserSessionID uid, SqliteConnection db)
535 { 588 {
589 if (uid.session_id == UUID.Zero)
590 return;
591
536 lock (db) 592 lock (db)
537 { 593 {
538 SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db); 594 SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db);