これは開発版のドキュメントを表示しています。内容が不完全な場合があります。
このページには自動翻訳されたコンテンツが含まれています。 誤りを見つけた場合は、その箇所を選択して Ctrl+Enter を押し、編集者に報告してください。

6 センサー

各センサーチップは、sysfs /sys/devices ツリー内に独自のディレクトリを持ちます。 すべてのセンサーチップを見つけるには、/sys/class/hwmon/hwmon* からデバイスのシンボリックリンクをたどる方が簡単です(*は実際の番号(0,1,2,...))。

センサーの読み取り値は、仮想デバイスの場合は /sys/class/hwmon/hwmon*/ ディレクトリ、非仮想デバイスの場合は /sys/class/hwmon/hwmon*/device ディレクトリにあります。hwmon* または hwmon*/device ディレクトリ内にある name というファイルには、チップの名前が含まれており、これはセンサーチップで使用されるカーネルドライバーの名前に対応しています。

ファイルごとに1つのセンサー読み取り値のみが含まれます。上記のいずれかのディレクトリ内でセンサー読み取り値を含むファイルの一般的な命名規則は次のとおりです: <type><number>_<item>、ここで

  • type - センサーチップの場合は "in"(電圧)、"temp"(温度)、"fan"(ファン)など
  • item - "input"(測定値)、"max"(上限値)、"min"(下限値)など
  • number - 複数存在する可能性のある要素には常に使用されます(通常は1から始まりますが、電圧の場合は0から始まります)。ファイルが特定の要素を参照していない場合は、番号のない単純な名前になります。

ホストで利用可能なセンサーに関する情報は、sensor-detect および sensors ツール(lm-sensors パッケージ:http://lm-sensors.org/)を使用して取得できます。Sensors-detect は、利用可能なセンサーに必要なモジュールを特定するのに役立ちます。モジュールがロードされると、sensors プログラムを使用してすべてのセンサーチップの読み取り値を表示できます。このプログラムで使用されるセンサー読み取り値のラベル付けは、一般的な命名規則(<type><number>_<item>)とは異なる場合があります:

  • <type><number>_label というファイルがある場合は、このファイル内のラベルが <type><number><item> 名の代わりに使用されます
  • <type><number>_label ファイルがない場合は、/etc/sensors.conf(/etc/sensors3.conf など、異なる場合もあり)内で名前の置換を検索します

このラベル付けにより、ユーザーはどのようなハードウェアが使用されているかを特定できます。<type><number>_label ファイルも設定ファイル内のラベルもない場合は、name 属性(hwmon*/device/name)によってハードウェアの種類を特定できます。zabbix_agent が受け付けるセンサーの実際の名前は、sensors プログラムを -u パラメータ(sensors -u)で実行することで取得できます。

sensor プログラムでは、利用可能なセンサーはバスタイプ(ISAアダプタ、PCIアダプタ、SPIアダプタ、仮想デバイス、ACPIインターフェース、HIDアダプタ)ごとに区切られています。

Overview

Each sensor chip gets its own directory in the sysfs /sys/devices tree. To find all sensor chips, it is easier to follow the device symlinks from /sys/class/hwmon/hwmon*, where * is a real number (0,1,2,...).

The sensor readings are located either in /sys/class/hwmon/hwmon*/ directory for virtual devices, or in /sys/class/hwmon/hwmon*/device directory for non-virtual devices. A file, named name, located inside hwmon* or hwmon*/device directories contains the name of the chip, which corresponds to the name of the kernel driver used by the sensor chip.

There is only one sensor reading value per file. The common scheme for naming the files that contain sensor readings inside any of the directories mentioned above is: <type><number>_<item>, where

  • type - for sensor chips is "in" (voltage), "temp" (temperature), "fan" (fan), etc.
  • item - "input" (measured value), "max" (high threshold), "min" (low threshold), etc.
  • number - always used for elements that can be present more than once (usually starts from 1, except for voltages which start from 0). If files do not refer to a specific element they have a simple name with no number.

The information regarding sensors available on the host can be acquired using sensors-detect and sensors tools (lm-sensors package). Sensors-detect helps to determine which modules are necessary for available sensors. When modules are loaded the sensors program can be used to show the readings of all sensor chips. The labeling of sensor readings, used by this program, can be different from the common naming scheme (<type><number>_<item> ):

  • if there is a file called <type><number>_label, then the label inside this file will be used instead of <type><number><item> name;
  • if there is no <type><number>_label file, then the program searches inside the /etc/sensors.conf (could be also /etc/sensors3.conf, or different) for the name substitution.

This labeling allows user to determine what kind of hardware is used. If there is neither <type><number>_label file nor label inside the configuration file the type of hardware can be determined by the name attribute (hwmon*/device/name). The actual names of sensors, which zabbix_agent accepts, can be obtained by running sensors program with -u parameter (sensors -u).

In the sensors program the available sensors are separated by the bus type (ISA adapter, PCI adapter, SPI adapter, Virtual device, ACPI interface, HID adapter).

センサー名の取得

sensors コマンドで表示されるセンサーラベルは、各センサーチップベンダーごとにラベルの命名が異なる場合があるため、必ずしも直接使用できるとは限りません。例えば、sensors の出力には以下のような行が含まれている場合があります。

$ sensors
       in0:         +2.24 V  (min =  +0.00 V, max =  +3.32 V)   
       Vcore:       +1.15 V  (min =  +0.00 V, max =  +2.99 V)   
       +3.3V:       +3.30 V  (min =  +2.97 V, max =  +3.63 V)   
       +12V:       +13.00 V  (min =  +0.00 V, max = +15.94 V)
       M/B Temp:    +30.0°C  (low  = -127.0°C, high = +127.0°C)

このうち、直接使用できるラベルは1つだけです。

$ zabbix_get -s 127.0.0.1 -k sensor[lm85-i2c-0-2e,in0]
       2.240000

他のラベル(Vcore+12V など)を使用しようとしても動作しません。

$ zabbix_get -s 127.0.0.1 -k sensor[lm85-i2c-0-2e,Vcore]
       ZBX_NOTSUPPORTED

Zabbixがセンサー値を取得するために使用できる実際のセンサー名を調べるには、sensors -u を実行します。出力には以下のような内容が表示されます。

$ sensors -u
       ...
       Vcore:
         in1_input: 1.15
         in1_min: 0.00
         in1_max: 2.99
         in1_alarm: 0.00
       ...    
       +12V:
         in4_input: 13.00
         in4_min: 0.00
         in4_max: 15.94
         in4_alarm: 0.00
       ...

したがって、Vcorein1+12Vin4 として問い合わせる必要があります。仕様によると、これらはチップピンの電圧であり、一般的にはスケーリングが必要な場合があります。

$ zabbix_get -s 127.0.0.1 -k sensor[lm85-i2c-0-2e,in1]
       1.301000

Zabbixでは、電圧(in)だけでなく、電流(curr)、温度(temp)、ファン速度(fan)の値も取得できます。

Compatibility

Linux 2.4の場合:

(センサーの読み取り値は /proc/sys/dev/sensors ディレクトリから取得されます)

  • device - デバイス名(<mode>が使用されている場合は正規表現);
  • sensor - センサー名(<mode>が使用されている場合は正規表現);
  • mode - 可能な値: avg, max, min(このパラメータが省略された場合、deviceとsensorはそのまま扱われます)。

キーの例: sensor[w83781d-i2c-0-2d,temp1]

Linux 2.6以降の場合:

(センサーの読み取り値は/sys/class/hwmonディレクトリから取得されます)

  • device - デバイス名(非正規表現) デバイス名はデバイスの実際の名前(0000:00:18.3など)またはセンサープログラムを使用して取得した名前(k8temp-pci-00c3など)の場合があります。 使用する名前はユーザーが選択してください。
  • sensor - センサー名(非正規表現)
  • mode - 使用可能な値: avg, max, min (このパラメーターを省略した場合、デバイスとセンサーは逐語的に扱われます).

キーの例:

sensor[k8temp-pci-00c3,temp,max] or sensor[0000:00:18.3,temp1]

sensor[smsc47b397-isa-0880,in,avg] or sensor[smsc47b397.2176,in1]