OpenVZ VE monitoring commands

Posted: 2p in Virtuozzo

Lists the top ten containers based on cpu usage

/usr/sbin/vzstat -t -s cpu|awk ‘NF==10{print $0}’|head

OR

/usr/sbin/vzlist -o ctid,hostname,ip,laverage|awk ‘BEGIN{MAX=10} {split($2,arr,”/”); if( (int(arr[1])>MAX) || (int(arr[2])>MAX) || (int(arr[3])>MAX) )print $0}’

OR

for i in `/usr/sbin/vzlist -H -o ctid`; do echo “CTID: ${i} `/usr/sbin/vzctl exec ${i} cat /proc/loadavg`”; done

2) List out all containers for which the status is not in “OK” status. This is quite helpful while troubleshooting load issues when the load average in the node is super-high(above 1000)

/usr/sbin/vzstat -t|awk ‘{if(NF==10 && $2!=”OK” && $1!=”CTID”)print $0}’

3) Lists the top ten containers based on socket usage
/usr/sbin/vzstat -t -s sock|awk ‘NF==10{print $0}’|head

4) Lists the top 10 containers based on number of processes running inside the container.
/usr/sbin/vzlist -H -o ctid,numproc|sort -r -n -k2|head

5) Lists the top 10 containers based on TCP sender buffer usage,
/usr/sbin/vzlist -H -o ctid,tcpsndbuf |sort -r -n -k2|head

6) Lists the top 10 containers based on TCP receive buffer usage,
/usr/sbin/vzlist -H -o ctid,tcprcvbuf |sort -r -n -k2|head

7) Sorts containers based on the highest inbound traffic(quite useful while troubleshooting n/w related attacks),
/usr/sbin/vznetstat -r |awk ‘$3 ~ /G/ {print $0}’|sort -r -nk3

8) Sorts containers based on the highest oubound traffic(quite useful while troubleshooting n/w related attacks) ,
/usr/sbin/vznetstat -r |awk ‘$5 ~ /G/ {print $0}’|sort -r -nk5

9) List out containers with resource shortage

dmesg|egrep -v ‘(SMTP-LOG|INPUT-DROP|LIMIT-PPS-DROP|FORWARD-DROP)’
TTL=64 ID=0 PROTO=UDP SPT=68 DPT=67 LEN=556

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s