diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Server/Handlers/Web/WebServerInConnector.cs | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/OpenSim/Server/Handlers/Web/WebServerInConnector.cs b/OpenSim/Server/Handlers/Web/WebServerInConnector.cs index e7fb2fc..01c74fe 100644 --- a/OpenSim/Server/Handlers/Web/WebServerInConnector.cs +++ b/OpenSim/Server/Handlers/Web/WebServerInConnector.cs | |||
@@ -38,6 +38,7 @@ using OpenMetaverse; | |||
38 | using OpenMetaverse.StructuredData; | 38 | using OpenMetaverse.StructuredData; |
39 | using Nini.Config; | 39 | using Nini.Config; |
40 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
41 | using OpenSim.Data.MySQL; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
42 | using OpenSim.Server.Handlers.Base; | 43 | using OpenSim.Server.Handlers.Base; |
43 | 44 | ||
@@ -48,12 +49,39 @@ namespace OpenSim.Server.Handlers.Web | |||
48 | // This is all slow and clunky, it's not a real web server, just something to use if you don't want a real one. | 49 | // This is all slow and clunky, it's not a real web server, just something to use if you don't want a real one. |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | private IConfigSource m_Config; | 51 | private IConfigSource m_Config; |
52 | protected MySQLGenericHandler m_Database = null; | ||
51 | private Hashtable mime = new Hashtable(); | 53 | private Hashtable mime = new Hashtable(); |
52 | private Hashtable ssi = new Hashtable(); | 54 | private Hashtable ssi = new Hashtable(); |
53 | 55 | ||
54 | public WebServerInConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) | 56 | public WebServerInConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) |
55 | { | 57 | { |
56 | m_Config = config; | 58 | m_Config = config; |
59 | |||
60 | string dllName = String.Empty; | ||
61 | string connString = String.Empty; | ||
62 | |||
63 | // | ||
64 | // Try reading the [DatabaseService] section, if it exists | ||
65 | // | ||
66 | IConfig dbConfig = m_Config.Configs["DatabaseService"]; | ||
67 | if (dbConfig != null) | ||
68 | { | ||
69 | if (dllName == String.Empty) | ||
70 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
71 | if (connString == String.Empty) | ||
72 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
73 | } | ||
74 | |||
75 | if (dllName.Equals(String.Empty)) | ||
76 | throw new Exception("No StorageProvider configured"); | ||
77 | |||
78 | //// TODO - Should do the plugin thing to pick between database backends. | ||
79 | // m_Database = LoadPlugin<SQLGenericHandler>(dllName, new Object[] { connString }); | ||
80 | m_Database = new MySQLGenericHandler(connString); | ||
81 | if (m_Database == null) | ||
82 | throw new Exception("Could not find a storage interface in the given module " + dllName); | ||
83 | |||
84 | |||
57 | mime.Add(".gz", "application/gzip"); | 85 | mime.Add(".gz", "application/gzip"); |
58 | mime.Add(".js", "application/javascript"); | 86 | mime.Add(".js", "application/javascript"); |
59 | mime.Add(".json", "application/json"); | 87 | mime.Add(".json", "application/json"); |
@@ -90,15 +118,19 @@ namespace OpenSim.Server.Handlers.Web | |||
90 | 118 | ||
91 | private Hashtable WebRequestHandler(Hashtable request) | 119 | private Hashtable WebRequestHandler(Hashtable request) |
92 | { | 120 | { |
121 | long locIn = m_Database.GetCount("Presence", "RegionID != '00000000-0000-0000-0000-000000000000'"); // Locals online but not HGing. | ||
122 | // long HGin = m_Database.GetCount("hg_traveling_data", "GridExternalName = '" + ssi["uri"] + "'"); // HGers in world, and locals not HGing, sometimes more than once. | ||
123 | long locOut = m_Database.GetCount("hg_traveling_data", "GridExternalName != '" + ssi["uri"] + "'"); // Locals that are HGing. | ||
93 | Hashtable reply = new Hashtable(); | 124 | Hashtable reply = new Hashtable(); |
94 | // Looks like we have to jump through hoops to do simple database queries. B-( | 125 | ssi["members"] = m_Database.GetCount("UserAccounts").ToString(); |
95 | ssi["members"] = "?"; // SELECT COUNT(PrincipalID) FROM UserAccounts | 126 | ssi["sims"] = m_Database.GetCount("regions").ToString(); |
96 | ssi["inworld"] = "?"; // SELECT COUNT(UserID) FROM presence_culled; Includes locals and HGers in world, but not locals HGing. | 127 | ssi["inworld"] = locIn.ToString(); |
97 | // SELECT COUNT(UserID) FROM users_online; Includes local online only. | 128 | ssi["outworld"] = locOut.ToString(); |
98 | ssi["outworld"] = "?"; // SELECT COUNT(UserID) FROM hg_traveling_data WHERE GridExternalName != ssi["uri"]; Includes locals that are HGing. | 129 | // ssi["hgers"] = HGin.ToString(); |
99 | // ssi["hgers"] = "?"; // This is complex. | 130 | ssi["hgers"] = "?"; |
100 | ssi["sims"] = "?"; // SELECT COUNT(uuid) FROM regions | 131 | ssi["month"] = m_Database.GetCount("GridUser", "Login > UNIX_TIMESTAMP(FROM_UNIXTIME(UNIX_TIMESTAMP(now()) - 2419200))").ToString(); |
101 | // ssi["month"] = "?"; // SELECT COUNT(UserID) FROM Presence WHERE LastSeen < one month ago 2017-11-28 09:01:51; Includes external HGers, and locals on now. | 132 | // SELECT COUNT(UserID) FROM Presence WHERE LastSeen < one month ago 2017-11-28 09:01:51; This is not accurate, and never has been. |
133 | // SELECT COUNT(UserID) FROM {GridUser} WHERE Login > UNIX_TIMESTAMP(FROM_UNIXTIME(UNIX_TIMESTAMP(now()) - 2419200) | ||
102 | 134 | ||
103 | string reqpath = (string) request["uri"]; | 135 | string reqpath = (string) request["uri"]; |
104 | string[] query = (string[]) request["querystringkeys"]; | 136 | string[] query = (string[]) request["querystringkeys"]; |