文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>UNIX SHELL编程书中的经典例子连载1--文件系统监..

UNIX SHELL编程书中的经典例子连载1--文件系统监..

时间:2006-06-29  来源:古道西风

#!/usr/bin/ksh
#
# SCRIPT: fs_mon_SUNOS.ksh
# AUTHOR: Randy Michael
# DATE: 08-22-2001
# REV: 1.1.P
# PURPOSE: This script is used to monitor for full filesystems,
#     which is defined as "exceeding" the FSMAX value.
#     A message is displayed for all "full" filesystems.
#
# PLATFORM: SUN Solaris
#
# REV LIST:
#
# set -n # Uncomment to check syntax without any execution
# set -x # Uncomment to debug this script
#
##### DEFINE FILES AND VARIABLES HERE #### 
WORKFILE="/tmp/df.work" # Holds filesystem data
>$WORKFILE              # Initialize to empty
OUTFILE="/tmp/df.outfile" # Output display file
>$OUTFILE  # Initialize to empty
THISHOST=`hostname` # Hostname of this machine
FSMAX="85"              # Max. FS percentage value
######## START OF MAIN ############# # Get the data of interest by stripping out rows
# to be ignored and keeping columns 1, 5 and 6
df -k | tail +2 | egrep -v '/dev/fd|/etc/mnttab|/proc|/cdrom' \
      | awk '{print $1, $5, $6}' > $WORKFILE
# Loop through each line of the file and compare column 2 while read FSDEVICE FSVALUE FSMOUNT
do
      FSVALUE=$(echo $FSVALUE | sed s/\%//g) # Remove the % sign
      if [ $FSVALUE -gt $FSMAX ]
      then
          echo "$FSDEVICE mounted on $FSMOUNT is ${FSVALUE}%" \
                >> $OUTFILE
      fi
done < $WORKFILE
if [[ -s $OUTFILE ]]
then
      echo "\nFull Filesystem(s) on $THISHOST\n"
      cat $OUTFILE
      print
fi
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载