From 587cfc263177fa1afa55120357d228e21554b216 Mon Sep 17 00:00:00 2001 From: magicdict Date: Mon, 7 Nov 2016 11:09:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=9B=91=E8=A7=86=E5=99=A8=E5=BC=BA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FunctionForm/Aggregation/frmAddStage.cs | 7 -- .../Status/frmServerMonitor.Designer.cs | 65 ++++++++++++-- FunctionForm/Status/frmServerMonitor.cs | 86 +++++++++--------- MachineLearning/Program.cs | 3 - MachineLearning/Properties/AssemblyInfo.cs | 1 - MongoCola/Release Note_Ver2.0.txt | 1 + MongoCola/SystemManager.cs | 3 + .../Controllers/HomeController.cs | 6 +- .../Controllers/ModifyConnectionController.cs | 6 +- MongoColaWebAdmin/Program.cs | 6 +- MongoGUICtl/Aggregation/ctlMatchItem.cs | 1 - MongoUtilityCore/Command/DataBase.cs | 3 +- MongoUtilityCore/Command/GFS.cs | 4 +- MongoUtilityCore/Command/SystemStatus.cs | 87 +++++++++++++++++++ MongoUtilityCore/Properties/AssemblyInfo.cs | 1 - PlugInPrj/Properties/AssemblyInfo.cs | 1 - docs/MarkDown/MongoCola.md | 17 +++- 17 files changed, 214 insertions(+), 84 deletions(-) create mode 100644 MongoUtilityCore/Command/SystemStatus.cs diff --git a/FunctionForm/Aggregation/frmAddStage.cs b/FunctionForm/Aggregation/frmAddStage.cs index f6e16a1c..78f88342 100644 --- a/FunctionForm/Aggregation/frmAddStage.cs +++ b/FunctionForm/Aggregation/frmAddStage.cs @@ -1,16 +1,9 @@ using Common; using MongoDB.Bson; using MongoGUICtl.ClientTree; -using MongoUtility.ToolKit; using ResourceLib.Method; using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace FunctionForm.Aggregation diff --git a/FunctionForm/Status/frmServerMonitor.Designer.cs b/FunctionForm/Status/frmServerMonitor.Designer.cs index a6e57290..8b1a97cd 100644 --- a/FunctionForm/Status/frmServerMonitor.Designer.cs +++ b/FunctionForm/Status/frmServerMonitor.Designer.cs @@ -32,32 +32,77 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend(); this.MonitorGrap = new System.Windows.Forms.DataVisualization.Charting.Chart(); + this.cmbCatalog = new System.Windows.Forms.ComboBox(); + this.lblTimeInterval = new System.Windows.Forms.Label(); + this.NumTimeInterval = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.MonitorGrap)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.NumTimeInterval)).BeginInit(); this.SuspendLayout(); // // MonitorGrap // this.MonitorGrap.BorderlineColor = System.Drawing.Color.Black; this.MonitorGrap.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid; - chartArea1.Name = "ChartArea1"; - this.MonitorGrap.ChartAreas.Add(chartArea1); - legend1.Name = "Legend1"; - this.MonitorGrap.Legends.Add(legend1); - this.MonitorGrap.Location = new System.Drawing.Point(12, 27); + chartArea4.Name = "ChartArea1"; + this.MonitorGrap.ChartAreas.Add(chartArea4); + legend4.Name = "Legend1"; + this.MonitorGrap.Legends.Add(legend4); + this.MonitorGrap.Location = new System.Drawing.Point(28, 45); this.MonitorGrap.Name = "MonitorGrap"; this.MonitorGrap.Size = new System.Drawing.Size(626, 282); this.MonitorGrap.TabIndex = 0; this.MonitorGrap.Text = "chart1"; // + // cmbCatalog + // + this.cmbCatalog.FormattingEnabled = true; + this.cmbCatalog.Location = new System.Drawing.Point(533, 12); + this.cmbCatalog.Name = "cmbCatalog"; + this.cmbCatalog.Size = new System.Drawing.Size(121, 20); + this.cmbCatalog.TabIndex = 1; + this.cmbCatalog.SelectedIndexChanged += new System.EventHandler(this.cmbCatalog_SelectedIndexChanged); + // + // lblTimeInterval + // + this.lblTimeInterval.AutoSize = true; + this.lblTimeInterval.Location = new System.Drawing.Point(26, 15); + this.lblTimeInterval.Name = "lblTimeInterval"; + this.lblTimeInterval.Size = new System.Drawing.Size(137, 12); + this.lblTimeInterval.TabIndex = 2; + this.lblTimeInterval.Text = "Time Interval (second)"; + // + // NumTimeInterval + // + this.NumTimeInterval.Location = new System.Drawing.Point(169, 11); + this.NumTimeInterval.Name = "NumTimeInterval"; + this.NumTimeInterval.Size = new System.Drawing.Size(78, 21); + this.NumTimeInterval.TabIndex = 3; + this.NumTimeInterval.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.NumTimeInterval.ValueChanged += new System.EventHandler(this.NumTimeInterval_ValueChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(262, 15); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(113, 12); + this.label1.TabIndex = 4; + this.label1.Text = "0 Seconds to Pause"; + // // FrmServerMonitor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; this.ClientSize = new System.Drawing.Size(666, 339); + this.Controls.Add(this.label1); + this.Controls.Add(this.NumTimeInterval); + this.Controls.Add(this.lblTimeInterval); + this.Controls.Add(this.cmbCatalog); this.Controls.Add(this.MonitorGrap); this.MaximizeBox = false; this.MinimizeBox = false; @@ -66,12 +111,18 @@ private void InitializeComponent() this.Text = "Server Monitor"; this.Load += new System.EventHandler(this.frmServerMonitor_Load); ((System.ComponentModel.ISupportInitialize)(this.MonitorGrap)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.NumTimeInterval)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion private Chart MonitorGrap; + private ComboBox cmbCatalog; + private Label lblTimeInterval; + private NumericUpDown NumTimeInterval; + private Label label1; } } \ No newline at end of file diff --git a/FunctionForm/Status/frmServerMonitor.cs b/FunctionForm/Status/frmServerMonitor.cs index 2d819386..026766f0 100644 --- a/FunctionForm/Status/frmServerMonitor.cs +++ b/FunctionForm/Status/frmServerMonitor.cs @@ -1,6 +1,7 @@ -using MongoDB.Bson; +using Common; using MongoUtility.Command; using MongoUtility.Core; +using MongoUtilityCore.Command; using ResourceLib.Method; using ResourceLib.Properties; using System; @@ -21,28 +22,16 @@ public FrmServerMonitor() GuiConfig.Translateform(this); } - private Dictionary QueryName = new Dictionary(); - - private void FillQueryName() - { - //opcounters - QueryName.Add("opcounters.Query", "opcounters.query"); - QueryName.Add("opcounters.Insert", "opcounters.insert"); - QueryName.Add("opcounters.Update", "opcounters.update"); - QueryName.Add("opcounters.Delete", "opcounters.delete"); - - //memory - QueryName.Add("mem.bits", "mem.bits"); - QueryName.Add("mem.resident", "mem.resident"); - QueryName.Add("mem.virtual", "mem.virtual"); - QueryName.Add("mem.mapped", "mem.mapped"); - } - /// /// 刷新时间间隔 /// public static int RefreshInterval { set; get; } + /// + /// 分类内部项目 + /// + public static Dictionary CatalogDetailDic = new Dictionary(); + /// /// /// @@ -50,26 +39,18 @@ private void FillQueryName() /// private void frmServerMonitor_Load(object sender, EventArgs e) { - FillQueryName(); + //填充分组 + Utility.FillComberWithArray(cmbCatalog, SystemStatus.GetCatalog().ToArray()); + cmbCatalog.SelectedIndex = 0; if (!GuiConfig.IsMono) Icon = GetSystemIcon.ConvertImgToIcon(Resources.KeyInfo); _mTime = new Timer { Interval = RefreshInterval * 1000 }; + NumTimeInterval.Value = RefreshInterval; _mTime.Tick += SetValue; - MonitorGrap.Series.Clear(); - - foreach (var item in QueryName.Keys) - { - var querySeries = new Series(item.Split(".".ToCharArray())[1]) - { - ChartType = SeriesChartType.Line, - XValueType = ChartValueType.String, - YValueType = ChartValueType.Int32 - }; - MonitorGrap.Series.Add(querySeries); - } - SetValue(null,null); + SetValue(null, null); FormClosing += (x, y) => _mTime.Stop(); _mTime.Start(); } + /// /// 将值设定到图表 /// @@ -79,24 +60,45 @@ private void SetValue(object sender, EventArgs e) { var docStatus = CommandHelper.ExecuteMongoSvrCommand(CommandHelper.ServerStatusCommand, RuntimeMongoDbContext.GetCurrentServer()).Response; - foreach (var item in QueryName.Keys) + foreach (var item in CatalogDetailDic.Keys) { var queryPoint = new DataPoint(); - queryPoint.SetValueXY(DateTime.Now.ToString(CultureInfo.InvariantCulture), GetValue(docStatus, QueryName[item])); + queryPoint.SetValueXY(DateTime.Now.ToString(CultureInfo.InvariantCulture), SystemStatus.GetValue(docStatus, CatalogDetailDic[item])); MonitorGrap.Series[item.Split(".".ToCharArray())[1]].Points.Add(queryPoint); } } + + private void cmbCatalog_SelectedIndexChanged(object sender, EventArgs e) + { + CatalogDetailDic = SystemStatus.GetCatalogDic(cmbCatalog.Text); + MonitorGrap.Series.Clear(); + foreach (var item in CatalogDetailDic.Keys) + { + var querySeries = new Series(item.Split(".".ToCharArray())[1]) + { + ChartType = SeriesChartType.Line, + XValueType = ChartValueType.String, + YValueType = ChartValueType.Int32 + }; + MonitorGrap.Series.Add(querySeries); + } + } /// - /// 获得值 + /// 时间变化 /// - /// - /// - /// - private BsonValue GetValue(BsonDocument Doc, string Path) + /// + /// + private void NumTimeInterval_ValueChanged(object sender, EventArgs e) { - var PathArray = Path.Split(".".ToCharArray()); - return Doc.GetElement(PathArray[0]).Value.AsBsonDocument.GetElement(PathArray[1]).Value; + if ((int)NumTimeInterval.Value == 0) + { + _mTime.Stop(); + } + else + { + _mTime.Start(); + _mTime.Interval = (int)NumTimeInterval.Value * 1000; + } } - } } \ No newline at end of file diff --git a/MachineLearning/Program.cs b/MachineLearning/Program.cs index f632c94b..8eeccd77 100644 --- a/MachineLearning/Program.cs +++ b/MachineLearning/Program.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; namespace MachineLearning diff --git a/MachineLearning/Properties/AssemblyInfo.cs b/MachineLearning/Properties/AssemblyInfo.cs index 92b9f0f0..bb8fca8e 100644 --- a/MachineLearning/Properties/AssemblyInfo.cs +++ b/MachineLearning/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // 有关程序集的一般信息由以下 diff --git a/MongoCola/Release Note_Ver2.0.txt b/MongoCola/Release Note_Ver2.0.txt index e02b3fe3..a6f2a6ad 100644 --- a/MongoCola/Release Note_Ver2.0.txt +++ b/MongoCola/Release Note_Ver2.0.txt @@ -6,6 +6,7 @@ 2. 树形数据展示控件,文档根字段表示优化 3. 服务器属性菜单表示的内容合并到服务器状态中 4. 启动后自动选中数据库结构的根对象 +5. 服务器监视功能的强化,允许同时打开多个监视窗体(改为非模态) ##Ver 2.0.3 2016/11/03 diff --git a/MongoCola/SystemManager.cs b/MongoCola/SystemManager.cs index 760947a6..7580a5bd 100644 --- a/MongoCola/SystemManager.cs +++ b/MongoCola/SystemManager.cs @@ -3,6 +3,7 @@ using MongoUtility.Command; using MongoUtility.Core; using MongoUtility.ToolKit; +using MongoUtilityCore.Command; using ResourceLib.Method; using System; using System.Diagnostics; @@ -95,6 +96,8 @@ public static void Init() MongoConfig.LoadFromConfigFile(); RuntimeMongoDbContext.MongoConnectionConfigList = MongoConnectionConfig.MongoConfig.ConnectionList; } + //服务器状态字典的初始化 + SystemStatus.FillStatusDicName(); Application.Run(new frmMain()); //delete tempfile directory when exit if (Directory.Exists(Gfs.TempFileFolder)) diff --git a/MongoColaWebAdmin/Controllers/HomeController.cs b/MongoColaWebAdmin/Controllers/HomeController.cs index db33db88..a25d6df2 100644 --- a/MongoColaWebAdmin/Controllers/HomeController.cs +++ b/MongoColaWebAdmin/Controllers/HomeController.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; namespace MongoColaWebAdmin.Controllers { diff --git a/MongoColaWebAdmin/Controllers/ModifyConnectionController.cs b/MongoColaWebAdmin/Controllers/ModifyConnectionController.cs index 8e439ed1..f6f59120 100644 --- a/MongoColaWebAdmin/Controllers/ModifyConnectionController.cs +++ b/MongoColaWebAdmin/Controllers/ModifyConnectionController.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; // For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 diff --git a/MongoColaWebAdmin/Program.cs b/MongoColaWebAdmin/Program.cs index 8cae005c..1fa90f14 100644 --- a/MongoColaWebAdmin/Program.cs +++ b/MongoColaWebAdmin/Program.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; +using System.IO; using Microsoft.AspNetCore.Hosting; namespace MongoColaWebAdmin diff --git a/MongoGUICtl/Aggregation/ctlMatchItem.cs b/MongoGUICtl/Aggregation/ctlMatchItem.cs index 36dee5c2..3422e54e 100644 --- a/MongoGUICtl/Aggregation/ctlMatchItem.cs +++ b/MongoGUICtl/Aggregation/ctlMatchItem.cs @@ -4,7 +4,6 @@ using MongoUtility.Aggregation; using MongoUtility.Core; using MongoUtility.ToolKit; -using MongoUtility.Basic; namespace MongoGUICtl.Aggregation { diff --git a/MongoUtilityCore/Command/DataBase.cs b/MongoUtilityCore/Command/DataBase.cs index 4d460382..480f3e07 100644 --- a/MongoUtilityCore/Command/DataBase.cs +++ b/MongoUtilityCore/Command/DataBase.cs @@ -1,5 +1,4 @@ -using System; -using MongoUtility.Basic; +using MongoUtility.Basic; using MongoUtility.Core; namespace MongoUtility.Command diff --git a/MongoUtilityCore/Command/GFS.cs b/MongoUtilityCore/Command/GFS.cs index 09ea65b7..ab15bfbd 100644 --- a/MongoUtilityCore/Command/GFS.cs +++ b/MongoUtilityCore/Command/GFS.cs @@ -1,6 +1,4 @@ -using System; -using System.ComponentModel; -using System.Diagnostics; +using System.Diagnostics; using System.IO; using MongoDB.Driver; using MongoDB.Driver.GridFS; diff --git a/MongoUtilityCore/Command/SystemStatus.cs b/MongoUtilityCore/Command/SystemStatus.cs new file mode 100644 index 00000000..af70baf9 --- /dev/null +++ b/MongoUtilityCore/Command/SystemStatus.cs @@ -0,0 +1,87 @@ +using MongoDB.Bson; +using System.Collections.Generic; + +namespace MongoUtilityCore.Command +{ + public static class SystemStatus + { + /// + /// 状态字典 + /// + public static Dictionary StatusNameDic = new Dictionary(); + + public static void FillStatusDicName() + { + //opcounters + StatusNameDic.Add("opcounters.Query", "opcounters.query"); + StatusNameDic.Add("opcounters.Insert", "opcounters.insert"); + StatusNameDic.Add("opcounters.Update", "opcounters.update"); + StatusNameDic.Add("opcounters.Delete", "opcounters.delete"); + + //asserts + StatusNameDic.Add("asserts.msg", "asserts.msg"); + StatusNameDic.Add("asserts.regular", "asserts.regular"); + StatusNameDic.Add("asserts.rollovers", "asserts.rollovers"); + StatusNameDic.Add("asserts.user", "asserts.user"); + StatusNameDic.Add("asserts.warning", "asserts.warning"); + + //mem + StatusNameDic.Add("mem.bits", "mem.bits"); + StatusNameDic.Add("mem.resident", "mem.resident"); + StatusNameDic.Add("mem.virtual", "mem.virtual"); + StatusNameDic.Add("mem.mapped", "mem.mapped"); + + //connections(available的数字十分巨大,放在一起的话,图表则无法清楚表示) + StatusNameDic.Add("connections1.available", "connections.available"); + StatusNameDic.Add("connections2.current", "connections.current"); + StatusNameDic.Add("connections2.totalCreated", "connections.totalCreated"); + + //network + StatusNameDic.Add("network.bytesIn", "network.bytesIn"); + StatusNameDic.Add("network.bytesOut", "network.bytesOut"); + StatusNameDic.Add("network.numRequests", "network.numRequests"); + StatusNameDic.Add("network.physicalBytesIn", "network.physicalBytesIn"); + StatusNameDic.Add("network.physicalBytesOut", "network.physicalBytesOut"); + + } + + /// + /// 获得值 + /// + /// + /// + /// + public static BsonValue GetValue(BsonDocument Doc, string Path) + { + var PathArray = Path.Split(".".ToCharArray()); + return Doc.GetElement(PathArray[0]).Value.AsBsonDocument.GetElement(PathArray[1]).Value; + } + + public static Dictionary GetCatalogDic(string CatalogName) + { + var CatalogDic = new Dictionary(); + foreach (var strKey in StatusNameDic.Keys) + { + if (strKey.StartsWith(CatalogName + ".")) + { + CatalogDic.Add(strKey, StatusNameDic[strKey]); + } + } + return CatalogDic; + } + + public static List GetCatalog() + { + var lst = new List(); + foreach (var item in StatusNameDic.Keys) + { + var Catalog = item.Split(".".ToCharArray())[0]; + if (!lst.Contains(Catalog)) lst.Add(Catalog); + } + return lst; + } + + + + } +} diff --git a/MongoUtilityCore/Properties/AssemblyInfo.cs b/MongoUtilityCore/Properties/AssemblyInfo.cs index b9eeeb01..50dfc785 100644 --- a/MongoUtilityCore/Properties/AssemblyInfo.cs +++ b/MongoUtilityCore/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/PlugInPrj/Properties/AssemblyInfo.cs b/PlugInPrj/Properties/AssemblyInfo.cs index 690c6357..1026144d 100644 --- a/PlugInPrj/Properties/AssemblyInfo.cs +++ b/PlugInPrj/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // 有关程序集的一般信息由以下 diff --git a/docs/MarkDown/MongoCola.md b/docs/MarkDown/MongoCola.md index 6ca52ed2..2e68c8e0 100644 --- a/docs/MarkDown/MongoCola.md +++ b/docs/MarkDown/MongoCola.md @@ -122,7 +122,11 @@ Mongo3.4新增概念:通过设定Collation可以指定字符串比较的时候 ![](/FileSystem/Thumbnail?filename=00000001_20161104095939_CreateCollation.png) -[该功能开发中] +###服务器监视 + +你可以同时打开多个服务器监视窗体查看服务器的各种状态 + +![](/FileSystem/Thumbnail?filename=00000001_20161107110554_Server Monitor.png) ##索引管理 ###索引一览和删除 @@ -307,6 +311,17 @@ MongoDB的视图是对某个数据集进行聚合操作生成的视图,暂时 ## 更新履历 +##Ver 2.0.5 2016/11/11 + +###修改 +1. 调整服务器监视功能的入口,移动到服务器顶层菜单 +2. 树形数据展示控件,文档根字段表示优化 +3. 服务器属性菜单表示的内容合并到服务器状态中 +4. 启动后自动选中数据库结构的根对象 +5. 服务器监视功能的强化,允许同时打开多个监视窗体(改为非模态) + +##Ver 2.0.3 2016/11/03 + ###新增 1. 添加视图(From MongoDB 3.4) 2. 视图的展示(From MongoDB 3.4)