Catdisk. sh #! /Bin/bashforiin 'df | sed1d | awk & #39; {print $5} & #39; | sed & #39; s/% // g & #39; ##### compare the loop size after obtaining #### doif [$ i-gt10] ### here the threshold value is set to 10, to facilitate the test result ### thendf-lh & gt; d
Cat disk. sh
#! /Bin/bash
For I in 'df | sed 1d | awk '{print $5}' | sed's/% // g'' ### compare the size of the obtained loop ### #
Do
If [$ I-gt 10] ### here, the threshold value is set to 10 to facilitate testing ###
Then
Df-lh> disk.txt was added to disk.txt to warn the Administrator ####
Ip = 'ifconfig eth0 | sed-n 2p | awk '{print $2}' | awk-F: '{print $2 }''
Echo "$ {ip} the disk of this host exceeds the threshold, please handle it in time" ### here, you can change it to email or fetion ###
Fi
Done
Run:
[Root @ 2 shell] # sh disk. sh
192.168.2.4 the disk of this host exceeds the threshold. Please handle it in time
[Root @ 2 shell] # cat disk.txt
File System capacity used available % mount point
/Dev/hda3 192G 4.0G 178G 3%/
/Dev/hda1 99 M 12 M 83 M 13%/boot
Tmpfs 506 M 0 506 M 0%/dev/shm
Finally, it is used with crontab and can be executed once every 30 minutes.