Search code examples
c++unixperformancetraffic-measurement

Tutorial for multi core CPU usage in c++ in unix


I would like to know if someone can point me any library or tutorial to work with measurements. In a first moment, CPU usage, but latter I will need network (I've already found libcap, is this good?) and memory usages also.

I believe that each of then will be a different library or project, so thanks in advance.

I am currently working in a database monitoring system for UNIX system, in C++.

PS.: is there a way to access the htop programmatically from c++?

Pedro


Solution

  • Look into the /proc filesystem. It contains a bunch of plain-text files with system statistics. /proc/stat has cpu info, and /proc/net/* has network info.

    Additionally, /proc/<pid>/* contains information about a specific process.