Browse Source

Some changes:

* Removed python2 compatibility
* Clean up postinst
* Changed some file names to match the format of other zabbix-check packages
master
Sebastian 12 months ago
parent
commit
2f3e8af2df
Signed by: imo GPG Key ID: AFA10CBFE4391C0C
  1. 6
      README.md
  2. 8
      debian/changelog
  3. 2
      debian/compat
  4. 2
      debian/control
  5. 21
      debian/postinst
  6. 1
      debian/zabbix-check-disk-performance.examples
  7. 11
      debian/zabbix-check-disk-performance.install
  8. 4
      etc/zabbix/zabbix_agentd.d/zabbix-check-disk-performance.conf
  9. 0
      examples/zabbix-check-disk-performance.xml
  10. 10
      usr/lib/zabbix-check/bin/zabbix-check-disk-performance
  11. 13
      usr/lib/zabbix-check/bin/zabbix-check-disk-performance-discovery

6
README.md

@ -4,6 +4,8 @@
A script to monitor the disk performance with [Zabbix](https://zabbix.com).
**Note**: Version 1.0 dropped the python2 support. See branch [python2](https://github.com/zabbix-deb/zabbix-check-disk-performance/tree/python2) for the latest python2 compatible version.
## Usage
* Clone this repo and build the debian package yourself with `LANG=C debuild -us -uc -b; dh clean`
@ -14,7 +16,7 @@ A script to monitor the disk performance with [Zabbix](https://zabbix.com).
## Dependencies
* Python
* Python3
## Licence
@ -22,5 +24,5 @@ MIT License (see [debian/copyright](debian/copyright))
## Template for the Zabbix frontend
A template for the Zabbix frontend can be found, as usual in our packages, in [/usr/share/doc/${package_name}/](usr/share/doc/zabbix-check-disk-performance/)
A template for the Zabbix frontend can be found, as usual in our packages, in [/usr/share/doc/${package_name}/](examples/)

8
debian/changelog

@ -1,3 +1,11 @@
zabbix-check-disk-performance (1.0) focal; urgency=low
* Removed python2 compatibility
* Clean up postinst
* Changed some file names to match the format of other zabbix-check packages
-- Sebastian Huebner <sebastian@hueb-ner.de> Wed, 09 Dec 2020 14:33:43 +0100
zabbix-check-disk-performance (0.1~dev4) xenial; urgency=medium
* Add lisens

2
debian/compat

@ -1 +1 @@
7
9

2
debian/control

@ -6,7 +6,7 @@ Standards-Version: 3.8.4
Package: zabbix-check-disk-performance
Architecture: all
Depends: zabbix-agent (>=2.0), python
Depends: zabbix-agent (>=2.0), python3
Description: zabbix-agent disk-performance passiv check
This checks discover all devices and monitor
the performance of it.

21
debian/postinst

@ -20,30 +20,27 @@ set -e
case "$1" in
configure)
chmod -v +x /usr/lib/zabbix-check/bin/zabbix-check-disk-performance-get.py
chmod -v +x /usr/lib/zabbix-check/bin/zabbix-check-disk-performance-discover.py
#Bugfix: if dpkg-old in zabbix_agentd.d directory
if ls /etc/zabbix/zabbix_agentd.d/*.dpkg-old 1>/dev/null 2>/dev/null; then
mv -v /etc/zabbix/zabbix_agentd.d/*.dpkg-old /etc/zabbix/
fi
if ls /etc/zabbix/zabbix_agentd.d/*.dpkg-old 1>/dev/null 2>/dev/null; then
mv -v /etc/zabbix/zabbix_agentd.d/*.dpkg-old /etc/zabbix/
fi
if which invoke-rc.d >/dev/null 2>&1; then
if command -v systemctl >/dev/null 2>&1; then
systemctl restart zabbix-agent || true
elif command -v invoke-rc.d >/dev/null 2>&1; then
invoke-rc.d zabbix-agent stop || true
invoke-rc.d zabbix-agent start || true
else
/etc/init.d/zabbix-agent stop || true
/etc/init.d/zabbix-agent start || true
fi
;;
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
;;
esac

1
debian/zabbix-check-disk-performance.examples

@ -0,0 +1 @@
examples/zabbix-check-disk-performance.xml

11
debian/zabbix-check-disk-performance.install

@ -1,15 +1,10 @@
etc
etc/zabbix
etc/zabbix/zabbix_agentd.d
etc/zabbix/zabbix_agentd.d/userparameter_disk-performance.conf
etc/zabbix/zabbix_agentd.d/zabbix-check-disk-performance.conf
usr
usr/lib
usr/lib/zabbix-check
usr/lib/zabbix-check/bin
usr/lib/zabbix-check/bin/zabbix-check-disk-performance-discover.py
usr/lib/zabbix-check/bin/zabbix-check-disk-performance-get.py
usr/share
usr/share/doc
usr/share/doc/zabbix-check-disk-performance
usr/share/doc/zabbix-check-disk-performance/examples
usr/share/doc/zabbix-check-disk-performance/examples/zabbix-check-disk-performance.xml
usr/lib/zabbix-check/bin/zabbix-check-disk-performance-discovery
usr/lib/zabbix-check/bin/zabbix-check-disk-performance

4
etc/zabbix/zabbix_agentd.d/userparameter_disk-performance.conf → etc/zabbix/zabbix_agentd.d/zabbix-check-disk-performance.conf

@ -1,2 +1,2 @@
UserParameter=vfs.discover,/usr/lib/zabbix-check/bin/zabbix-check-disk-performance-discover.py
UserParameter=vfs.dev[*],/usr/lib/zabbix-check/bin/zabbix-check-disk-performance-get.py $1 $2
UserParameter=vfs.discover,/usr/lib/zabbix-check/bin/zabbix-check-disk-performance-discovery
UserParameter=vfs.dev[*],/usr/lib/zabbix-check/bin/zabbix-check-disk-performance $1 $2

0
usr/share/doc/zabbix-check-disk-performance/examples/zabbix-check-disk-performance.xml → examples/zabbix-check-disk-performance.xml

10
usr/lib/zabbix-check/bin/zabbix-check-disk-performance-get.py → usr/lib/zabbix-check/bin/zabbix-check-disk-performance

@ -1,8 +1,9 @@
#!/usr/bin/python
#!/usr/bin/env python3
import sys
import os
def getRealDevName(dev):
devpath = "/dev/disk/by-id/dm-name-{0}".format(dev)
if os.path.exists(devpath):
@ -10,6 +11,7 @@ def getRealDevName(dev):
else:
return dev
opt = ['read.ops', 'read.merged', 'read.sectors', 'read.ms',
'write.ops', 'write.merged', 'write.sectors', 'write.ms',
'io.active', 'io.ms', 'weight.io.ms']
@ -20,13 +22,13 @@ try:
with open('/sys/class/block/{0}/stat'.format(device)) as f:
stats = f.read().split()
except IOError as e:
print "An error occured: {0}".format(e)
print("An error occured: {0}".format(e))
sys.exit(1)
opt_per_stat = dict(zip(opt, stats))
try:
print opt_per_stat[arg]
print(opt_per_stat[arg])
except KeyError as e:
print "Wrong Key: {0}".format(e)
print("Wrong Key: {0}".format(e))
sys.exit(1)

13
usr/lib/zabbix-check/bin/zabbix-check-disk-performance-discover.py → usr/lib/zabbix-check/bin/zabbix-check-disk-performance-discovery

@ -1,13 +1,13 @@
#!/usr/bin/python
#!/usr/bin/env python3
import json
import os
import re
disk_id_path = "/dev/disk/by-id/"
dev_list = []
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)
@ -15,11 +15,8 @@ for name in os.listdir(disk_id_path):
if dev_match:
real_dev = os.path.realpath(disk_id_path + dev_match.group(0)).split('/')[2]
if real_dev != "sr0":
dev_list.append(real_dev)
data.append({"{#DEVICENAME}": real_dev})
elif dm_match:
dev_list.append(dm_match.group(1))
data.append({"{#DEVICENAME}": dm_match.group(1)})
returnvalue = { "data" : [] }
for dev in dev_list:
returnvalue["data"].append({ "{#DEVICENAME}" : dev })
print json.dumps(returnvalue)
print(json.dumps({ "data": data }))
Loading…
Cancel
Save