void tick_Tick2(object sender, EventArgs e) { statusEx = new MEMORYSTATUSEX(); statusEx.setValues(); val1 = statusEx.dwMemoryLoad.ToString(); val2 = statusEx.convertToBytes(statusEx.ullTotalPhys).ToString("0.00"); val3 = statusEx.convertToBytes(statusEx.ullAvailPhys).ToString("0.00"); val4 = statusEx.convertToBytes(statusEx.ullTotalPageFile).ToString("0.00"); val5 = statusEx.convertToBytes(statusEx.ullAvailPageFile).ToString("0.00"); val6 = statusEx.convertToBytes(statusEx.ullTotalVirtual).ToString("0.00"); val7 = statusEx.convertToBytes(statusEx.ullAvailVirtual).ToString("0.00"); try { myConnection.Open(); string query = "INSERT INTO SystemMemoryInfo(AgentID,PercentageOfMemoryInUse,TotalPhysicalMemory,TotalAvailablePhysicalMemory,CurrentCommittedMemory,MaxAmountCommittableMemory,TotalVirtualMemory,VirtualMemoryAvailable)" + "VALUES(1,'" + val1 + "','" + val2 + "','" + val3 + "','" + val4 + "','" + val5 + "','" + val6 + "','" + val7 + "')"; SqlCommand insertQuery = new SqlCommand(query, myConnection); insertQuery.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine("cannot open SQL connection " + ex); } myConnection.Close(); }
/// <summary> /// GetCpuUsage /// </summary> /// <param name="sender">Websocket object</param> public void GetRamUsage(object sender) { HandlerParameters parameter = (HandlerParameters)sender; try { //LogMessage("StartMonitoring Method Started.", ((NativeWebSocket)parameter.Sender)); statusEx.setValues(); //double data = Convert.ToDouble(MEMORYSTATUSEX.graphMemory); Hashtable ramUsage = new Hashtable(); ramUsage.Add("ramUsage", statusEx); Dictionary <string, Hashtable> response = new Dictionary <string, Hashtable>(); response.Add("GetRamUsage", ramUsage); bool successMessage = false; if (ramUsage.Count > 0) { successMessage = true; } Response res = parameter.Args.RequestInfo.GenerateResponse(successMessage, response); ((NativeWebSocket)parameter.Sender).SendResponse(res); } catch (Exception ex) { //LogMessage(ex.Message + " Exception in ILETSNetLib.validateQuality() " + ex.StackTrace, ((NativeWebSocket)parameter.Sender)); } }
private void SystemMemoryInfo_Load(object sender, EventArgs e) { statusEx = new MEMORYSTATUSEX(); statusEx.setValues(); ram_percentage.Text = statusEx.dwMemoryLoad.ToString(); ram_totalPhysical.Text = statusEx.convertToBytes(statusEx.ullTotalPhys).ToString("0.00" + " MB"); ram_availPhysical.Text = statusEx.convertToBytes(statusEx.ullAvailPhys).ToString("0.00" + " MB"); ram_totalPage.Text = statusEx.convertToBytes(statusEx.ullTotalPageFile).ToString("0.00" + " MB"); ram_availPage.Text = statusEx.convertToBytes(statusEx.ullAvailPageFile).ToString("0.00" + " MB"); ram_totalVirtual.Text = statusEx.convertToBytes(statusEx.ullTotalVirtual).ToString("0.00" + " MB"); ram_availVirtual.Text = statusEx.convertToBytes(statusEx.ullAvailVirtual).ToString("0.00" + " MB"); }
void tick_Tick(object sender, EventArgs e) { m.setValues(); popupNotifier1 = new PopupNotifier(); popupNotifier1.TitleText = "Automated Computer Resource Management System"; if (m.dwMemoryLoad > Configuration.percentage) { tick1.Interval = Configuration.timeInterval; popupNotifier1.ContentText = "Your RAM percentage is " + m.dwMemoryLoad.ToString() + "%" + Environment.NewLine; popupNotifier1.Delay = 2000; popupNotifier1.Delay = 3000; popupNotifier1.Image = Properties.Resources.a; popupNotifier1.Popup(); } }
public void AddNewPoint(DateTime timeStamp, System.Windows.Forms.DataVisualization.Charting.Series ptSeries) { MEMORYSTATUSEX statusEx = new MEMORYSTATUSEX(); statusEx.setValues(); double newVal = 0; //double newVal = Convert.ToDouble(MEMORYSTATUSEX.graphMemory); //Console.WriteLine(statusEx.dwMemoryLoad.ToString()); //chart1.Series["Series1"].Points.AddXY(timeStamp, newVal); if (ptSeries.Points.Count > 0) { newVal = ptSeries.Points[ptSeries.Points.Count - 1].YValues[0] + Convert.ToDouble(MEMORYSTATUSEX.graphMemory); } if (newVal < 0) { newVal = 0; } ptSeries.Points.AddXY(timeStamp.ToOADate(), Convert.ToDouble(MEMORYSTATUSEX.graphMemory)); double removeBefore = timeStamp.AddSeconds((double)(90) * (-1)).ToOADate(); while (ptSeries.Points[0].XValue < removeBefore) { ptSeries.Points.RemoveAt(0); } chart1.ChartAreas[0].AxisX.Minimum = ptSeries.Points[0].XValue; chart1.ChartAreas[0].AxisX.Maximum = DateTime.FromOADate(ptSeries.Points[0].XValue).AddMinutes(2).ToOADate(); chart1.Invalidate(); }