You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
In the docker container, oshi gets cpu information will be blocked #2019
My springboot application is deployed in a docker container. Calling the cpu api as shown in the figure below cannot obtain information, and it will be blocked all the time, as shown in the above figure.
After testing, it is possible to obtain memory information and obtain jvm information, and hope to get a reply.
Docker is deployed on centos, and the base image of the container is openjdk:8-jre-alpine.
The project is a springboot, so should I change the base image in the dockerfile to centos or ubuntu?
Thank you again.
There is not enough information in your post for me to diagnose the problem.
The top image appears to show a synchronization thread triggering every 5 seconds, and two log messages from an attempt to get CPU information, with only the first of the two log messages shown
This implies the CPU information thread is terminating somewhere in the code snippet shown
The only possibility inside the thread would be a hang/delay/error executing getSystemCpuLoadTicks()
The code for this on Linux simply reads the contents of /proc/stat and parses it
The other possibility is that the thread is being terminated from outside by the application, possibly due to the internal 1000 ms delay in your code
Suggestion: don't use code with an internal delay. Just return the raw tick values to your springboot application and do the usage calculations there.
Heh @conghuhu, haven't heard back from you so I'm going to assume this is resolved and close this issue.
I researched enough to know that springboot does include default timeouts and it's not waiting for you do delay as long as you do before responding to the query. As mentioned in the previous comment, you should immediately return the raw tick values, and your base application should compare them to an older returned set to do the calculation.
Feel free to reopen this issue if you need more help.
Activity
dbwiddis commentedon Apr 23, 2022
Which operating system is the container running on?
Does the container have access to procfs or have an alternate in-container location for the equivalent of the
/procdirectory?conghuhu commentedon Apr 23, 2022
dbwiddis commentedon Apr 23, 2022
Can you see the contents of
/proc/statfrom inside the container?dbwiddis commentedon Apr 23, 2022
There is not enough information in your post for me to diagnose the problem.
getSystemCpuLoadTicks()/proc/statand parses itSuggestion: don't use code with an internal delay. Just return the raw tick values to your springboot application and do the usage calculations there.
dbwiddis commentedon May 14, 2022
Heh @conghuhu, haven't heard back from you so I'm going to assume this is resolved and close this issue.
I researched enough to know that springboot does include default timeouts and it's not waiting for you do delay as long as you do before responding to the query. As mentioned in the previous comment, you should immediately return the raw tick values, and your base application should compare them to an older returned set to do the calculation.
Feel free to reopen this issue if you need more help.
conghuhu commentedon May 15, 2022