• 【17】自动发现磁盘脚本


    disk_scan.sh

    #!/bin/bash
    diskarray=(`cat /proc/diskstats |grep -E "sd[abcdefg]|vd[abcdefg]|nvme0n1"|grep -i "$1"|awk '{print $3}'|sort|uniq   2>/dev/null`)
    length=${#diskarray[@]}
    printf "{
    "
    printf  '	'""data":["
    for ((i=0;i<$length;i++))
    do
             printf '
    		{'
             printf ""{#DISKNAME}":"${diskarray[$i]}"}"
             if [ $i -lt $[$length-1] ];then
                     printf ','
             fi
    done
    printf  "
    	]
    "
    printf "}
    "

    mykey.conf

    # 磁盘IO
    UserParameter=io.scandisk[*],/usr/local/zabbix/etc/zabbix_agentd.conf.d/scripts/disk_scan.sh $1
    UserParameter=io.rps[*],/usr/bin/tail /tmp/iostat_output |grep "$1"|tail -1|awk '{print $$4}'
    UserParameter=io.wps[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$5}'
    UserParameter=io.rKBps[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$6}'
    UserParameter=io.wKBps[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$7}'
    UserParameter=io.avgrq-sz[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$8}'
    UserParameter=io.avgqu-sz[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$9}'
    UserParameter=io.await[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$10}'
    UserParameter=io.r_await[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$11}'
    UserParameter=io.w_await[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$12}'
    UserParameter=io.svctm[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$13}'
    UserParameter=io.util[*],/usr/bin/tail /tmp/iostat_output |grep "$1" |tail -1|awk '{print $$14}
  • 相关阅读:
    ubuntu13.04中把ibus中的中文拼音输入设为默认
    PHP中获取星期的几种方法
    linux 指令(经常更新)
    手机禁止浏览器往下拉
    Linux常用命令大全
    flask之SQLAlchemy
    【原创】微服务为什么一定要用docker
    flask3
    nginx+uWSGI+django+virtualenv+supervisor发布web服务器
    flask之jinji2模板介绍
  • 原文地址:https://www.cnblogs.com/zmx-721/p/10719180.html
Copyright © 2020-2023  润新知