How average of CPU load is done

Forums NSClient++ support How average of CPU load is done

This topic contains 3 replies, has 2 voices, and was last updated by  Michael Medin 3 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #2065


    I want to know if someone know how the average is calculated for the check CPU Load.

    A buffer is filled with CPU information every 1/10s.
    If you ask NSClient to retrieve average for 5min, 10min and 60min, how it works ?

    Samuel Mutel.


    Michael Medin

    Sort of like this…

    char *buffer = new char[buffer_size];

    while (…) {
    buffer[i++] = get_current_value();

    Get value function:
    double sum = 0;
    for (int i=0;i sum += buffer[i];
    return sum/time;



    Can you explain with an example, please ?

    With time = 5m, time = 60m ?
    The buffer is cleared between check ? Or it’s more like a FIFO ?


    Michael Medin

    LOL, and here I though I was beeing clear…

    Well, lets try like this.
    There is a round buffer. Every 10 seconds the CPU load is read and a value is pushed on the “round buffer”. (hence this is always the last X readings).

    When you poll it goes through all reading in the time frame and caluclates the average of them.

    So there is no reset or anything like that…

    // Michael Medin

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.