LoginSignup
2
1

More than 5 years have passed since last update.

macOS マシンの CPU 温度変化を監視&通知する gem を作った

Posted at

これは何?

macOS マシン の CPU 温度変化を監視&通知する gem を作ったので、その紹介をします。gem の名前は Hotcorg です。

Hotcorg

https://rubygems.org/gems/hotcorg/
Hotcorg は CUI ツールです。以下、インストール方法と使い方を書きます。

インストール

$ gem install hotcorg

使い方

以下のコマンドを実行するとプロセスが起動して CPU 温度変化の監視が始まります (Ctrl+C で停止)。

$ hotcorg go

デフォルトでは、Hotcorg プロセスは5秒に1回のペースで CPU 温度を確認します。温度が1°Cでも上昇していた場合は、通知センターにて知らせます。また、50、60、70、80、90°C をそれぞれオーバした時点でも通知します。

notify_hotcorg.png

下記のオプションで温度確認の頻度や通知条件を指定することもできます。

  -g, [--granularity=N]            # Granularity for change in CPU temperature at which hotcorg should react [°C]
                                   # Default: 1
  -t, [--threthold=one two three]  
                                   # Default: [50, 60, 70, 80, 90]
  -i, [--interval=N]               # Interval when hotcorg checks CPU temperature change [Sec.]
                                   # Default: 5
  -c, [--command=COMMAND]          # Command to be executed each time hotcorg detects CPU temperature change
  -n, [--notify], [--no-notify]    # Whether hotcorg notifies CPU temperature change (supported only with macOS)
                                   # Default: true

また、'-c' オプションを使えば通知のタイミングで指定のコマンドを実行することも可能です。例えば下記のようにします。

$ hotcorg go -g 10 -t 70 80 90 -i 60 -c "echo 'hello'"

上記コマンドでは「CPU温度が10°C上昇した」または「70、80、90°Cをオーバーした」時点でHotcorgにより通知されます。また、通知のたびにecho 'hello'コマンドを実行します。

なぜこれを作ったの?

私は MacBookAir(13-inch, Mid 2012) を愛用しているのですが、重い処理をしてマシンが熱くなるとキーボードを叩く指にも熱が伝わります。長時間そのまま作業した結果、指先に軽い火傷を負ってしまいました。また、高熱はマシンの故障にもつながります。もちろんそういうときはファンが音を立てて回転してくれますが、作業に集中していると耳から入る情報をスルーしがちです。温度の変化を視覚的に通知してくれるツールがあれば、指先の火傷やマシンの故障を避けられるかも……と考えて Hotcorg を公開しました。この gem であなたの指先と愛用のマシンの健康を守る手助けができれば幸いです。

2
1
0

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
2
1