Use df-tph to view hard disk usage under Linux:
sdua:/# Df-tphfilesystem Type Size used Avail use% mounted On/dev/vda3 ext3 2.0G 974M 940M 51%/udev tmpfs 16G 500K 16G 1%/devtmpfs tmpfs 32G 9.4G 23G 30%/dev/shm/dev/vda2 ext3 1008M 56M 902M 6%/boot/dev/vda9 ext3 20G 173M 19G 1%/core/dev/vda8 ext3 28G 2.5G 24G 10%/home/dev/vda10 Ext3 21G 6.1G 14G 31%/opt/dev/vda6 ext3 4.0G 186M 3.6G 5%/ Vartmpfs tmpfs 512M 620K 512M 1%/tmpshm tmpfs 32G 9.4G 23G 30%/dev/shm/dev/mapper/vgdb-lv_bakdata ext3 11G 326M 9.8G 4%/home/oracle/rmcbak/dev/mapper/ Vgdb-lvarchive ext3 11G 156M 9.9G 2%/home/oracle/archive
Remove filesystem rows, Tmpfs rows (Tmpfs is a memory-based file system), obtaining the hard disk name and usage rate:
The actual shell script is implemented as follows:
#!/bin/bash# Set alert level 90% is defaultalert=50df-tph | Grep-ve ' ^filesystem|tmpfs|cdrom ' | awk ' {print $6 ' "$} ' | While read Output;do usep=$ (echo $output | awk ' {print $} ' | cut-d '% '-F 1) partition=$ (echo $output | awk ' { Print $} ') if [$usep-ge $ALERT]; then echo "Running Out of space $partition ($usep%) on $ (date +%y-%m-%d)" C4/>fidoneexit 0
Running effect exceeds 50% usage rate:
Linux hard disk usage and Shell script implementation