How do I run top and ps commands when in a container without standard Linux tools
Issue
- Container images such as
jboss-webserver-5/jws56-openjdk11-openshift-rhel8andjboss-eap-7/eap74-openjdk11-openshift-rhel8, which are based onubi8, do not haveprocps-ngpackage as follows:
[lab@master ~]$ oc rsh <mw-pod-name>
sh-4.4$ top -b -n 1 -H -p <java-pid>
sh: top: command not found
sh-4.4$ ps
sh: ps: command not found
- CPU metrics such as
container_cpu_user_seconds_totalandcontainer_cpu_system_seconds_totalas cAdvisor metrics are collected by OpenShift Monitoring, but these metrics are in units of containers, and no cpu-usage metrics per thread in cAdvisor. - Scraping interval of cpu utilization that can be referred in OpenShift monitoring stack is
30seconds, but I need to check cpu utilization at finer intervals to identify burst load for a couple of seconds - How do I identify high CPU utilization by Java threads on OCP?
Environment
- Red Hat OpenShift Container Platform (OCP)
- 4.x
- 3.x
- Middleware containers based on ubi8
- "Distroless" containers
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.