iT邦幫忙

DAY 12
3

IT人實用技巧分享-30Tips系列 第 12

如何監視AIX系統上的disk空間?

作為一個AIX的系統管理者,我們需要經常的下指令df -k查看file system空間是否已滿,透過以下方式我們可以達成在file system空間90%時,自動mail通知我們,避免disk空間滿後造成系統無法運作.
(1)在IBM AIX系統寫一個檔名為 df.sh的script,內容如下:
#!/bin/sh

Shell script to monitor or watch the disk space

It will send an email to $ADMIN, if the (free avilable) percentage

of space is >= 90%

-------------------------------------------------------

Copyright (c) 2005 nixCraft project http://cyberciti.biz/fb/

This script is licensed under GNU GPL version 2.0 or above

-------------------------------------------------------

This script is part of nixCraft shell script collection (NSSC)

Visit http://bash.cyberciti.biz/ for more information.

---------------------------------------------------------

Linux shell script to watch disk space (should work on other UNIX oses )

SEE URL: http://www.cyberciti.biz/tips/shell-script-to-watch-the- disk-space.html

set admin email so that you can get email

ADMIN="mis@ibm.com"

set alert level 90% is default

ALERT=90
df -g | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $4 " " $1 }' | while read output;
do
#echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $ALERT ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep" $ADMIN
fi
done
(2)再AIX編輯crontab設定每小時固定執行df.sh當有空間>90時,即會發mail通知mis
#monitor or watch the disk space .
30 * * * * /usr/bin/su - aixadm -c "/sapmnt/AIX/exe/df.sh AIX DVEBMGS00" > /dev/null


上一篇
Windows自動新增網路印表機
下一篇
windows裡禁止開機自檢硬碟
系列文
IT人實用技巧分享-30Tips30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
SunAllen
iT邦研究生 1 級 ‧ 2011-10-29 01:36:04

好久沒碰AIX了,好懷念啊讚

我要留言

立即登入留言