2 ################################################################################
5 # Description: Checks diskspace
6 # Author: Andrew@DeFaria.com
7 # Created: Fri Jul 16 11:05:06 PDT 1999
11 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
13 ################################################################################
14 # Set me to command name
18 adm_base=${adm_base:-//sonscentral/Corporate/Software/adm}
21 adm_fpath=${adm_fpath:-$adm_base/functions}
29 display "$me [-v|verbose] [-d|debug] [-u|sage] [ -n|etwork | -l|ocal ]"
30 display " -v|erbose: Turns on verbose mode"
31 display " -d|ebug: Turns on debug mode"
32 display " -u|sage: Print this usage message"
33 display " -n|etwork: Produce report for network wide storages areas"
34 display " -l|ocal: Produce report for local file systems only"
39 function check_filesystem_space {
40 debug "ENTER check_filesystem_space ($1, $2)"
44 # Make sure that file system is mounted
45 ls $fs > /dev/null 2>&1
48 warning "Cannot mount $kind filesystem $fs" 1
49 debug "RETURN check_filesystem_space"
53 # Isolate the disk usage line
54 diskusage=$(df -k $fs | tail -1 | tr -s ' ')
56 # Get hostname from the now mounted filesystem
57 # Separate field of interest
58 host=$(print $diskusage | cut -f1 -d:)
59 available=$(print $diskusage | cut -f4 -d' ' | awk '{printf "%.3f", $1/1024}')
60 integer capacity=$(print $diskusage | cut -f5 -d' ' | cut -f1 -d'%')
62 # Check if over threshold and report
63 if [ $capacity -le $threshold ]; then
64 if [ ! -z "$verbose" ]; then
65 display "$kind filesystem $host:$fs is $capacity% full and has $available Megs left"
68 display "$kind filesystem $host:$fs has exceeded the threshold of $threshold%."
69 display "It is $capacity% full and has $available Megs left"
72 debug "EXIT check_filesystem_space"
73 } # check_filesystem_space
75 function check_vob_space {
76 debug "ENTER check_vob_space"
77 vob_filesystems="/vbs/bog /vbs/bof /vbs/boh /vbs/bol"
79 for vbs in $vob_filesystems; do
80 check_filesystem_space VOB $vbs
82 debug "EXIT check_vob_space"
85 function check_view_space {
86 debug "ENTER check_view_space"
87 view_filesystems="/vws/bpj /vws/bpq /vws/bpr"
89 for vws in $view_filesystems; do
90 check_filesystem_space View $vws
92 debug "EXIT check_view_space"
95 function check_local_filesystems {
96 debug "ENTER check_local_filesystems"
97 local_filesystems=$(df -k -F ufs | grep /dev | awk '{print $NF}')
101 for lfs in $local_filesystems; do
102 # Isolate the disk usage line
103 diskusage=$(df -k $lfs | tail -1 | tr -s ' ')
105 # Separate field of interest
106 available=$(print $diskusage | cut -f4 -d' ' | awk '{printf "%.3f", $1/1024}')
107 integer capacity=$(print $diskusage | cut -f5 -d' ' | cut -f1 -d'%')
109 # Check if over threshold and report
110 if [ $capacity -le $threshold ]; then
111 if [ ! -z "$verbose" ]; then
112 display "$kind filesystem $host:$lfs is $capacity% full and has $available Megs left"
115 display "$kind filesystem $host:$lfs has exceeded the threshold of $threshold%."
116 display "It is $capacity% full and has $available Megs left"
120 debug "EXIT check_local_filesystems"
121 } # check_local_filesystems
124 threshold=90 # default threshold
125 filesystems=local # default to local filesystems
126 while [ $# -ge 1 ]; do
142 if [ $# -lt 1 ]; then
143 error "Threshold not specified" 0
165 if [ "$filesystems" = "local" ]; then
166 check_local_filesystems