码迷,mamicode.com
首页 > 系统相关 > 详细

Linux/AIX/HP-UNIX监控磁盘脚本

时间:2018-06-13 19:40:47      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:磁盘空间

#!/bin/sh

os_ver=`uname`


if [ "$os_ver" = "Linux" ]; then

#line_num=`df -h|grep -v Filesystem|grep -v proc|awk ' gsub(/%/,"",$5) {print $6 "   " $5}' |wc -l`

line_num=`df -h|grep -v Filesystem|grep -v proc |grep   '[[:digit:]]' | awk '  gsub(/%/,"",$(NF-1)){print $NF,$(NF-1)}' |wc -l`

i=0

echo "["

df -h|grep -v Filesystem|grep -v proc |grep   '[[:digit:]]' | awk '  gsub(/%/,"",$(NF-1)){print $NF,$(NF-1)}'|while read v_file v_precent

#df -h|grep -v Filesystem|grep -v proc|awk ' gsub(/%/,"",$5) {print $6 "   " $5}'|while read v_file v_precent

do

 let i=i+1

 if [ $i -lt $line_num ]; then

    echo  "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"},"

 else

    echo  "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"}"

 fi

done

echo "]"


elif [ "$os_ver" = "AIX" ]; then

i=0

line_num=`df -g|grep -v Filesystem|grep -v proc|awk ' gsub(/%/,"",$4) {print $7 "   " $4}' |wc -l`

echo "["

df -g|grep -v Filesystem|grep -v proc|awk ' gsub(/%/,"",$4) {print $7 "   " $4}'|while read v_file v_precent

do

 let i=i+1

 if [ $i -lt $line_num ]; then

    echo  "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"},"

 else

    echo  "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"}"

 fi

done

echo "]"


else

line_num=`bdf |grep -v Filesystem|grep '[[:digit:]]'  |awk 'gsub(/%/,"",$(NF-1)) {print $NF,$(NF-1)}' |wc -l`

#line_num=`bdf |grep -v Filesystem|awk ' gsub(/%/,"",$5) {print $6 "   " $5}' |wc -l`

i=0

echo "["

bdf |grep -v Filesystem|grep '[[:digit:]]'  |awk 'gsub(/%/,"",$(NF-1)) {print $NF,$(NF-1)}'|while read v_file v_precent

#bdf |grep -v Filesystem|awk ' gsub(/%/,"",$5) {print $6 "   " $5}'|while read v_file v_precent

do

 let i=i+1

 if [ $i -lt $line_num ]; then

    echo  "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"},"

 else

    echo  "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"}"

 fi

done

echo "]"

fi


Linux/AIX/HP-UNIX监控磁盘脚本

标签:磁盘空间

原文地址:http://blog.51cto.com/11310506/2129041

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!