Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a Solaris script for showing disk usage as shown below:
Code:
home/l> space
SPACE OF IMPORTANT FILE SYSTEMS
------------------------------------------------------------------------
FILE-SYSTEM TOTAL-SPACE USED-SPACE FREE-SPACE %USED
/home 4.75 2.23 2.52 47%
/outputs 32.00 15.27 16.73 48%
/backup 60.00 40.42 19.58 68%
/fns 60.00 47.68 12.32 80%
/var 5.00 3.04 1.96 61%
-------------------------------------------------------------------------
Color Significance for USED spaces: gt-80 % lt-80 % & gt-40 % lt-40 %
Script:
Code:
home/> cat space
df -gt /tmp /home /outputs /backup /fns /var|awk 'BEGIN{
print "\t\t\t\033[1;43m SPACE OF IMPORTANT FILE SYSTEMS\t\033[m\n------------------------------------------------------------------------\n\033[1;45mFILE-SYSTEM \t TOTAL-SPACE \t USED-SPACE \t FREE-SPACE \t %USED\033[m\n"}
function disp(color_code,v1,v2,v3,v4,v5){
printf "\033[1;"color_code"m%-10s\t%10s\t%10s\t%10s\t%6s\033[m\n",v1,v2,v3,v4,v5
}
NR>2&&(($3>($2*.80)&&disp(31,$6,$2,$3,$4,$5))||($3>($2*.40)&&$3<($2*.80)&&disp(33,$6,$2,$3,$4,$5))||($3<($2*.40)&&disp(32,$6,$2,$3,$4,$5)))
END{print "-------------------------------------------------------------------------\nColor Significance for USED spaces: \033[1;31mgt-80 % \033[m \033[1;33mlt-80 % & gt-40 %\033[m \033[1;32m lt-40 %\033[m"}'
Its not running on Linux as it doesnt detect df -gt command. Any idea how to get it run under Linux?
While I ran the script:
Code:
./space
df: invalid option -- 'g'
Try `df --help' for more information.
SPACE OF IMPORTANT FILE SYSTEMS
------------------------------------------------------------------------
FILE-SYSTEM TOTAL-SPACE USED-SPACE FREE-SPACE %USED
-------------------------------------------------------------------------
Color Significance for USED spaces: gt-80 % lt-80 % & gt-40 % lt-40 %
Last edited by your_shadow03; 02-21-2014 at 09:09 PM.
You have changed the list of directories from those in your original post, so the grep pattern needs adjustment.
Are you really mounting volumes on /var/lib/psa and /var/log? If so, then properly escape the forward slashes in the grep pattern.
That shows why the script is failing. The output from /dev/mapper/vg00-home has been split across two lines.
As your script does not use the $1 field, you could modify the script to include the '--output' option to df and modify the field positions used by awk accordingly.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.