|
I want to write a program in C# that should display all services memory usage which is running on particular application server using C#.net.
modified 9-Jul-15 2:56am.
|
|
|
|
|
In which case start by looking at WMI, you can get the WMICodeCreator from Miscrosoft site which will let you select WMI Objects, view them and their properties and write the code to do the same that you can cut and paste into your application.
For instance:
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_Service");
ManagementObjectSearcher procsearcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_Process");
String q;
foreach (ManagementObject queryObj in searcher.Get())
{
if (queryObj["ProcessId"].ToString() != "0")
{
Console.WriteLine("-----------------------------------");
q = "SELECT * FROM Win32_Process WHERE ProcessId=";
q += queryObj["ProcessId"].ToString();
procsearcher.Query = new System.Management.ObjectQuery(q);
foreach (ManagementObject ProcObj in procsearcher.Get())
{
Console.WriteLine("Name: {0} : {1}", queryObj["Name"], ProcObj["WorkingSetSize"]);
}
}
}
}
catch (ManagementException e)
{
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
}
}
}
}
You can also get the ProcessId which will be non-zero if the service is running, using the ProcessId you can query WMI to get the process information.
Updated the code to get the memory for running Services.
modified 9-Jul-15 5:39am.
|
|
|
|
|
i just run your code. Some error came (The type or namespace name 'ManagementObjectSearcher' could not be found). i want to get All Services memory usage running on Application Server in local system using C#.
How to achieve this.
Please reply me.
|
|
|
|
|
Did you add system.management and system.management.instrumentation as references to your project?
From Project menu select Add Reference, in the resulting dialogue click the .Net tab and scroll to locate the System.Management and add it to your project, same again for .Instrumentation.
FYI. I updated the code in previous reply to get the memory for the process as well.
|
|
|
|
|
Hi,
I added the reference and is working.
[Workingsetsize] means usage memory size or allocated size and this will be for checking in local system no.
If i want to check the memory usage of services which are running in Application server from my local system, how can i achieve.
how to specify app server from my local system through this code and get memory usage of services of that app server.
Please reply me.
|
|
|
|
|
Hi,
how to specify app server IP and service name (If possible) from my local system through this code and get memory usage of services of that app server.
How to achieve this.
Please reply me.
|
|
|
|
|
|
Repeating your question isn't going to get you any faster help. When you encounter an error like this, a quick Google search is enough to find out which DLL you need to reference.
|
|
|
|
|
I added the reference and is working.
[Workingsetsize] means usage memory size or allocated size and this will be for checking in local system no.
If i want to check the memory usage of services which are running in Application server from my local system, how can i achieve.
how to specify app server from my local system through this code and get memory usage of services of that app server.
Please reply me.
|
|
|
|
|
Look here
[^]
Learn to use Google.
|
|
|
|
|
kindly i want image slider in Asp.Net application in simple way so if any one know simple way please share to me.
|
|
|
|
|
First try Google, then the CodeProject ASP.NET articles, then maybe the correct forum[^].
|
|
|
|
|
have already googled but could not find much
|
|
|
|
|
raghvendra_tsar wrote: have already googled but could not find much
I would suggest that you improve your search skills. My search for "ASP.NET image slider" returned more than 2 million results. A lot more than "not much".
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
|
|
|
|
|
first when i inherited a form from Office2007Form -nameed basefrom set the shortcut,and then inherited from baseform,the shortcut does't work, Can you help me?
|
|
|
|
|
We need a lot more details. I don't follow what you're saying.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I am trying to check input from a .NET BASIC input form. Is using reg-edit over engineering my solution? I am using [^A-Z, 0-9] to block out bad inputs, Is this too much?
|
|
|
|
|
You mean regex (regular expression) I'm sure...
No. It is not too much. In a lot of cases checking input with regex the best way (fast and simple), the only thing you have to take care of is to write the write expression...
In your case, the expression tells to pass only chars that are not uppercase Latin letters (A-Z), not comma (,), not space ( ) and not numeric (0-9)...It sounds to me strange, so check it...
Here a nice visual tool to see what expression you are building: http://regexper.com/[^]
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Using Regex is not over-engineering.
Most scripting / programming languages allow regex.
|
|
|
|
|
I am facing Problem in integrating R language with asp.net web application.Currently I am using R.Net but it is using DCOM so its not proper executing in multiple instances of web browser.Please provide a solution
|
|
|
|
|
Quoting from https://rdotnet.codeplex.com/[^]:
Quote: Known Issues
There are persisting issues running R.NET from an ASP.NET application. The exact cause remains unclear, but this may be a inherent limitation of the R native engine with respect to thread safety. Doesn't sound to me like an issue that could be resolved with a forum post.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
i have been working on multiple file upload control in angular Js and web Api. in my case when user uploads image . i will convert it to byte array and on submit i will post it to the web api.the problem is its working well when image size is less than 800KB above that it makes the whole entity null
|
|
|
|
|
|
How can we help?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi plz who can help me, i am trying to use datagridview rows as cheched and the make updated the checked columns in to Emptable
itryed as flows:
For i As Integer = 0 To DataGridView1.Rows.Count - 1
While DataGridView1.Rows(0).Cells("Select").Value = True
sql = "update tbl_EmpDetails set Approval='" & x &"' where eid='"& DataGridView1.Rows(i).Cells(1).Value &"'"
cmd = New SqlClient.SqlCommand(sql, conn)
cmd.ExecuteNonQuery()
End While
Next
|
|
|
|