6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

LinuxでCPU使用率を取得する(top)

6
Posted at

窓OSのタスクマネージャーにあるCPU使用率みたいなものが必要になったので簡単(適当)なスクリプトをメモ程度に書いときます。

スクリプト

# !/bin/sh
CPU=`top -n 2 -b -d 1 | grep ^Cpu | tail -n 1`
IFS=','
set -- $CPU
echo $1 | sed -e "s/\Cpu(s):  //" | sed -e "s/\Cpu(s): //" |sed -e "s/\%us//"

出力結果

# sh cpu.sh 
20.1

間違えてたらごめんなさい。

6
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?