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.
So I am new to scripting. What I am trying to accomplish it ssh into all my linux boxes and get their disc usage, print discs above 60%, then display it on a webpage. I like the format of df -HP displaying the headers. Searching through this website I came across this df -h | awk 'BEGIN { FS="[ %]*"} ($5+0) > 60 { print $NF } '. This is creditous to pan64, the keep it simple approach always works. Thus far I have replaced df-h with df-HP and changed { print $NF } to { print $FS } | cat >> /var/www/html/filename which gives most of what I am looking for. The only thing I am missing is the header information such as Filesystem, Size, Used, Avail, Use%, and Mounted on. If you can please point me in the right direction as how to get this information displayed, that will be greatly appreciated? From there I will figure out how to get the hostname with a break then with the above info. Ultimately trying to get the scrip to format it like this....
Hostname
-----------------
df -HP information (week 1)
df -HP information (week 2)
Ca I just point out that over time its going to get hard to read a wall of text ... How about something like Nagios (for alarming you if percentage exceeds eg 90) and Cacti (trend graphing so you can easily see at a glance what state ALL the disks are/have been in).
There are alternatives to both of these tools, but you get the idea.
Thank you chrism01...I will look into these solutions. I was going to add to the script to send out an alert if disc utilization hits 90%. If these solutions makes things easier. Well then......
Well, its possible to write your own scripts and that can be educational, but for more than a few systems/disks I'd recommend a tool built for the job.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.