Is there a FUB or I/O datapoint to read the cpu usage

Hello everyone,

is there a way to get the current CPU usage as a variable in the AS? In the SDM it is always there, but I can’t find any FUB or I/O datapoint that gives me the CPU usage inside my AS.

Thank you

Hi Markus,

I think that the LogIdleShow function block from the AsArProf library should give you the information you need.

Thank you Marcus, that’s it! It’s the same value as the SDM gives me :+1:

But still it seems a bit strange for me, that there is no datapoint available for the CPU usage. For the temperature there is; you can even configure its datatype. But not for the usage.
For me this is an important info. If I want to figure out if a CPU is capable of running an application or not I need this value. And on smaller CPUs (like X20CP13x1) just opening the SDM increases the usage by ~10%.
So, LogIdleShow I will definitely use in every project now


Great, I’m glad it works for you!

I think the reason why it’s not available as a CPU datapoint is that it’s not something the CPU can measure in the same way as temperature. The idle time is based on all of the tasks that are running at a given time. Idle time is the terminology given to time during which cyclic tasks are not running (when tasks don’t take the entire time allocated to a cyclic task class) or for the time which is specifically allocated as Idle time in the CPU configuration. This time is then used for other things (online communication to Automation Studio for example). So the CPU is still working, it’s just not running one of your cyclic tasks. It’s not an instantaneous value either. The allocation of CPU resources has to be measured over some time interval and then the time which the CPU was “idle” can be calculated as a percentage.

That totally makes sense.
Just out of curiosity: how does the SDM calculate the CPU usage? And is this calculation always running when you enable the SDM or just if you actively open the System page?

How does the SDM calculate the CPU usage?

This I don’t know for sure. I imagine it uses a similar function in the backend, but maybe someone else who knows more is able to chime in here.

And is this calculation always running when you enable the SDM or just if you actively open the System page

The SDM gives you historical CPU Usage data which exists for time intervals when the browser window is closed. This makes me think that the calculation is always running. Though I don’t think this is an extra calculation per se. The CPU usage can be calculated from the Profiler data, and I do think that there is always some form of a Profiler task running on the target whether or not you configure a trace.

1 Like


only for some additional information:
even if I can’t prove it, I’m pretty sure that LogIdleShow() and SDM utilize the same underlying system functions for measuring the idle time. And I agree to Marcus, that SDM has to measure all the time (even if the web page isn’t loaded) to provide historical data.

The reason why SDM consumes some CPU time is less because of the idle time measurement, but more because of the “cyclic data transfer” between the browser and the SDM cgi interface functions (and of course the work that has to be done on server side to deliver data from the AR system to the cgi functions).

In SDM, the’re also some “legacy” static HTML-based pages integrated, which don’t do cyclic data exchange with the browser; therefore, they aren’t updated when shown without performing a reload … and yes, they don’t look as nice as the SVG-based SDM, but sometimes those pages can be used for “only having a quick look into the system” without consuming some processing time as long as the page is loaded inside the browser.

But I think it’s also good to know, that SDM itself has a much lower priority inside the AR system then for example the task classes and the IO systems.
And since AR is a priority-based multitasking system that means: even if SDM is running, it can’t consume time that is needed by higher priority tasks (user tasks, but also system tasks).

Best regards!