Thursday, April 26, 2018

List all the Filesystems which are more than 80% used in linux with awk command


Monitoring file system utilization on linux production server is a very important thing.  We can automate the file system utilization monitoring and schedule it in crontab.  So that script will run at the scheduled time and send out the alert messages.

It's always a good idea to have multiple threshold set for file system and we can make sure it won't reach 100% and the file system crashes on the server.

Below are the few examples of monitoring the file system threshold with powerful awk command.

[santhosh@localhost ~]# df -hP | tr -d "%" | sed 1d | awk '$5 >80'
/dev/mapper/vg00-mysql   30G   25G  3.7G  87 /u01
/dev/mapper/vg00-yumrepo  30G   24G  5.8G  81 /yumrepsitory


[santhosh@localhost ~]# df -hP | tr -d "%" | sed 1d | awk '{if($5>80) print}'
/dev/mapper/vg00-mysql   30G   25G  3.7G  87 /u01
/dev/mapper/vg00-yumrepo  30G   24G  5.8G  81 /yumrepsitory


[santhosh@localhost ~]# df -hP | tr -d "%" | sed 1d | awk 'int($5) > 80 { print $0 }'
/dev/mapper/vg00-mysql   30G   25G  3.7G  87 /u01
/dev/mapper/vg00-yumrepo  30G   24G  5.8G  81 /yumrepsitory

No comments:

Post a Comment