add mdadm module

This commit is contained in:
Beu 2021-04-14 00:11:02 +02:00
parent 8e790628bb
commit b852bfe39a
3 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,13 @@
## What is the purpose of this template:
A simple template that detects and monitors software raids made with MDADM
## How to setup:
### On your servers :
copy the `userparameter_mdadm.conf` file in the directory "/etc/zabbix/zabbix_agentd.d/" and restart your zabbix agent
### On your Zabbix WebUI :
In "Configurations" -> "Templates", clic on the "Import" button and load the `Template Module MDADM.yaml` file

View File

@ -0,0 +1,108 @@
zabbix_export:
version: '5.2'
date: '2021-04-13T21:34:53Z'
groups:
-
name: Templates
-
name: Templates/Modules
templates:
-
template: 'Template Module MDADM'
name: 'Template Module MDADM'
description: 'A simple template that detects and monitors software raids made with MDADM'
groups:
-
name: Templates
-
name: Templates/Modules
applications:
-
name: MD
discovery_rules:
-
name: 'MDADM MD devices discovery'
key: md.discovery
delay: 12h
filter:
conditions:
-
macro: '{#MDNAME}'
value: '.*'
formulaid: A
item_prototypes:
-
name: 'MD $1 degraded'
key: 'md.degraded[{#MDNAME}]'
delay: 5m
description: 'Get number of degraded disks'
applications:
-
name: MD
preprocessing:
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
-
name: 'MD $1 raid disks'
key: 'md.raid_disks[{#MDNAME}]'
delay: 6h
description: 'Get number of all disks'
applications:
-
name: MD
preprocessing:
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1d
trigger_prototypes:
-
expression: '{diff()}>0'
name: 'MD {#MDNAME} number of disks changed on {HOST.NAME}'
priority: WARNING
-
name: 'MD $1 raid level'
key: 'md.raid_level[{#MDNAME}]'
delay: 24h
description: 'Get number of all disks'
applications:
-
name: MD
preprocessing:
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 2d
trigger_prototypes:
-
expression: '{change()}=1'
name: 'MD {#MDNAME} changed of level'
priority: INFO
-
name: 'MD $1 sync action'
key: 'md.sync_action[{#MDNAME}]'
delay: 5m
history: 365d
trends: '0'
value_type: TEXT
description: 'Get current sync action'
applications:
-
name: MD
preprocessing:
-
type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
trigger_prototypes:
-
expression: '{str(recover)}=1'
name: 'MD {#MDNAME} in recovery mode on {HOST.NAME}'
priority: INFO
trigger_prototypes:
-
expression: '{Template Module MDADM:md.degraded[{#MDNAME}].last()}>0 and {Template Module MDADM:md.raid_level[{#MDNAME}].last()}<>0'
name: 'MD {#MDNAME} is degraded on {HOST.NAME}'
priority: HIGH

View File

@ -0,0 +1,5 @@
UserParameter=md.discovery,ls /sys/class/block | awk 'BEGIN{printf "{\"data\":["}; /^md[0-9]+$/ {printf c"{\"{#MDNAME}\":\""$1"\"}";c=","}; END{print "]}"}'
UserParameter=md.degraded[*],cat /sys/block/$1/md/degraded 2>/dev/null || echo 1
UserParameter=md.sync_action[*],cat /sys/block/$1/md/sync_action
UserParameter=md.raid_disks[*],cat /sys/block/$1/md/raid_disks
UserParameter=md.raid_level[*],cat /sys/block/$1/md/level | sed 's/^raid//g'