Monitoring CPU Usage in Linux (Need to integrate it with C#)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gskbond
    New Member
    • Oct 2009
    • 18

    Monitoring CPU Usage in Linux (Need to integrate it with C#)

    Hello,

    I have a driver program in C# which uses performance counters for windows to get perf stats (CPU Usage) for windows.

    But for linux there is no known method in C# or .NET using which you can monitor CPU Usage of remote or local unix system.

    I wanted to know that is there any way to achieve this in linux and get performance data in C#. (May be a web service running on Linux and C# program calling web service)?

    Can anybody give me any pointer regarding this problem?
  • vinot85
    New Member
    • Aug 2007
    • 53

    #2
    Vinoth

    First of all, You need to prepare a web service in the Linux machine Language of choice can be Java.

    From the java webservice, you could read the CPU performance parameters by using System class. Or, write a C program to measure the CPU parameters and call the same through JNDI.

    Finally, deploy the webservice and access it from you C# application on windows machine.

    Comment

    • iohos
      Banned
      New Member
      • Jul 2010
      • 45

      #3
      Have you tried using the Top program for viewing the CPU utilization? The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
      The top command monitors CPU utilization, process statistics, and memory utilization. The top section contains information related to overall system status - uptime, load average, process counts, CPU status, and utilization statistics for both memory and swap space.

      Comment

      • Jyoti Ballabh
        Banned
        New Member
        • Jul 2010
        • 115

        #4
        If you have a package called sysstat installed in your system then you could take advantage of -

        # apt-gel install sysstat

        replace it with the up2date command if you are using the Red Hat Linux version or the RHEL

        # up2date sysstat

        Then there is the mpstat command which displays activities for each available processor, processor 0 being the first one. Global average activities among all processors are also reported. The mpstat command can be used both on SMP and UP machines, but in the latter, only global average activities will be printed.

        Comment

        • ashitpro
          Recognized Expert Contributor
          • Aug 2007
          • 542

          #5
          You can implement webservice.

          Or

          try using telnet from C# application to remote linux box, and execute any of the command suggested by other users.

          Then gather the out put and parse it according to your need.

          Comment

          Working...