2017年12月24日日曜日

温度管理(lm-sensors)(sagittarius)

続いて、sagittarius で lm-sensors と xsensors を導入する。

やり方は全く一緒だ。
$ sudo apt-get --simulate install lm-sensors
$ sudo apt-get install lm-sensors

lm-sensors の設定を作成
$ sudo sensors-detect
# sensors-detect revision 6284 (2015-05-31 14:00:33 +0200)
# Board: ASUSTeK COMPUTER INC. Z170 PRO GAMING
# Kernel: 4.4.0-104-generic x86_64
# Processor: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (6/94/3)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): (そのままエンター)
Module cpuid loaded successfully.
Silicon Integrated Systems SIS5595... No
VIA VT82C686 Integrated Sensors... No
VIA VT8231 Integrated Sensors... No
AMD K8 thermal sensors... No
AMD Family 10h thermal sensors... No
AMD Family 11h thermal sensors... No
AMD Family 12h and 14h thermal sensors... No
AMD Family 15h thermal sensors... No
AMD Family 16h thermal sensors... No
AMD Family 15h power sensors... No
AMD Family 16h power sensors... No
Intel digital thermal sensor... Success!
(driver `coretemp')
Intel AMB FB-DIMM thermal sensor... No
Intel 5500/5520/X58 thermal sensor... No
VIA C7 thermal sensor... No
VIA Nano thermal sensor... No

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no): (そのままエンター)
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor/ITE'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... No
Trying family `ITE'... No
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor/ITE'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... No
Trying family `ITE'... No

Some systems (mainly servers) implement IPMI, a set of common interfaces
through which system health data may be retrieved, amongst other things.
We first try to get the information from SMBIOS. If we don't find it
there, we have to read from arbitrary I/O ports to probe for such
interfaces. This is normally safe. Do you want to scan for IPMI
interfaces? (YES/no): (そのままエンター)
Probing for `IPMI BMC KCS' at 0xca0... No
Probing for `IPMI BMC SMIC' at 0xca8... No

Some hardware monitoring chips are accessible through the ISA I/O ports.
We have to write to arbitrary I/O ports to probe them. This is usually
safe though. Yes, you do have ISA I/O ports even if you do not have any
ISA slots! Do you want to scan the ISA I/O ports? (YES/no): (そのままエンター)
Probing for `National Semiconductor LM78' at 0x290... No
Probing for `National Semiconductor LM79' at 0x290... No
Probing for `Winbond W83781D' at 0x290... No
Probing for `Winbond W83782D' at 0x290... No

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no): (そのままエンター)
Found unknown SMBus adapter 8086:a123 at 0000:00:1f.4.
Sorry, no supported PCI bus adapters found.

Next adapter: i915 gmbus dpc (i2c-0)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)

Next adapter: i915 gmbus dpb (i2c-1)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)

Next adapter: i915 gmbus dpd (i2c-2)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)

Next adapter: DPDDC-D (i2c-3)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)

Next adapter: DPDDC-E (i2c-4)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)


Now follows a summary of the probes I have just done.
Just press ENTER to continue: (そのままエンター)

Driver `coretemp':
* Chip `Intel digital thermal sensor' (confidence: 9)

To load everything that is needed, add this to /etc/modules:
#----cut here----
# Chip drivers
coretemp
#----cut here----
If you have some drivers built into your kernel, the list above will
contain too many modules. Skip the appropriate ones!

Do you want to add these lines automatically to /etc/modules? (yes/NO) (そのままエンター)

Unloading cpuid... OK

ありゃ…、coretemp 以外の対応ドライバーが見つからなかったっぽいな。
これでドコまで見られるのだろうか…。

実行してみよう。
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +119.0°C)
temp2: +29.8°C (crit = +119.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +20.0°C (high = +84.0°C, crit = +100.0°C)
Core 0: +16.0°C (high = +84.0°C, crit = +100.0°C)
Core 1: +19.0°C (high = +84.0°C, crit = +100.0°C)
Core 2: +16.0°C (high = +84.0°C, crit = +100.0°C)
Core 3: +16.0°C (high = +84.0°C, crit = +100.0°C)

asus-isa-0000
Adapter: ISA adapter
cpu_fan: 0 RPM

う~ん。ちょっと温度表記数が少ないかな…。

ちょっと気になったので、先程の sensors-detect で「Do you want to scan it?」の質問のところを、全て yes で答えたが、結果は変わらずだった。
CPUの温度項目しか見られないのね。

続いて、 xsensors を導入。
$ sudo apt-get install xsensors

動かしてみる。
$ xsensors &

表示はされたけど、項目数は少ない。
まぁ、CPUの温度が分かるだけでもいいか…。

2017年12月22日金曜日

温度管理(lm-sensors)(aquarius)

ココで仮想マシン pegasus がクラッシュするのが、H/W障害か?と書いた。
メモリが壊れたかと思って、一応memtestしかけてみたんだけど、特に問題は見つからず。

となると、単に I/O 負荷が上がって CPU 無応答時間が発生→強制再起動、ということが想定される。
が、そこまでチェックする前に、そもそも熱が大丈夫か確認してみたい。

というわけで、温度を確認するツールを入れてみる。
まずは aquarius から。
$ sudo apt-get --simulate install lm-sensors
$ sudo apt-get install lm-sensors

次はどうやら構成ファイルを作成するようだ。
色々聞かれるから、基本的にはデフォルトでエンター。
$ sudo sensors-detect
# sensors-detect revision 6284 (2015-05-31 14:00:33 +0200)
# System:   []
# Board: Intel Corporation NUC5i7RYB
# Kernel: 4.4.0-104-generic x86_64
# Processor: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz (6/61/4)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): (そのままエンター)
Module cpuid loaded successfully.
Silicon Integrated Systems SIS5595... No
VIA VT82C686 Integrated Sensors... No
VIA VT8231 Integrated Sensors... No
AMD K8 thermal sensors... No
AMD Family 10h thermal sensors... No
AMD Family 11h thermal sensors... No
AMD Family 12h and 14h thermal sensors... No
AMD Family 15h thermal sensors... No
AMD Family 16h thermal sensors... No
AMD Family 15h power sensors... No
AMD Family 16h power sensors... No
Intel digital thermal sensor... Success!
(driver `coretemp')
Intel AMB FB-DIMM thermal sensor... No
Intel 5500/5520/X58 thermal sensor... No
VIA C7 thermal sensor... No
VIA Nano thermal sensor... No

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no): (そのままエンター)
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor/ITE'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... No
Trying family `ITE'... No
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor/ITE'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... Yes
Found `Nuvoton NCT5573D/NCT5577D/NCT6776F Super IO Sensors' Success!
(address 0xa00, driver `nct6775')

Some systems (mainly servers) implement IPMI, a set of common interfaces
through which system health data may be retrieved, amongst other things.
We first try to get the information from SMBIOS. If we don't find it
there, we have to read from arbitrary I/O ports to probe for such
interfaces. This is normally safe. Do you want to scan for IPMI
interfaces? (YES/no): (そのままエンター)
Probing for `IPMI BMC KCS' at 0xca0... No
Probing for `IPMI BMC SMIC' at 0xca8... No

Some hardware monitoring chips are accessible through the ISA I/O ports.
We have to write to arbitrary I/O ports to probe them. This is usually
safe though. Yes, you do have ISA I/O ports even if you do not have any
ISA slots! Do you want to scan the ISA I/O ports? (yes/NO): (そのままエンター)

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no): (そのままエンター)
Found unknown SMBus adapter 8086:9ca2 at 0000:00:1f.3.
Sorry, no supported PCI bus adapters found.

Next adapter: i915 gmbus vga (i2c-0)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)

Next adapter: i915 gmbus dpc (i2c-1)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)

Next adapter: i915 gmbus dpb (i2c-2)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)

Next adapter: i915 gmbus dpd (i2c-3)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)

Next adapter: DPDDC-C (i2c-4)
Do you want to scan it? (yes/NO/selectively): (そのままエンター)

Now follows a summary of the probes I have just done.
Just press ENTER to continue: (そのままエンター)

Driver `nct6775':
* ISA bus, address 0xa00
Chip `Nuvoton NCT5573D/NCT5577D/NCT6776F Super IO Sensors' (confidence: 9)

Driver `coretemp':
* Chip `Intel digital thermal sensor' (confidence: 9)

To load everything that is needed, add this to /etc/modules:
#----cut here----
# Chip drivers
coretemp
nct6775
#----cut here----
If you have some drivers built into your kernel, the list above will
contain too many modules. Skip the appropriate ones!

Do you want to add these lines automatically to /etc/modules? (yes/NO) (そのままエンター)

Unloading cpuid... OK

これでいいのかな?何か、/etc/modules に「coretemp と nct6775 を入れろ」って言われてるけど…。

とりあえず動かしてみる。
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +110.0°C)
temp2: +29.8°C (crit = +110.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +35.0°C (high = +105.0°C, crit = +105.0°C)
Core 0: +34.0°C (high = +105.0°C, crit = +105.0°C)
Core 1: +33.0°C (high = +105.0°C, crit = +105.0°C)

う~ん、これで良いのだろうか…?

lsmod を見てみると、 coretemp というカーネルモジュールは導入されているっぽいので、 nct6775 というカーネルモジュールを入れてみようかな…。
$ lsmod > lsmod.before
$ sudo modprobe nct6775
$ lsmod > lsmod.after
$ diff -c lsmod.before lsmod.after
*** lsmod.before 2017-12-22 15:36:48.274393335 +0900
--- lsmod.after 2017-12-22 15:37:00.374274890 +0900
***************
*** 1,4 ****
--- 1,6 ----
Module Size Used by
+ nct6775 57344 0
+ hwmon_vid 16384 1 nct6775
vhost_net 20480 0
vhost 32768 1 vhost_net
macvtap 20480 1 vhost_net

nct6775 を使うために、hwmon_vid というカーネルモジュールも一緒にロードされたな…。
sensors の出力結果に何か変化はあるか…?
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +110.0°C)
temp2: +29.8°C (crit = +110.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +35.0°C (high = +105.0°C, crit = +105.0°C)
Core 0: +34.0°C (high = +105.0°C, crit = +105.0°C)
Core 1: +34.0°C (high = +105.0°C, crit = +105.0°C)

nct6776-isa-0a00
Adapter: ISA adapter
Vcore: +1.88 V (min = +0.00 V, max = +1.74 V) ALARM
in1: +1.36 V (min = +0.00 V, max = +0.00 V) ALARM
AVCC: +3.36 V (min = +0.00 V, max = +0.00 V) ALARM
+3.3V: +3.36 V (min = +0.00 V, max = +0.00 V) ALARM
in4: +1.02 V (min = +0.00 V, max = +0.00 V) ALARM
in5: +0.00 V (min = +0.00 V, max = +0.00 V)
in6: +0.26 V (min = +0.00 V, max = +0.00 V) ALARM
3VSB: +3.34 V (min = +0.00 V, max = +0.00 V) ALARM
Vbat: +3.20 V (min = +0.00 V, max = +0.00 V) ALARM
fan1: 0 RPM (min = 0 RPM)
fan2: 3435 RPM (min = 0 RPM)
SYSTIN: +65.0°C (high = +0.0°C, hyst = +0.0°C) ALARM sensor = thermistor
CPUTIN: +30.5°C (high = +80.0°C, hyst = +75.0°C) sensor = CPU diode
AUXTIN: +32.5°C (high = +80.0°C, hyst = +75.0°C) sensor = CPU diode
PCH_CHIP_CPU_MAX_TEMP: +34.0°C (high = +80.0°C, hyst = +75.0°C)
PECI Agent 0: +34.0°C (high = +80.0°C, hyst = +75.0°C)
(crit = +105.0°C)
PCH_CHIP_TEMP: +0.0°C
PCH_CPU_TEMP: +0.0°C
intrusion0: OK
intrusion1: OK
beep_enable: disabled

びっくりした!しっかり出てきたよ…。

これを X で見るためのツールも導入してみよう。
$ sudo apt-get install xsensors

動くかな…?
$ xsensors &
動いた!画面イメージは以下の通り。
acpitzから出力される温度

coretempから出力される温度

nct6776から出力される温度

普通に動いている。
とりあえず後は、nct6776 というカーネルモジュールが、OS起動時に自動的に取り込まれるか…だな…。

というわけで再起動して確認してみる。
$ sudo systemctl reboot

リブート後、カーネルモジュールを確認してみる。
$ lsmod | grep nct6775
ありゃ、ロードされてないや。
ってことは、意図的にロードするように設定を組み込まないとアカンのね。

sensors-detect コマンドの出力結果では、 /etc/modules に記載しろ、とのことだったので、それを書いてみよう。
$ ls /etc/modules
$ cat /etc/modules
コメント行のみで存在しているので追記しよう。
$ sudo vi /etc/modules
--以下の行を追加
# Chip drivers
nct6775
--ココまで

これで再起動して再確認だな。
$ sudo systemctl daemon-reload
$ sudo systemctl reboot

起動してきたら確認。
$ lsmod | grep nct6775

ロードされているので、温度見てみよう。
$ sensors

nct6775 の方の温度も表示されたなら、xsensors も見てみる。
$ xsensors &

問題なく見れた。

次回は、同じ作業を sagittarius に適用したい。
ただ、ハードウェア構成が違から、カーネルモジュールも違うはずなので、次回に同じように記載する。

2017年12月21日木曜日

故障かなぁ?

今の家の環境、2台のマシン(sagittarius / aquarius)を常時稼働させ、その上で仮想マシンを動かしてる。
仮想マシンの1つに Windows7 がいて、主に sagittairus 上で動かしている。
この仮装マシン、ちょくちょくリモートデスクトップ接続して操作している。
ところがどうもこの仮想マシン、不定期にパニックリブート起こしているようで。
もしかしたら、 sagittarius の H/W に問題抱えているかも、ということで、Windows7 を aquarius 側に移して動かしてみた。
今のところ問題は起きていない。

というわけで、近いうちに sagittarius 上で memtest86 を流して、メモリ障害が起きてないか調べておこう…。

メモリ故障起こしてたら、新しいメモリに買い直さないといかのか…金が…。

2017年12月20日水曜日

systemdの設定ファイルの場所

ココで、「編集したはずのopenvswitchの起動ファイルが元に戻っている」と書いたけど、原因は大したことなかった。

そもそも、 /lib/systemd/system/openvswitch-switch.service というファイルは openvswitch-switch というパッケージに含まれるファイルの1つだ。
裏で openvswitch-switch の自動アップデートが行われ、手作業で更新したファイルがアップデートによって上書きされたに過ぎない。
逆に言うと、どんなに頑張って /lib/systemd/system/openvswitch-switch.service をカスタマイズしても、アップデート一発で元に戻ってしまうわけだ。

となると、定義ファイルをカスタマイズしたい場合はどうすればいいんだろうか?
パッケージに付属しているファイルをカスタマイズするだけでなく、自分でローカルに作成した定義ファイルというのもありうる。
これらは、ユーザ用のディレクトリに置く必要があるわけで、通常ならそういったディレクトリがあるはずだ。

ちょっと調べてみる…。
どうやら、 systemd.unit の man ページにヒントがあるようだぞ。
$ man systemd.unit
システムモード(--system)とユーザモード(--user)ってのがあるようだけど、どうやら通常運用では気にする必要がない(システムモードを見ておけばいい)ようだ。(こちらは systemd の man より)
そして、システムモードでは以下の3つのディレクトリが意味があるようだ。
/etc/systemd/system/*
/run/systemd/system/*
/lib/systemd/system/*

3つ目の /lib/systemd/system/* はこれまでもチェックしていた通りで、パッケージのファイルが配置されるところ。
/run/systemd/system/* はマニュアル上は Runtime units と書かれている。
が、中身を見てみてもちょっと良くわからない。
今見てみたら、ssh でログインしたユーザのセッション毎にディレクトリが有り、その中に conf ファイルが存在している。
どうやら、ダイナミックに動くサービス関連がココに自動的に作成されるようだ。

そして /etc/systemd/system/* だ。
こちらが、ユーザカスタマイズした定義ファイルや、ユーザが独自に作成したサービスの起動定義ファイル等を配置するためのディレクトリのようだ。

そのため、今回のように「パッケージが用意している起動定義ファイルをちょこっとカスタマイズしたい」という場合は、パッケージが用意している /lib/systemd/system/* ファイルを /etc/systemd/system/ にコピーし、こちらをカスタマイズする、というのが正しい姿のようだ。

ちなみに、/lib/systemd/system/ と /etc/systemd/system/ の両方に同じファイル名の定義ファイルがあったら、/etc/systemd/system/ の方にあるファイルを優先して使うため、同一ファイル名で配置しても問題はない。

さっそく試してみよう。
ここまで、blogの通りに作っていた場合、aquarius / sagittarius ペアと、gemini / cancer ペアの合計4台で openvswitch の起動定義をカスタマイズしているはずだ。
それぞれのペア毎に実施して欲しい。
以下の例は、 aquarius で実施している想定で書いているが、他のマシンでも同じだ。

まずは openvswitch-switch のサービスが、どの .service ファイルから起動されているかを確認する。
$ systemctl --no-pager -l status openvswitch-switch
● openvswitch-switch.service - Open vSwitch
Loaded: loaded (/lib/systemd/system/openvswitch-switch.service; enabled; vendor preset: enabled)
Active: active (exited) since 金 2017-12-15 15:07:02 JST; 32min ago
Process: 1432 ExecStartPost=/bin/sleep 6 (code=exited, status=0/SUCCESS)
Process: 1377 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 1377 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CPU: 0
CGroup: /system.slice/openvswitch-switch.service

12月 15 15:06:56 cancer systemd[1]: Starting Open vSwitch...
12月 15 15:07:02 cancer systemd[1]: Started Open vSwitch.
/lib/system/system/openvswitch-switch.service ファイルを使用しているのが分かる。(下線部)

今使っているファイルを、/etc/systemd/system の下に移動しておく。
$ sudo mv -i /lib/systemd/system/openvswitch-switch.service \
/etc/systemd/system/openvswitch-switch.service

そしたら、過去にバックアップしておいたオリジナルファイルを、元の名前に戻しておく。
$ sudo mv -i /lib/systemd/system/openvswitch-switch.service.orig \
/lib/systemd/system/openvswitch-switch.service

オリジナルファイルと、ユーザカスタマイズファイルの存在を確認しておこう。
$ ls -l /lib/systemd/system/openvswitch-switch.service \
/etc/systemd/system/openvswitch-switch.service
(両方ともファイルが存在するはずだ)

オリジナルとユーザカスタマイズファイルの差分をチェックしておく。
$ diff -c /lib/systemd/system/openvswitch-switch.service \
/etc/systemd/system/openvswitch-switch.service
*** /lib/systemd/system/openvswitch-switch.service 2017-03-15 21:34:41.000000000 +0900
--- /etc/systemd/system/openvswitch-switch.service 2017-11-13 10:09:34.965702805 +0900
***************
*** 6,11 ****
--- 6,12 ----
[Service]
Type=oneshot
ExecStart=/bin/true
+ ExecStartPost=/bin/sleep 6
ExecStop=/bin/true
RemainAfterExit=yes
(ExecStartPost=/bin/sleep 6 の行が追加されているのが確認できる。)

設定を反映させて、/etc/systemd/system の方を使用するようになったか確認する。
$ sudo systemctl daemon-reload
$ systemctl --no-pager -l status openvswitch-switch
● openvswitch-switch.service - Open vSwitch
Loaded: loaded (/etc/systemd/system/openvswitch-switch.service; enabled; vendor preset: enabled)
Active: active (exited) since 金 2017-12-15 15:33:54 JST; 54min ago
Main PID: 1589 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/openvswitch-switch.service
(無事に /etc/systemd/system/openvswitch-switch.service の方に切り替わったっぽい。)

これで再起動してみる。(仮想マシンが動いていたら、予め停止しておくこと。)
$ sudo systemctl reboot

もし、dlm / corosync の起動がトラブったら、相方のノード側(aquarius に対して sagittarius等)から fencing されてる状態だと思う。(自分はそうだった)
ので、相方のノードで fencing を解除しておこう。

[sagittariusから]
$ sudo dlm_tool status
cluster nodeid 1084766082 quorate 1 ring seq 516 516 daemon now 402223 fence_pid 0 node 1084766082 M add 22 rem 0 fail 0 fence 0 at 0 0 node 1084766083 X add 23 rem 0 fail 0 fence 0 at 0 0
自分自身(sagittarius)の node id が 1084766082 のようなので、aquarius の node id は 1084766083 だ。
aquarius の node id に対して fencing を解除しておく。

$ sudo dlm_tool fence_ack 1084766083

[aquariusに戻って]
再び再起動して、corosync / dlm が正常に起動してくるのを確認する。
$ sudo systemctl reboot
$ systemctl --no-pager -l status dlm
$ systemctl --no-pager -l status corosync

再起動が終わったら、もう一度確認しておこう。
$ systemctl --no-pager -l status openvswitch-switch
/etc/systemd/system/openvswitch-switch.service の方を利用しているようなら無事に完了だ。
同じ手順を他のマシン上で実行して、openvswitch-switch の起動処理を /etc/systemd/system/ の方に移しておこう。

他にカスタマイズしている部分もあった気がするので、後日確認することにする。