7 Sensor

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, called 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 sensor-detect and sensors tools (lm-sensors package: http://lm-sensors.org/). 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 sensor program the available sensors are separated by the bus type (ISA adapter, PCI adapter, SPI adapter, Virtual device, ACPI interface, HID adapter).

ב-Linux 2.4:

(קריאת החיישנים מתקבלות מספריית /proc/sys/dev/sensors)

  • התקן - שם ההתקן (אם נעשה שימוש ב-<mode>, הוא רגיל ביטוי);
  • חיישן - שם חיישן (אם נעשה שימוש ב-<mode>, זהו רגיל ביטוי);
  • מצב - ערכים אפשריים: avg, max, min (אם פרמטר זה הוא הושמט, המכשיר והחיישן מטופלים מילה במילה).

מפתח לדוגמה: חיישן[w83781d-i2c-0-2d,temp1]

לפני Zabbix 1.8.4, נעשה שימוש בפורמט החיישן[temp1].

ב-Linux 2.6+:

(קריאות חיישנים מתקבלות מספריית /sys/class/hwmon)

  • התקן - שם המכשיר (לא ביטוי רגולרי). שם המכשיר יכול להיות השם האמיתי של המכשיר (למשל 0000:00:18.3) או שם שנרכש באמצעות תוכנית חיישנים (למשל k8temp-pci-00c3). זה למעלה למשתמש לבחור באיזה שם להשתמש;
  • חיישן - שם חיישן (ביטוי לא רגולרי);
  • מצב - ערכים אפשריים: avg, max, min (אם פרמטר זה הוא הושמט, המכשיר והחיישן מטופלים מילה במילה).

מפתח לדוגמה:

חיישן[k8temp-pci-00c3,temp,max] או חיישן[0000:00:18.3,temp1]

חיישן[smsc47b397-isa-0880,in,avg] או חיישן[smsc47b397.2176,in1]

השגת שמות חיישנים

תוויות חיישנים, כפי שהודפסו על ידי הפקודה חיישנים, לא תמיד יכולות להיות בשימוש ישירות מכיוון ששמות התוויות עשויים להיות שונים עבור כל אחת מהן ספק שבבי חיישן. לדוגמה, פלט חיישנים עשוי להכיל את השורות הבאות:

 חיישני $
        in0: +2.24 וולט (מינימום = +0.00 וולט, מקסימום = +3.32 וולט)
        Vcore: +1.15 וולט (מינימום = +0.00 וולט, מקסימום = +2.99 וולט)
        +3.3V: +3.30 וולט (מינימום = +2.97 וולט, מקסימום = +3.63 וולט)
        +12V: +13.00 וולט (מינימום = +0.00 וולט, מקסימום = +15.94 וולט)
        טמפרטורת M/B: +30.0°C (נמוכה = -127.0°C, גבוהה = +127.0°C)

מתוך אלה, ניתן להשתמש בתווית אחת בלבד ישירות:

 $ 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 כדי אחזר את קריאות החיישן, הפעל חיישנים -u. בפלט, ה ניתן לראות את הדברים הבאים:

 חיישני $ -u
        ...
        Vcore:
          in1_input: 1.15
          תוך 1_דקה: 0.00
          in1_max: 2.99
          in1_alarm: 0.00
        ...
        +12V:
          in4_input: 13.00
          תוך 4_דקות: 0.00
          in4_max: 15.94
          in4_alarm: 0.00
        ...

אז Vcore צריך להיות שאילתה בתור in1, ו-+12V צריך להיות שאילתה בתור in4.1

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

לא רק מתח (in), אלא גם זרם (curr), טמפרטורה (טמפ') ו ניתן לאחזר קריאות מהירות מאוורר (מאוורר) על ידי Zabbix.


  1. לפי מפרט אלה הם מתחים על פיני שבב ובאופן כללי אולי צריך דֵרוּג.↩︎