i want to get memory usage of client through IP address.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • balach
    New Member
    • Sep 2008
    • 18

    i want to get memory usage of client through IP address.

    hi all;

    i am new in .NET and i am assigned work like this.

    my question is that, 3 clients are connected wtih server on LAN, i want to get the cpu usage and physical memory usage of one client on another client,
    i more specify my questin that, i have IP address 10.15.24.10 and the IP of my friend is 10.15.24.30, from my system i just pass IP Address of my friend's system and i get cpu usage and physical memory usage of my friend.

    please tell me is it possible by using any method ?? and please also demonstrate in little detail what process should i follow, this problem will be solved by using desktop application or web based app.

    please......... ...... give me idea about its development.

    regards
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    take a look at this thread:
    thread

    For remote computers you need to supply username and password along with IP/computername

    Code:
    ConnectionOptions con = new ConnectionOptions();
    
                con.Username = "";
                con.Password = "";
    
                ManagementScope scope = new ManagementScope(
                "\\\\ComputerName\\root\\cimv2", con);
                scope.Connect();
    
                ObjectQuery que = new ObjectQuery(
                "SELECT * FROM Win32_OperatingSystem");
            
                ManagementObjectSearcher searcher = 
                new ManagementObjectSearcher(scope,que);
    
           
                ManagementObjectCollection querys = searcher.Get();
            
                foreach (ManagementObject m in querys)
            
                {
                    string s = Convert.ToString(m["FreePhysicalMemory"]).Trim();
                    s = Convert.ToString(m["FreeVirtualMemory"]).Trim();
                    s = Convert.ToString(m["TotalVirtualMemorySize"]).Trim();
                    s = Convert.ToString(m["TotalVisibleMemorySize"]).Trim();
            
                }

    Comment

    • PRR
      Recognized Expert Contributor
      • Dec 2007
      • 750

      #3
      Do add a reference to System.Manageme nt;

      For more info google : WMI (windows management instrumentation )
      Also look for a wmi tool in msdn...

      Comment

      • balach
        New Member
        • Sep 2008
        • 18

        #4
        thanks alot ''Dirtbag" for answer but, when i give the IP address(10.15.2 4.30) of my friend's computer in "management scope" as like in code below to check my friend's memory usage at that specific time, then it gives error that" RPC server is not connected or not responding" i think that it is an exception that is fired, and i am unaware to handle this exception to fulfil my requirement that is named as the title of this thread.

        i shall be thankful if you could resolve this problem, or any other forum member who could help me.

        Code:
        ConnectionOptions con = new ConnectionOptions(); 
        con.Username = ""; 
        con.Password = ""; 
        
        ManagementScope scope = new ManagementScope( "\\\\10.15.24.30\\root\\cimv2", con); 
        
        //Here comes error on executing below line, that RPC server is not responding
        
        scope.Connect();
        regards

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Originally posted by balach
          when i give the IP address(10.15.2 4.30) of my friend's computer in "management scope" as like in code below to check my friend's memory usage at that specific time, then it gives error that" RPC server is not connected or not responding"
          WMI calls are blocked by firewalls in general (security), so if your friend is on another network, or is otherwise blocked by a firewall, you will not be able to make the connection. You also need to be able to supply valid user credentials to get into the system, and the user must have rights to use WMI on the system.

          I would look up the WMICodeCreator tool, it's pretty helpfull in building WMI calls (it will write code for you)

          Comment

          • jg007
            Contributor
            • Mar 2008
            • 283

            #6
            you will need to also have admin access the other PC and access to the RPC share and , to check if you have access try connecting to the other computer using computer managment and see it that works

            ( right click 'my computer' , select manager , click on 'action ' then connect to another computer .

            also it is not something that is easy to do using XP home and really needs you to have XP Pro so that you can set up the permissions okay

            also look at hamatchi if your friends pc is not on the same network as you.

            Comment

            • balach
              New Member
              • Sep 2008
              • 18

              #7
              thanks for answers, but unfortunately problem is still there, i have checked all of the scenarios delivered by "jg007" and "plater" with this additional scenario, as given at this url

              Even this url has also not solved my problem

              my program is still giving this error "The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"
              this error is generated on this line of code
              scope.Connect() ;

              i request for some other possible issues that i must check regarding this problem.

              Comment

              • jg007
                Contributor
                • Mar 2008
                • 283

                #8
                please can you advise what happens when you try to connect using computer manager and also if you are able to connect to the other pc by accessing the c$ share on it

                to access C$ share go to run and enter below replacing the ip add bit with whatever the remote machine is-

                \\<IP ADDRESS>\c$

                Comment

                • Plater
                  Recognized Expert Expert
                  • Apr 2007
                  • 7872

                  #9
                  I would guess that one or BOTH of you have the RPC services turned off then?
                  There is
                  Remote Procedure Call (RPC)
                  and
                  Remote Procedure Call (RPC) Locator
                  services, which i think need to be running.

                  You should try to connect using the windows manager thing mentioned earlier and see what happens

                  Comment

                  • PRR
                    Recognized Expert Contributor
                    • Dec 2007
                    • 750

                    #10
                    check this out
                    MSDN
                    See This too
                    see

                    As Plater pointed out u need..(especial ly if u are startin or stoppin services)

                    "Remote Procedure Call (RPC)
                    and
                    Remote Procedure Call (RPC) Locator
                    services, which i think need to be running."


                    ConnectionOptio ns con = new ConnectionOptio ns();
                    con.Username = ""; // You need to provide administrator name
                    con.Password = ""; // and password... cant be blank for remote PC..
                    Without proper username n password u wont be able to connect( also the username should have admin or wmi rights on the remote PC)...
                    Although WMI calls are blocked by default .... for querying information that should not be a problem...if i remember correctly i had issues tryin to shutdown remote pc... gettin remote information was OK as long as windows firewall was off...

                    Comment

                    • balach
                      New Member
                      • Sep 2008
                      • 18

                      #11
                      thank you very much to all, giving me best possible cases for accessing remote system's information, but i do not wnat to do any configuration on remote system, as mentioned in the last post, sent by "DeepBlue".

                      here, what i desire, without doing any configuration on remote system, by using any method of c#.NET, how do i get remote System information as like CPU usage, Memory Usage of remote system.


                      thanks in advace for answers and coding.
                      GOD BLESS ALL OF YOU

                      Comment

                      • jg007
                        Contributor
                        • Mar 2008
                        • 283

                        #12
                        if you do not have permission to access the RPC on the other system you wil NOT be able to find out this information.

                        please confirm what happens when you try as above to connect to the c$ share or computer manager as this will diagnose further to see if it is just your program or if you do not have the access that you need to do what you want to do

                        Comment

                        Working...