public void CreateCustomMonitor() { authentication = new Authentication(apiKey: MonitisAccountInformation.ApiKey, secretKey: MonitisAccountInformation.SekretKey); customMonitor = new CustomMonitor(); customMonitor.SetAuthenticationParams(authentication); agent = new CustomUserAgent(); agent.SetAuthenticationParams(authentication); var a1 = agent.AddAgent("TestAgent1" + DateTime.Now.Ticks.ToString(), "internal", new JObject(), 100000, OutputType.JSON); _agentID = JObject.Parse(a1.Content).Value<int>("data"); customMonitor = new CustomMonitor(); customMonitor.SetAuthenticationParams(authentication); MonitorParameter param = new MonitorParameter("param1", "param1d", "val", DataType.String, false); MonResultParameter resParam = new MonResultParameter("MonResparam1", "MonResparam1d", "MonResval", DataType.String); MonResultParameter resAddParam = new MonResultParameter("MonAddResparam1", "MonAddResparam1d", "MonAddResval", DataType.String); var s = customMonitor.AddMonitor(_agentID, TestCustomMonitorName + DateTime.Now.Ticks.ToString(), "Test", "internal", new List<MonitorParameter>() { param }, new List<MonResultParameter>() { resParam }, new List<MonResultParameter>() { resAddParam }); _customMonitorID = JObject.Parse(s.Content).Value<int>("data"); GetTestMonitor(); }
public TCB(MonitorParameter para) { _LastHeartbeat = DateTime.Now; _LastGotCpu = DateTime.Now; _Para = para; _HitTimes = 0; LastTotalProcessorTime = GetTotalProcessorTime(); }
/// <summary> /// Monitor register /// </summary> /// <param name="monitorPara">Monitor parameter</param> public void Register(MonitorParameter monitorPara) { Debug.Assert(monitorPara != null); Debug.Assert(monitorPara.Thread != null); //if (GetTCB(monitorPara.Thread) != null) //{ // throw new System.ArgumentException("Register repeatedly!"); //} lock (_RegisterLock) { if (_TCBTable.ContainsKey(monitorPara.Thread.ManagedThreadId)) { _TCBTable.Remove(monitorPara.Thread.ManagedThreadId); } _TCBTable.Add(monitorPara.Thread.ManagedThreadId, new TCB(monitorPara)); } }
public void CreateCustomMonitor() { authentication = new Authentication(apiKey: MonitisAccountInformation.ApiKey, secretKey: MonitisAccountInformation.SekretKey); customMonitor = new CustomMonitor(); customMonitor.SetAuthenticationParams(authentication); agent = new CustomUserAgent(); agent.SetAuthenticationParams(authentication); var a1 = agent.AddAgent("TestAgent1" + DateTime.Now.Ticks.ToString(), "internal", new JObject(), 100000, OutputType.JSON); _agentID = JObject.Parse(a1.Content).Value <int>("data"); customMonitor = new CustomMonitor(); customMonitor.SetAuthenticationParams(authentication); MonitorParameter param = new MonitorParameter("param1", "param1d", "val", DataType.String, false); MonResultParameter resParam = new MonResultParameter("MonResparam1", "MonResparam1d", "MonResval", DataType.String); MonResultParameter resAddParam = new MonResultParameter("MonAddResparam1", "MonAddResparam1d", "MonAddResval", DataType.String); var s = customMonitor.AddMonitor(_agentID, TestCustomMonitorName + DateTime.Now.Ticks.ToString(), "Test", "internal", new List <MonitorParameter>() { param }, new List <MonResultParameter>() { resParam }, new List <MonResultParameter>() { resAddParam }); _customMonitorID = JObject.Parse(s.Content).Value <int>("data"); GetTestMonitor(); }
/// <summary> /// Initializes a new instance of the <see cref="MonitorQueryWorker"/> class /// </summary> /// <param name="info">Requested information</param> internal MonitorQueryWorker(MonitorParameter info) : base() { this.Info = info; }
/// <summary> /// Initializes a new instance of the <see cref="MonitorQuerySubscriber"/> class /// </summary> /// <param name="node">Yate node information</param> /// <param name="param">Parameter to query from Yate</param> internal MonitorQuerySubscriber(INode node, MonitorParameter param) : base(node, MessageType.MonitorQuery) { this.queryLock = new SemaphoreSlim(initialCount: 1, maxCount: 1); this.Parameter = param; }
private int CreateMonitorIfNotExist(ClrMethodInfo info) { var name = GetMonitorName(info); var monitors = _monitor.GetMonitors(OutputType.XML); var monitorsElement = System.Xml.Linq.XElement.Parse(monitors.Content); var monitorss = monitorsElement.Descendants("monitor").Select(u => new { ID = u.Elements("id").FirstOrDefault(), Name = u.Elements("name").FirstOrDefault(), Monitor = u }); var monitor = monitorss.FirstOrDefault(u => u.Name != null && u.Name.Value == name); if (monitor == null) { var agents = _agent.GetAgents("profiler", true, true, OutputType.XML); var agentsElement = System.Xml.Linq.XElement.Parse(agents.Content); var agent = agentsElement.Descendants("agent").Select(u => new { ID = u.Elements("id").FirstOrDefault(), Name = u.Elements("name").FirstOrDefault(), Agent = u }).FirstOrDefault(u => u.Name != null && u.ID != null && u.Name.Value == "MonitisProfilerUserAgent"); int agentID; if (agent == null) { var result = _agent.AddAgent("MonitisProfilerUserAgent", "profiler", new JObject(), 100000, OutputType.JSON); var res = JObject.Parse(result.Content); if (res["status"].Value <string>() != "ok") { throw new InvalidOperationException("Cannot create agent!: " + res["status"]); } agentID = int.Parse(res["data"].Value <string>()); } else { agentID = int.Parse(agent.ID.Value); } var resParam = new MonResultParameter("Execution Time", "Execution Time", "Execution Time", DataType.Float); var param = new MonitorParameter("param1", "param1d", "val", DataType.String, false); var resAddParam = new MonResultParameter("MonAddResparam1", "MonAddResparam1d", "MonAddResval", DataType.String); _log.InfoFormat("Creating monitor {0}", name); var resMon = _monitor.AddMonitor(agentID, name, "profiler", "profiler", new List <MonitorParameter>() { param }, new List <MonResultParameter>() { resParam }, new List <MonResultParameter>() { resAddParam }); var resJson = JObject.Parse(resMon.Content); if (resJson["status"].Value <string>() != "ok") { throw new InvalidOperationException("Cannot create custom monitor!: " + resJson["status"]); } return(int.Parse(resJson["data"].Value <string>())); } else { _log.InfoFormat("Monitor exist {0}", name); return(int.Parse(monitor.ID.Value)); } }