Skip to content

Commit

Permalink
服务器状态监视器强化
Browse files Browse the repository at this point in the history
  • Loading branch information
magicdict committed Nov 7, 2016
1 parent c307b28 commit 587cfc2
Show file tree
Hide file tree
Showing 17 changed files with 214 additions and 84 deletions.
7 changes: 0 additions & 7 deletions FunctionForm/Aggregation/frmAddStage.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
65 changes: 58 additions & 7 deletions FunctionForm/Status/frmServerMonitor.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 44 additions & 42 deletions FunctionForm/Status/frmServerMonitor.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,55 +22,35 @@ public FrmServerMonitor()
GuiConfig.Translateform(this);
}

private Dictionary<string, string> QueryName = new Dictionary<string, string>();

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");
}

/// <summary>
/// 刷新时间间隔
/// </summary>
public static int RefreshInterval { set; get; }

/// <summary>
/// 分类内部项目
/// </summary>
public static Dictionary<string, string> CatalogDetailDic = new Dictionary<string, string>();

/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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();
}

/// <summary>
/// 将值设定到图表
/// </summary>
Expand All @@ -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);
}
}
/// <summary>
/// 获得值
/// 时间变化
/// </summary>
/// <param name="Doc"></param>
/// <param name="Path"></param>
/// <returns></returns>
private BsonValue GetValue(BsonDocument Doc, string Path)
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
}

}
}
3 changes: 0 additions & 3 deletions MachineLearning/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MachineLearning
Expand Down
1 change: 0 additions & 1 deletion MachineLearning/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 有关程序集的一般信息由以下
Expand Down
1 change: 1 addition & 0 deletions MongoCola/Release Note_Ver2.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
2. 树形数据展示控件,文档根字段表示优化
3. 服务器属性菜单表示的内容合并到服务器状态中
4. 启动后自动选中数据库结构的根对象
5. 服务器监视功能的强化,允许同时打开多个监视窗体(改为非模态)

##Ver 2.0.3 2016/11/03

Expand Down
3 changes: 3 additions & 0 deletions MongoCola/SystemManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using MongoUtility.Command;
using MongoUtility.Core;
using MongoUtility.ToolKit;
using MongoUtilityCore.Command;
using ResourceLib.Method;
using System;
using System.Diagnostics;
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 1 addition & 5 deletions MongoColaWebAdmin/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
6 changes: 1 addition & 5 deletions MongoColaWebAdmin/Controllers/ModifyConnectionController.cs
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 1 addition & 5 deletions MongoColaWebAdmin/Program.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion MongoGUICtl/Aggregation/ctlMatchItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using MongoUtility.Aggregation;
using MongoUtility.Core;
using MongoUtility.ToolKit;
using MongoUtility.Basic;

namespace MongoGUICtl.Aggregation
{
Expand Down
3 changes: 1 addition & 2 deletions MongoUtilityCore/Command/DataBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using MongoUtility.Basic;
using MongoUtility.Basic;
using MongoUtility.Core;

namespace MongoUtility.Command
Expand Down
4 changes: 1 addition & 3 deletions MongoUtilityCore/Command/GFS.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading

0 comments on commit 587cfc2

Please sign in to comment.