Linux/AIX/HP-UNIX监控磁盘脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux/AIX/HP-UNIX监控磁盘脚本相关的知识,希望对你有一定的参考价值。
#!/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监控磁盘脚本的主要内容,如果未能解决你的问题,请参考以下文章