aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs64
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs115
2 files changed, 173 insertions, 6 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 2203e45..af7b707 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -65,6 +65,8 @@ namespace OpenSim
65 65
66 protected string proxyUrl; 66 protected string proxyUrl;
67 protected int proxyOffset = 0; 67 protected int proxyOffset = 0;
68
69 public string userStatsURI = String.Empty;
68 70
69 protected bool m_autoCreateClientStack = true; 71 protected bool m_autoCreateClientStack = true;
70 72
@@ -189,6 +191,9 @@ namespace OpenSim
189 string pidFile = startupConfig.GetString("PIDFile", String.Empty); 191 string pidFile = startupConfig.GetString("PIDFile", String.Empty);
190 if (pidFile != String.Empty) 192 if (pidFile != String.Empty)
191 CreatePIDFile(pidFile); 193 CreatePIDFile(pidFile);
194
195 userStatsURI = startupConfig.GetString("Stats_URI", String.Empty);
196
192 } 197 }
193 198
194 base.StartupSpecific(); 199 base.StartupSpecific();
@@ -508,7 +513,9 @@ namespace OpenSim
508 // set initial ServerURI 513 // set initial ServerURI
509 regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.InternalEndPoint.Port; 514 regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.InternalEndPoint.Port;
510 regionInfo.HttpPort = m_httpServerPort; 515 regionInfo.HttpPort = m_httpServerPort;
511 516
517 regionInfo.osSecret = m_osSecret;
518
512 if ((proxyUrl.Length > 0) && (portadd_flag)) 519 if ((proxyUrl.Length > 0) && (portadd_flag))
513 { 520 {
514 // set proxy url to RegionInfo 521 // set proxy url to RegionInfo
@@ -543,7 +550,10 @@ namespace OpenSim
543 scene.LoadPrimsFromStorage(regionInfo.originRegionID); 550 scene.LoadPrimsFromStorage(regionInfo.originRegionID);
544 551
545 scene.StartTimer(); 552 scene.StartTimer();
546 553
554 // TODO : Try setting resource for region xstats here on scene
555 scene.CommsManager.HttpServer.AddStreamHandler( new Region.Framework.Scenes.RegionStatsHandler(regionInfo));
556
547 // moved these here as the terrain texture has to be created after the modules are initialized 557 // moved these here as the terrain texture has to be created after the modules are initialized
548 // and has to happen before the region is registered with the grid. 558 // and has to happen before the region is registered with the grid.
549 scene.CreateTerrainTexture(false); 559 scene.CreateTerrainTexture(false);
@@ -813,16 +823,18 @@ namespace OpenSim
813 } 823 }
814 824
815 /// <summary> 825 /// <summary>
816 /// Handler to supply the current extended status of this sim 826 /// Handler to supply the current extended status of this sim
827 /// Sends the statistical data in a json serialization
817 /// </summary> 828 /// </summary>
818 /// Sends the statistical data in a json serialization
819 public class XSimStatusHandler : IStreamedRequestHandler 829 public class XSimStatusHandler : IStreamedRequestHandler
820 { 830 {
821 OpenSimBase m_opensim; 831 OpenSimBase m_opensim;
832 string osXStatsURI = String.Empty;
822 833
823 public XSimStatusHandler(OpenSimBase sim) 834 public XSimStatusHandler(OpenSimBase sim)
824 { 835 {
825 m_opensim = sim; 836 m_opensim = sim;
837 osXStatsURI = Util.SHA1Hash(sim.osSecret);
826 } 838 }
827 839
828 public byte[] Handle(string path, Stream request, 840 public byte[] Handle(string path, Stream request,
@@ -842,11 +854,50 @@ namespace OpenSim
842 } 854 }
843 855
844 public string Path 856 public string Path
845 { 857 {
846 get { return "/simstatusx/"; } 858 // This is for the OpenSim instance and is the osSecret hashed
859 get { return "/" + osXStatsURI + "/"; }
847 } 860 }
848 } 861 }
849 862
863 /// <summary>
864 /// Handler to supply the current extended status of this sim
865 /// Sends the statistical data in a json serialization
866 /// </summary>
867 public class UXSimStatusHandler : IStreamedRequestHandler
868 {
869 OpenSimBase m_opensim;
870 string osUXStatsURI = String.Empty;
871
872 public UXSimStatusHandler(OpenSimBase sim)
873 {
874 m_opensim = sim;
875 osUXStatsURI = sim.userStatsURI;
876
877 }
878
879 public byte[] Handle(string path, Stream request,
880 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
881 {
882 return Encoding.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
883 }
884
885 public string ContentType
886 {
887 get { return "text/plain"; }
888 }
889
890 public string HttpMethod
891 {
892 get { return "GET"; }
893 }
894
895 public string Path
896 {
897 // This is for the OpenSim instance and is the osSecret hashed
898 get { return "/" + osUXStatsURI + "/"; }
899 }
900 }
850 901
851 #endregion 902 #endregion
852 903
@@ -906,6 +957,7 @@ namespace OpenSim
906 } 957 }
907 } 958 }
908 959
960
909 public class OpenSimConfigSource 961 public class OpenSimConfigSource
910 { 962 {
911 public IConfigSource Source; 963 public IConfigSource Source;
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
new file mode 100644
index 0000000..f521490
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -0,0 +1,115 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Net;
31using System.Reflection;
32using System.Text;
33using log4net;
34using Nini.Config;
35using OpenMetaverse;
36using OpenMetaverse.StructuredData;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services;
40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Console;
42using OpenSim.Framework.Servers;
43using OpenSim.Framework.Servers.Interfaces;
44using OpenSim.Framework.Statistics;
45using OpenSim.Region.Framework;
46using OpenSim.Region.Framework.Interfaces;
47using OpenSim.Region.Framework.Scenes;
48
49
50
51namespace OpenSim.Region.Framework.Scenes
52{
53
54
55 public class RegionStatsHandler : IStreamedRequestHandler
56 {
57
58 private string osRXStatsURI = String.Empty;
59 private string osXStatsURI = String.Empty;
60 private string osSecret = String.Empty;
61 private OpenSim.Framework.RegionInfo regionInfo;
62 public string localZone = TimeZone.CurrentTimeZone.StandardName;
63 public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
64
65 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
66
67 public RegionStatsHandler(OpenSim.Framework.RegionInfo region_info )
68 {
69 regionInfo = region_info;
70 osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret);
71 osXStatsURI = Util.SHA1Hash(regionInfo.osSecret);
72
73 }
74
75 public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
76 {
77 return Encoding.UTF8.GetBytes(Report());
78 }
79
80 public string ContentType
81 {
82 get { return "text/plain"; }
83 }
84
85 public string HttpMethod
86 {
87 get { return "GET"; }
88 }
89
90 public string Path
91 {
92 // This is for the region and is the regionSecret hashed
93 get { return "/" + osRXStatsURI + "/"; }
94 }
95
96 private string Report()
97 {
98
99 OSDMap args = new OSDMap(30);
100 int time = Util.ToUnixTime( DateTime.Now );
101 args["OSStatsURI"] = OSD.FromString("http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "/" + osXStatsURI + "/");
102 args["TimeZoneName"] = OSD.FromString(localZone);
103 args["TimeZoneOffs"] = OSD.FromReal(utcOffset.TotalHours);
104 args["UxTime"] = OSD.FromInteger(Util.ToUnixTime(DateTime.Now));
105 args["Memory"] = OSD.FromReal(Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
106 args["Version"] = OSD.FromString(VersionInfo.Version);
107
108 string strBuffer = "";
109 strBuffer = OSDParser.SerializeJsonString(args);
110
111 return strBuffer;
112
113 }
114 }
115}