zabbix监控硬盘指标,tcp连接状态
zabbix自动发现硬盘脚本disk_discovery.py
[app@data1etc]$catdisk_discovery.py#/usr/bin/pythonimportsubprocessimportjsonargs="cat/proc/diskstats|grep-E'\ssd[a-z]\s|\sxvd[a-z]\s|\svd[a-z]\s'|awk'{print$3}'|sort|uniq2>/dev/null"t=subprocess.Popen(args,shell=True,stdout=subprocess.PIPE).communicate()[0]disks=[]fordiskint.split('\n'):iflen(disk)!=0:disks.append({'{#DISK_NAME}':disk})printjson.dumps({'data':disks},indent=4,separators=(',',':'))
zabbix监控硬盘状态脚本
[app@data1etc]$catdisk_status.sh#/bin/shdevice=$1item=$2case$iteminrrqm)/usr/bin/iostat-dx|grep$device|awk'{print$2}';;wrqm)/usr/bin/iostat-dx|grep$device|awk'{print$3}';;rps)/usr/bin/iostat-dx|grep$device|awk'{print$4}';;wps)/usr/bin/iostat-dx|grep$device|awk'{print$5}';;rKBps)/usr/bin/iostat-dx|grep$device|awk'{print$6}';;wKBps)/usr/bin/iostat-dx|grep$device|awk'{print$7}';;avgrq-sz)/usr/bin/iostat-dx|grep$device|awk'{print$8}';;avgqu-sz)/usr/bin/iostat-dx|grep$device|awk'{print$9}';;await)/usr/bin/iostat-dx|grep$device|awk'{print$10}';;svctm)/usr/bin/iostat-dx|grep$device|awk'{print$11}';;util)/usr/bin/iostat-dx|grep$device|awk'{print$12}';;esac
修改zabbix_agentd.conf文件
[app@data1etc]$tail-2zabbix_agentd.confUserParameter=disk.discovery,/usr/bin/python/usr/local/zabbix/etc/disk_discovery.pyUserParameter=disk.status[*],/usr/local/zabbix/etc/disk_status.sh$1$2#说明$1为自动发现脚本disk_discovery.py返回给zabbixserver的{#DISK_NAME}$2位要监控的选项
监控tcp连接状态
[app@data1etc]$tail-1zabbix_agentd.confUserParameter=tcp[*],netstat-an|grep-c$1
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。