Skip to content

In the docker container, oshi gets cpu information will be blocked #2019

Closed

Description

@conghuhu

image
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.
image

After testing, it is possible to obtain memory information and obtain jvm information, and hope to get a reply.

Activity

  1. dbwiddis commented on Apr 23, 2022

    @dbwiddis
    Member

    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 /proc directory?

  2. conghuhu commented on Apr 23, 2022

    @conghuhu
    Author
  3. dbwiddis commented on Apr 23, 2022

    @dbwiddis
    Member

    Can you see the contents of /proc/stat from inside the container?

  4. dbwiddis commented on Apr 23, 2022

    @dbwiddis
    Member

    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.

  5. dbwiddis commented on May 14, 2022

    @dbwiddis
    Member

    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.

  6. conghuhu commented on May 15, 2022

    @conghuhu
    Author
  7. added
    containers
    on Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    containers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions