[shell] Monitor CPU or Memory

Posted buptqq

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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 ">>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

以上是关于[shell] Monitor CPU or Memory的主要内容,如果未能解决你的问题,请参考以下文章