CPU % - procfs - system

What it does

This metric provider calculates an estimate of the % total CPU usage based of the system based on the /proc/stat file.

Classname

  • CpuUtilizationProcfsSystemProvider

Metric Name

  • cpu_utilization_procfs_system

Input Parameters

  • args
    • -i: interval in milliseconds

By default the measurement interval is 1000 ms.

./metric-provider-binary -i 100

Output

This metric provider prints to Stdout a continuous stream of data. The format of the data is as follows:

TIMESTAMP READING

Where:

  • TIMESTAMP: Unix timestamp, in microseconds
  • READING: The estimated % CPU used

Any errors are printed to Stderr.

How it works

The provider reads the aggregate cpu line of the /proc/stat file. CPU Utilization is calcuated as:

user_time+nice_time+system_time / user_time+nice_time+system_time+idle_time+iowait_time+irq_time+softirq_time

Only user, nice and system are counted as compute time. idle, iowait, irq and softirq are all counted as non-compute time. This differs from htop, which counts irq and softirq as busy and was changed to align with the cgroup reporters which do also not include irq times in their compute time.

steal is not read at all. It is zero on non-virtualized systems, and in a virtualized environment we make the case that this is time spent outside of the system we are looking at, so it is not work this reporter should capture.

Since we want the output as a ratio that can be expressed as an integer, we multiply with 10000.