Skip to content

Instantly share code, notes, and snippets.

@kedazo
Last active September 20, 2018 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kedazo/3ce417be59cd8304142e63dd9c1f6002 to your computer and use it in GitHub Desktop.
Save kedazo/3ce417be59cd8304142e63dd9c1f6002 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# A command to show the cmon process threads, note any cmon running
# inside containers will be skipped.
#
IFS='
'
CMONPIDS=`pgrep cmon`
SELECTED=''
for APID in ${CMONPIDS}; do
if grep cpuset /proc/$APID/cgroup | grep lxc >/dev/null 2>/dev/null; then
# skip cmon-s in container
continue
fi
if [ `cat /proc/$APID/comm` != "cmon" ]; then
# only match if command name is exactly "cmon"
continue
fi
SELECTED=${APID}
break;
done
if [ "${SELECTED}x" == "x" ]; then
echo "No cmon found (NOTE: containers were skipped)."
exit 1
fi
top -H -p ${SELECTED}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment