NSClient++ Help (#1) - How average of CPU load is done (#791) - Message List

How average of CPU load is done

Hello,

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 ?

Thanks. Samuel Mutel.

  • Message #2164

    Sort of like this...

    poller:

    char *buffer = new char[buffer_size];
    ...
    while (...) {
    	buffer[i++] = get_current_value();
    ...
    }
    

    Get value function:

    double sum = 0;
    for (int i=0;i<time;i++)
    	sum += buffer[i];
    return sum/time;
    

    (ish)

    • Message #2165

      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 ?

      • Message #2166

        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

Subscriptions