aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
diff options
context:
space:
mode:
authorCharles Krinke2009-05-02 16:28:30 +0000
committerCharles Krinke2009-05-02 16:28:30 +0000
commit280d2cbf4ab7a075b3a3d16744ba4f2b2a19c984 (patch)
tree79a984b7874804d64007e9944d9c23180cf82f0e /OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
parentThank you kindly, MCortez for a patch that solves: (diff)
downloadopensim-SC-280d2cbf4ab7a075b3a3d16744ba4f2b2a19c984.zip
opensim-SC-280d2cbf4ab7a075b3a3d16744ba4f2b2a19c984.tar.gz
opensim-SC-280d2cbf4ab7a075b3a3d16744ba4f2b2a19c984.tar.bz2
opensim-SC-280d2cbf4ab7a075b3a3d16744ba4f2b2a19c984.tar.xz
Thank you kindly, BlueWall, for a patch that:
Move json stats to non-published resource name Remove well-known resource name for json stats, creating dynamic uris with private keys and add a user configurable resource name for region owner usage.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs115
1 files changed, 115 insertions, 0 deletions
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}