Search code examples
c#ubuntuasp.net-corehealth-monitoring

Get Cross Platform System Health ASP.Net Core


I am developing an ASP.Net Core MVC Application where an administrator e.g. me should be able to see system information like:

  1. CPU usage by current process
  2. Total CPU usage
  3. Total System Memory available
  4. Total System Memory used by current application
  5. Total System Memory usage
  6. Total Disk space available
  7. Total Disk space used

After digging for hours I only found solutions using some Performance Counters or system queries. The problem being that most of them only work under Windows, but I need them to work on Linux, to be specific Ubuntu 18.10, to work as well.


Solution

  • You can just execute linux command line the relevant programs to gather these info. You can even create a shell script to collect all of these info with one execution, and return them in a format that you can process.

    The following commands should be enough to gather all the info.

    • ps -aux: per process cpu and memory consumption
    • free: overall memory consumption
    • df: overall disk consumption