v-zhuravlev / zbx-smartctl

Templates and scripts for monitoring disks health with Zabbix and smartmontools
https://share.zabbix.com/storage-devices/smartmontools/smart-monitoring-with-smartmontools-lld
GNU General Public License v3.0
245 stars 127 forks source link

SSD/HDD different LLD #36

Closed v-zhuravlev closed 6 years ago

v-zhuravlev commented 7 years ago

"Под Linux, оказывается, можно всего одной командой определить какой диск - SSD или HDD:

Linux automatically detects SSD, and since kernel version 2.6.29, you may verify sda with: cat /sys/block/sda/queue/rotational You should get 1 for hard disks and 0 for a SSD.

То есть, можно добавить в perl-script еще одну проверку с всего одной командой, вывод которой даст определение типа диска - 1 или 0.

Далее добавить еще один RegExp "DISK_TYPE". Если он - "1", то ничего делать не надо. Если он "0" и имеем дело с SSD, то надо делать еще одно Правило обнаружения с элементами данных под SSD. Там самое главное - это 231-й параметр вывода smartctl, который и показывает "Здоровье диска". Из остальных параметров можно оставить 5, 9, 194 (надо редактировать), инвентарные данные, а так же Test Result. Все остальное не актуально для SSD.

Вот только, насколько я знаю, несколько RegExp в Правилах обнаружения Zabbix умеет в версии 3+. На 2.2 и 2.4 придется играться с глобальными регулярками, и писать правила туда. Для HDD это будет "SMART_ENABLED = 1 и DISK_TYPE = 1", для SSD - "SMART_ENABLED = 1 и DISK_TYPE = 0"

В общем, все можно красиво реализовать. И было бы просто потрясающе сделать модернизацию шаблона.

Спасибо! :)"

vazhnov commented 7 years ago

As I know, 231 is not for any SSD manufactures:

Do you know another types?

v-zhuravlev commented 7 years ago

Samsung - 177

v-zhuravlev commented 7 years ago

"Corsair with SandForce — 231 SSD_Life_Left, Crucial with Micron — 173 Ave_Block-Erase_Count, 202 Percent_Lifetime_Used"

do those have 233? Do you have example output you can share for those disks?

ferreol commented 6 years ago

Because having the same rules for HDD and SSD I had errors in server logs with specific SMART attributes types missing for the other.

I filtered them with:

Then I modified the LLD to have 3 rules, 1 generic, 1 with SSD specific attributes, 1 with HDD specific attributes.

I had to duplicates the master items because you cannot have a dependent item for SSD that depends on master item from generic discovery rules for instance. Had to break trigger depency too.

v-zhuravlev commented 6 years ago

added #DISKTYPE https://github.com/v-zhuravlev/zbx-smartctl/pull/59 macro with values 0 -HHD, 1-SSD, 0-Other. this now can be used for separate discovery rules. Not sure whether it should be separated though in the templates stored here.