bash - Finding the DISK space for all the server instances -
in bash script, server list has list of serers disk space should calculated. ranging c1 c109. servers c100-c109 has capacity below 50%, have following message says
"there sufficient disk space available"
but, getting message instead
"i seem running nonexistent amount of disk space"
please if can me fixing this, awesome. let me know, if clarifications need. here script below:
#!/usr/bin/bash # script simple test checking disk space. vtier in `cat serverlist` space=$(ssh -q ${vtier}@${vtier} 'df -kh|grep ${servername}|cut -c 65-70') echo "checking disk space.... in ${vtier}" case $space in [1-6]*) message="there sufficient disk space available - $space full" ;; [7-8]*) message="keep eye on disk space - $space full." ;; 9[1-8]) message="better hurry new disk - $space full." ;; 99) message="i'm drowning here! - $space full" ;; *) message="i seem running nonexistent amount of disk space - $space full" ;; esac echo $message done
your cut incorrect:
marc@panic:/home/httpd/html$ df -kh|cut -c 65-70 marc@panic:/home/httpd/html$
note blank lines... that's not whitespace. it's cut output. once include k
option force block size, block size column removed, shortening each line, you're cutting text way past end of each line. might better off using awk:
marc@panic:/home/httpd/html$ df -kh|awk '{print $5}' use% 7% 1% 1% 0% 1% 61%
Comments
Post a Comment