All Projects → v-zhuravlev → Zbx Smartctl

v-zhuravlev / Zbx Smartctl

Licence: gpl-3.0
Templates and scripts for monitoring disks health with Zabbix and smartmontools

Programming Languages

perl
6916 projects

Projects that are alternatives of or similar to Zbx Smartctl

Zabbixapi
Ruby wrapper to Zabbix API
Stars: ✭ 128 (-37.86%)
Mutual labels:  zabbix
Zapix
Online Zabbix API tool - test and develope Zabbix API queries in the browser
Stars: ✭ 157 (-23.79%)
Mutual labels:  zabbix
Thola
Tool for monitoring and provisioning network devices (mainly using SNMP) - monitoring check plugin
Stars: ✭ 179 (-13.11%)
Mutual labels:  zabbix
Zabbix Notify
Notify alarms from Zabbix to Slack Hipchat and PagerDuty
Stars: ✭ 139 (-32.52%)
Mutual labels:  zabbix
Libzbxpgsql
Monitor PostgreSQL with Zabbix
Stars: ✭ 150 (-27.18%)
Mutual labels:  zabbix
Zabbix Haproxy
HAProxy Zabbix Discovery and Template
Stars: ✭ 169 (-17.96%)
Mutual labels:  zabbix
Ara Archive
This repository is an historical archive of https://github.com/dmsimard/ara, please use https://github.com/openstack/ara instead.
Stars: ✭ 121 (-41.26%)
Mutual labels:  ansible-playbook
Zabbix
Zabbix Plugin
Stars: ✭ 195 (-5.34%)
Mutual labels:  zabbix
Matrix Docker Ansible Deploy
Matrix (An open network for secure, decentralized communication) server setup using Ansible and Docker
Stars: ✭ 2,541 (+1133.5%)
Mutual labels:  ansible-playbook
Zorka
Sophisticated monitoring agent for Java
Stars: ✭ 178 (-13.59%)
Mutual labels:  zabbix
Zabbix Cli
Command-line interface for Zabbix
Stars: ✭ 141 (-31.55%)
Mutual labels:  zabbix
Opssam
opsSAM运维平台 (基于saltstack、cobbler和zabbix接口的集成管理)
Stars: ✭ 143 (-30.58%)
Mutual labels:  zabbix
Dellemc Openmanage Ansible Modules
Dell EMC OpenManage Ansible Modules
Stars: ✭ 169 (-17.96%)
Mutual labels:  ansible-playbook
Barn
Ansible playbooks for Laravel applications
Stars: ✭ 129 (-37.38%)
Mutual labels:  ansible-playbook
Wgcloud
linux运维监控工具,支持系统信息,内存,cpu,温度,磁盘空间及IO,硬盘smart,系统负载,网络流量等监控,API接口,大屏展示,拓扑图,进程监控,端口监控,docker监控,文件防篡改,日志监控,数据可视化,web ssh,堡垒机,指令下发批量执行,linux面板,探针,故障告警
Stars: ✭ 2,669 (+1195.63%)
Mutual labels:  zabbix
Grafana Zabbix
Zabbix plugin for Grafana dashboard
Stars: ✭ 1,716 (+733.01%)
Mutual labels:  zabbix
Https Ssl Cert Check Zabbix
Script to check validity and expiration of TLS/SSL certificate on site. May be used with Zabbix or standalone.
Stars: ✭ 162 (-21.36%)
Mutual labels:  zabbix
Django Oms
加强版运维系统,集成工单、发布、监控、管理dns、saltstack
Stars: ✭ 201 (-2.43%)
Mutual labels:  zabbix
Zabbix manager
🍀 (1)安装后一键设置 (2)日常管理工具 (3)一键导出常用报表 (4)Zabbix API 二次开发
Stars: ✭ 192 (-6.8%)
Mutual labels:  zabbix
Graylog Ansible Role
Ansible role which installs and configures Graylog
Stars: ✭ 173 (-16.02%)
Mutual labels:  ansible-playbook

zbx-smartctl

Description

This is the template and discovery scripts for monitoring disks SMART attributes using smartmontools in Zabbix.
Zabbix server 3.4+ is recommended with dependendent items support but there are also older templates for 3.2, 3.0, 2.4, 2.2 provided as is. Discovery scripts should work with them too.

Main features

  • Supports SATA, SAS and NVMe devices
  • Disks discovery:
    • Two discovery scripts - for Linux/BSD/MacOS and Windows
    • Simple discovery in MacOS by scanning /dev/disk/* (macos)
    • Discover with smartctl --scan-open (nix, windows)
    • Discover NVMe devices with smartctl --scan-open -dnvme (nix, windows)
    • Discover Hardware RAID with sg_scan (nix only)
    • Discover NVMe devices with nvme-cli (nix only)
    • Handling usbjmicron (nix only)
    • Handling Areca SATA RAID (nix only)
    • Try to enable SMART if it is disabled(nix, macos, windows)
    • (new) static discovery (nix only)
    • HDD(0), SSD/NVMe(1), other(2) classification in {#DISKTYPE} macro (nix, macos, windows)
    • LLD macros in output: {#DISKNAME}, {#DISKCMD}, {#DISKTYPE}, {#DISKMODEL}, {#DISKSN}. {#SMART_ENABLED} (nix, macos, windows)
  • Templates:
    • For all templates:
      • Zabbix agent required with UserParameter
      • LLD discovery of disks
      • 'Problems first' approach. Collect items that can help to detect disk failures
      • Skip disks if SMART_ENABLED != 1
      • SATA devices support
    • 3.4+ template:
      • Two discovery rules: for HDD and SSD/NVMe to reduce the number of unsupported
      • Server side regex parsing, so, very simple UserParameters in agent configs
      • No excessive calls to disks. Collect all items in the single smartctl run
      • SAS devices support
      • NVMe devices support
      • Static discovery support with {$SMARTCTL_STATIC_DISKS}

About static discovery

Static discovery is useful for disks that cannot be easily discovered, such as disks hidden behind some hardware RAIDs or when agent is installed on Windows or Mac where automatic discovery is not so powerful.

{$SMARTCTL_STATIC_DISKS} - If some disks cannot be discovered automatically no matter how hard you try, you can add additional disks with -d option in this macro on the host level. Such disks will be discovered in addition to any disks that will be discovered with smartctl --scan-open, sg_scan and so on.

Replace all spaces with _ inside each disk command. Separate multiple disks with space ' '. For example, to discover 2 drives behind hardware RAID, set this macro on the host level:

{$SMARTCTL_STATIC_DISKS} = /dev/sda_-d_sat+megaraid,00 /dev/sda_-d_sat+megaraid,01

Installation

Linux/BSD/Mac OSX

  • Make sure that smartmontools package is installed
  • (optional) Install sg3-utils if you need to monitor hardware RAIDs. See #29
  • (optional) Install nvme-cli if you need to monitor NVMe devices.
  • Copy the following contents of sudoers_zabbix_smartctl file to /etc/sudoers.d/sudoers_zabbix_smartctl:
Cmnd_Alias SMARTCTL = /usr/sbin/smartctl
Cmnd_Alias SMARTCTL_DISCOVERY = /etc/zabbix/scripts/smartctl-disks-discovery.pl
zabbix ALL= (ALL) NOPASSWD: SMARTCTL, SMARTCTL_DISCOVERY
Defaults!SMARTCTL !logfile, !syslog, !pam_session
Defaults!SMARTCTL_DISCOVERY !logfile, !syslog, !pam_session
chmod 440 /etc/sudoers.d/sudoers_zabbix_smartctl
  • Copy zabbix_smartctl.conf to /etc/zabbix/zabbix_agentd.d
  • Copy script smartctl-disks-discovery.pl to /etc/zabbix/scripts
    • Then run
chown zabbix:zabbix /etc/zabbix/scripts/smartctl-disks-discovery.pl
chmod u+x /etc/zabbix/scripts/smartctl-disks-discovery.pl
  • Test the discovery script by running it as sudo. You should receive JSON object in the script output.
  • Restart zabbix-agent

Building deb package

You can create .deb package zabbix-agent-extra-smartctl for Debian/Ubuntu distributions:

dpkg-buildpackage -tc -Zgzip

Ansible Role

There is an ansible role available in this repo, feel free to try it. To build the role run create_ansible_role.sh script then copy ansible-role-zabbix-smartctl to your ansible/roles directory

Windows

  • Install smartmontools, prefer default installation path
  • Install Zabbix agent using official MSI package, prefer default installation path
  • Copy script smartctl-disks-discovery.ps1 to Zabbix Agent folder
  • Copy file zabbix_smartctl.win.conf to Zabbix Agent\zabbix_agentd.conf.d folder
    • Check that path to smartmontools bin folder and to discovery script smartctl-disks-discovery.ps1 are correct
  • Restart Zabbix Agent service
  • Test items
    • Test discovery and retrieval of disks data:
PS C:\Program Files\Zabbix Agent> .\zabbix_agentd.exe -c .\zabbix_agentd.conf -t uHDD.discovery
uHDD.discovery                                [t|{
 "data":[
         {
                "{#DISKSN}":"ZZZZZZZZZZZZ",
                "{#DISKMODEL}":"THNSN5512GPUK TOSHIBA",
                "{#DISKNAME}":"/dev/sda",
                "{#DISKCMD}":"/dev/sda -dnvme",
                "{#SMART_ENABLED}":"0",
                "{#DISKTYPE}":"1"
         }
 ]
}]
PS C:\Program Files\Zabbix Agent> .\zabbix_agentd.exe -c .\zabbix_agentd.conf -t uHDD.get["/dev/sda -d nvme"]
uHDD.get[/dev/nvme1]                          [t|smartctl 6.6 2017-11-05 r4594 [x86_64-w64-mingw32-w10-b17134] (sf-6.6-1)..DISK OUTPUT HERE.....]

Examples

Items in 3.4: image Catch SSD problems in Zabbix 2.4: image

Contributing

Please keep in mind key concepts when submitting a PR:

  • The template should work with Windows, Linux, MacOS.

  • Discovery scripts should not have any dependencies (apart from smartctl)

  • Discovery scripts should deduplicate disks (using serial number as unique id)

  • Discovery scripts should output the following set of macros:

    • {#DISKSN} - Disk serial number
    • {#DISKMODEL} - Disk model
    • {#DISKNAME} - Disk name you would like to use in item name
    • {#DISKCMD} - System disk name with -d param to be used in running smartctl
    • {#SMART_ENABLED} - 1 or 0
    • {#DISKTYPE} - 0 - HDD, 1 - SSD/NVMe, 2 - Other(ODD etc)

    To make sure that the sources of these macro is available everywhere, it is best to use output of smartctl -i or smartctl --scan-open. Other macros may be added, but try to edit both windows and nix scripts at the same time.

Please also keep in mind things that require improvement (welcome!)

  • Absolute paths used(especially in Windows(UserParameters,inside powershell script))
  • Discovery script should probably fail if not run under Admin/root(since its impossible to collect proper data)
  • usbjmicron is not implemented in Windows, only in Linux discovery script
  • There are no proper tests. It's nice to run discovery scripts automatically using /tests/examples directory contents as mocks. So it's easier to accept PRs. BTW you can also PR your outputs to examples folder
  • MacOS disks discovery is very limited. Feel free to improve it.

Troubleshooting

  1. SELinux. Turn it off or add a selinux policy:
yum install policycoreutils-python
semanage permissive -a zabbix_agent_t
semodule -DB
# from zabbox_server issue:
zabbix_get -s host -k uHDD.discovery
zabbix_get -s host -k uHDD.get[/dev/sda]

cat /var/log/audit/audit.log | grep zabbix_agent_t | grep denied | audit2allow -M zabbix_smartctl
semodule -i zabbix_smartctl.pp
semanage permissive -d zabbix_agent_t
semodule -B

License

GPL v3 or newer.

More info

http://habrahabr.ru/company/zabbix/blog/196218/
http://www.lanana.org/docs/device-list/devices-2.6+.txt
https://www.smartmontools.org/wiki/Supported_RAID-Controllers
https://www.percona.com/blog/2017/02/09/using-nvme-command-line-tools-to-check-nvme-flash-health/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].