Disc Monitoring Script only print > 60%
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) Hostname --------------- Same as above. |
How about adding a check for Use that should cause it to dump the header as well:
df -HP | awk 'BEGIN { FS="[ %]*"} ($5+0) > 60 { print $FS } $5=="Use" { print $FS }' |
Genius estabroo....pure genius.....
|
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.
|
Quote:
df -HP | head -1 Which will output only the heading... |
All times are GMT -5. The time now is 01:41 PM. |