标签:
UserParameter=disk.discovery,python /usr/local/zabbix/bin/disk_discovery.py UserParameter=diskstats[*],/usr/local/zabbix/bin/diskstats.sh $1 $2
#!/usr/bin/env python #This script is used to discovery disk on the server import subprocess import json args="cat /proc/diskstats |grep -E ‘\ssd[a-z]\s|\sxvd[a-z]\s|\svd[a-z]\s‘|awk ‘{print $3}‘|sort|uniq 2>/dev/null" t=subprocess.Popen(args,shell=True,stdout=subprocess.PIPE).communicate()[0] disks=[] for disk in t.split(‘\n‘): if len(disk) != 0: disks.append({‘{#DISK_NAME}‘:disk}) print json.dumps({‘data‘:disks},indent=4,separators=(‘,‘,‘:‘))
#!/bin/sh device=$1 item=$2 case $item in read.ops) cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk ‘{print $4}‘ ;; read.ms) cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk ‘{print $7}‘ ;; write.ops) cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk ‘{print $8}‘ ;; write.ms) cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk ‘{print $11}‘ ;; io.active) cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk ‘{print $12}‘ ;; io.ms) cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk ‘{print $13}‘ ;; read.sectors) cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk ‘{print $6}‘ ;; write.sectors) cat /proc/diskstats |grep "\b\$device\b"| head -1 | awk ‘{print $10}‘ ;; esac
标签:
原文地址:http://www.cnblogs.com/tankt101/p/5551519.html