As i'm still pretty new to AIX, i need to learn as quickly as possible to manage the new babies in my care. :) Let say i want to determine disk size of physical volume The output below is in Mb.
# bootinfo -s hdisk2 51200For free space left in volume group We can see that there are 36Gb of space left in VG unassigned.
# lsvg rootvg VOLUME GROUP: rootvg VG IDENTIFIER: 00f603d800004c000000012c441dd962 VG STATE: active PP SIZE: 32 megabyte(s) VG PERMISSION: read/write TOTAL PPs: 1918 (61376 megabytes) MAX LVs: 256 FREE PPs: 1140 (36480 megabytes) LVs: 13 USED PPs: 778 (24896 megabytes) OPEN LVs: 12 QUORUM: 1 (Disabled) TOTAL PVs: 2 VG DESCRIPTORS: 3 STALE PVs: 0 STALE PPs: 0 ACTIVE PVs: 2 AUTO ON: yes MAX PPs per VG: 32512 MAX PPs per PV: 1016 MAX PVs: 32 LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no HOT SPARE: no BB POLICY: relocatable PV RESTRICTION: noneThis is the demo script i have written to check both disk and inode utilisation. Please let me know if you find this useful or the gurus want to help me improve. :)
#!/bin/ksh # # FILENAME : checkDiskSpace.ksh # AUTHOR : Victor Kwan # EMAIL : victorkk [AT] gmail [DOT] com # PURPOSE : To check disk and inode utilisation # : and alert sys admin if threshold is breached. # DATE : Feb 2011 # # # Parameters setup OUTPUTFILE_DF="checkDisk.DF.`hostname`.`date '+%d%b%Y'`.output" NOTIFICATION_MSG="checkDisk.DF.`hostname`.`date '+%d%b%Y'`.message" isFOUND=0 # # Input Validation if [ $# -ne 3 ] then printf "Usage: \n\t$0\n\n" exit fi DISK_THRESHOLD=$1 INODE_THRESHOLD=$2 EMAIL="$3" # # Check for Logical Disk Partition full df -m > ./$OUTPUTFILE_DF # # Setup the messages printf "----------------------------------------\n" > $NOTIFICATION_MSG printf " Check for Logical Parition Utilisation\n\n" >> $NOTIFICATION_MSG printf " Disk / Inode Threshold: $DISK_THRESHOLD | $INODE_THRESHOLD \n" >> $NOTIFICATION_MSG printf "----------------------------------------\n\n" >> $NOTIFICATION_MSG if [ `cat $OUTPUTFILE_DF | wc -l` == 1 ] then printf "No Partition detected.\n" else cat $OUTPUTFILE_DF | while read LINE do isFULL_CHECK=`echo $LINE | awk '{print $4}' | grep "%" | wc -l` #printf "[DEBUG]isFULL_CHECK is %d.\n" $isFULL_CHECK if [ $isFULL_CHECK == 1 ] then LDISK=`echo $LINE | awk '{print $1}'` LDISK_PARTITION=`echo $LINE | awk '{print $7}'` LDISK_SIZE=`echo $LINE | awk '{print $2}'` LDISK_USED=`echo $LINE | awk '{print $4}' | awk -F% '{print $1}'` LDISK_INODE=`echo $LINE | awk '{print $6}' | awk -F% '{print $1}'` if [ $LDISK_USED -ge $DISK_THRESHOLD -o $LDISK_INODE -ge $INODE_THRESHOLD ] then #printf "[DEBUG]The line is $LINE\n" printf "Partition \"%s\" mounted on \"%s\"\n" $LDISK_PARTITION $LDISK >> $NOTIFICATION_MSG printf "Size (Mb) | Disk (%%) | Inode (%%)\n" >> $NOTIFICATION_MSG printf "%-9.2f | %-8d | %-8d\n\n" $LDISK_SIZE $LDISK_USED $LDISK_INODE >> $NOTIFICATION_MSG isFOUND=1 fi fi done fi if [ $isFOUND == 0 ] then printf "All Partition within threshold.\n" >> $NOTIFICATION_MSG elif [ $isFOUND == 1 ] then cat $NOTIFICATION_MSG | mailx -s "[`hostname`] Disk Space Above Threshold" $EMAIL fi # # Some Housekeeping rm $OUTPUTFILE_DF rm $NOTIFICATION_MSG
No comments:
Post a Comment