├── LICENSE ├── README.md ├── Template Disk Performance.xml ├── images ├── discovery_rules.png ├── sda_bytes_second.png ├── sda_merged.png ├── sda_ops_second.png └── sda_overview.png ├── lld-disks.py └── userparameter_diskstats.conf /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Grigory Chernyshev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | zabbix-disk-performance 2 | ======================= 3 | 4 | Zabbix template for collecting IO statistics 5 | 6 | With this template you can collect different disk statistics. 7 | 8 | ![Bytes/Sec](https://github.com/grundic/zabbix-disk-performance/blob/master/images/sda_bytes_second.png?raw=true=250x) 9 | ![Merged](https://github.com/grundic/zabbix-disk-performance/blob/master/images/sda_merged.png?raw=true=250x) 10 | ![Ops/Sec](https://github.com/grundic/zabbix-disk-performance/blob/master/images/sda_ops_second.png?raw=true=250x) 11 | ![Overview](https://github.com/grundic/zabbix-disk-performance/blob/master/images/sda_overview.png?raw=true=250x) 12 | 13 | Installation 14 | ------------ 15 | To install, copy `userparameter_diskstats.conf` to `/etc/zabbix/zabbix_agentd.d/userparameter_diskstats.conf` and `lld-disks.py` to `/usr/local/bin/lld-disks.py`. 16 | Do not forget to mark it executable. 17 | ```bash 18 | # diskstats user parameters config 19 | sudo mkdir -p /etc/zabbix/zabbix_agentd.d/ 20 | sudo wget https://raw.githubusercontent.com/grundic/zabbix-disk-performance/master/userparameter_diskstats.conf -O /etc/zabbix/zabbix_agentd.d/userparameter_diskstats.conf 21 | 22 | # low level discovery script 23 | sudo wget https://raw.githubusercontent.com/grundic/zabbix-disk-performance/master/lld-disks.py -O /usr/local/bin/lld-disks.py 24 | sudo chmod +x /usr/local/bin/lld-disks.py 25 | ``` 26 | 27 | `userparameter_diskstats.conf` is user parameters for Zabbix. 28 | `lld-disks.py` is low level discovery script for enumerating disks of your system. 29 | 30 | After that restart zabbix-agent 31 | ```sudo service zabbix-agent restart``` 32 | 33 | Go to Zabbix's web interface, Configuration->Templates and import `Template Disk Performance.xml`. 34 | After that you should be able to monitor disk activity for all your disks. 35 | 36 | Please note, that items and graphs are created for each disk/partition individually using discovery script, so do not expect to 37 | find them under usual configuration -- they would be in `Discovery rules` section: 38 | 39 | ![Discovery Rules](https://github.com/grundic/zabbix-disk-performance/blob/master/images/discovery_rules.png?raw=true=250x) 40 | 41 | Low level discovery will list your RAID devices, and LVM volumes, but LVM 42 | volumes will be mapped with their device-mapper ID, not the pretty names. 43 | 44 | Using without User Parameters 45 | ----------------------------- 46 | Zabbix have [standard parameters](https://www.zabbix.com/documentation/2.0/manual/appendix/items/supported_by_platform) for monitoring disk io: `vfs.dev.read` and `vfs.dev.write` with several types: 47 | * sectors 48 | * operations 49 | * sps 50 | * ops 51 | 52 | Template have this values configured, but disabled by default. 53 | 54 | 55 | Testing 56 | ------- 57 | To test that everything work use `zabbix_get` (from some time this is in it's own package, so do `apt-get/yum install zabbix-get`): 58 | ```bash 59 | # view result of low level discovery 60 | zabbix_get -s 127.0.0.1 -k "custom.vfs.discover_disks" 61 | # view statistics for 'sda' disk 62 | zabbix_get -s 127.0.0.1 -k "custom.vfs.dev.write.sectors[sda]" 63 | ``` 64 | -------------------------------------------------------------------------------- /Template Disk Performance.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2.0 4 | 2015-04-09T12:56:43Z 5 | 6 | 7 | Templates 8 | 9 | 10 | 11 | 1051 | 1052 | 1053 | -------------------------------------------------------------------------------- /images/discovery_rules.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grundic/zabbix-disk-performance/e2591df43b3c8f0019484035ee80fd81d526be7d/images/discovery_rules.png -------------------------------------------------------------------------------- /images/sda_bytes_second.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grundic/zabbix-disk-performance/e2591df43b3c8f0019484035ee80fd81d526be7d/images/sda_bytes_second.png -------------------------------------------------------------------------------- /images/sda_merged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grundic/zabbix-disk-performance/e2591df43b3c8f0019484035ee80fd81d526be7d/images/sda_merged.png -------------------------------------------------------------------------------- /images/sda_ops_second.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grundic/zabbix-disk-performance/e2591df43b3c8f0019484035ee80fd81d526be7d/images/sda_ops_second.png -------------------------------------------------------------------------------- /images/sda_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grundic/zabbix-disk-performance/e2591df43b3c8f0019484035ee80fd81d526be7d/images/sda_overview.png -------------------------------------------------------------------------------- /lld-disks.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import os 3 | import json 4 | 5 | if __name__ == "__main__": 6 | # Iterate over all block devices, but ignore them if they are in the 7 | # skippable set 8 | skippable = ("sr", "loop", "ram") 9 | devices = (device for device in os.listdir("/sys/class/block") 10 | if not any(ignore in device for ignore in skippable)) 11 | data = [{"{#DEVICENAME}": device} for device in devices] 12 | print(json.dumps({"data": data}, indent=4)) 13 | -------------------------------------------------------------------------------- /userparameter_diskstats.conf: -------------------------------------------------------------------------------- 1 | UserParameter=custom.vfs.discover_disks,/usr/local/bin/lld-disks.py 2 | 3 | UserParameter=custom.vfs.dev.read.ops[*],awk '{print $$1}' /sys/class/block/$1/stat 4 | UserParameter=custom.vfs.dev.read.merged[*],awk '{print $$2}' /sys/class/block/$1/stat 5 | UserParameter=custom.vfs.dev.read.sectors[*],awk '{print $$3}' /sys/class/block/$1/stat 6 | UserParameter=custom.vfs.dev.read.ms[*],awk '{print $$4}' /sys/class/block/$1/stat 7 | UserParameter=custom.vfs.dev.write.ops[*],awk '{print $$5}' /sys/class/block/$1/stat 8 | UserParameter=custom.vfs.dev.write.merged[*],awk '{print $$6}' /sys/class/block/$1/stat 9 | UserParameter=custom.vfs.dev.write.sectors[*],awk '{print $$7}' /sys/class/block/$1/stat 10 | UserParameter=custom.vfs.dev.write.ms[*],awk '{print $$8}' /sys/class/block/$1/stat 11 | UserParameter=custom.vfs.dev.io.active[*],awk '{print $$9}' /sys/class/block/$1/stat 12 | UserParameter=custom.vfs.dev.io.ms[*],awk '{print $$10}' /sys/class/block/$1/stat 13 | UserParameter=custom.vfs.dev.weight.io.ms[*],awk '{print $$11}' /sys/class/block/$1/stat 14 | --------------------------------------------------------------------------------