Run the following command to calculate the currently used memory (megabytes) in openshift container platform 4.x.
oc adm top node | awk '{ sum+=$4} END {print sum}'
Run the following command to calculate the used memory (megabytes) for worker nodes in the cluster.
oc adm top node --selector='node-role.kubernetes.io/worker=' | awk '{ sum+=$4} END {print sum}'
Calculate the total memory (megabytes) assigned to all the nodes in the cluster.
for n in $(oc get node -o name); do node_cpu=$(oc get $n -o jsonpath='{.status.capacity.memory}'| awk '{ print substr( $0, 1, length($0)-2 ) }'); ((tot_cpu+=node_cpu)); done; echo $(($tot_cpu / 1024)) ; ((tot_cpu=0))
Calculate the total memory assigned to the worker nodes in the cluster (megabytes).
for n in $(oc get node --selector='node-role.kubernetes.io/worker=' -o name); do node_cpu=$(oc get $n -o jsonpath='{.status.capacity.memory}'| awk '{ print substr( $0, 1, length($0)-2 ) }'); ((tot_cpu+=node_cpu)); done; echo $(($tot_cpu / 1024)) ; ((tot_cpu=0))