A script to monitor the disk performance with Zabbix.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
599 B

#!/usr/bin/env python3
import json
import os
import re
disk_id_path = "/dev/disk/by-id/"
dev_re = re.compile(r'^.*(ata|scsi)+(?!.*?part).*$')
dm_re = re.compile(r'^dm-name-(.*)$')
data = []
for name in os.listdir(disk_id_path):
dev_match = dev_re.match(name)
dm_match = dm_re.match(name)
if dev_match:
real_dev = os.path.realpath(disk_id_path + dev_match.group(0)).split('/')[2]
if real_dev != "sr0":
data.append({"{#DEVICENAME}": real_dev})
elif dm_match:
data.append({"{#DEVICENAME}": dm_match.group(1)})
print(json.dumps({ "data": data }))