[shell] Monitor CPU or Memory

#!/bin/bash

startT=`date +%Y-%m-%dT%H:%M:%S`
echo "TIMESTAMP CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS\n">>mem.$startT.txt
jmeterContainerID=$(docker ps | grep "adspop" | awk ‘{print $1}‘)
while true
do
    timestamp=`date +%Y-%m-%dT%H:%M:%S`
    dockerinfo=`docker stats --no-stream $jmeterContainerID | grep -v CONTAINER`
    echo "$timestamp $dockerinfo" >>mem.$startT.txt
    sleep 60
done

相关推荐