![]() ![]() – In the case of of exceeding the allowable size limit you have to get an failed status like in the below picture. – Reload Monit if there were no errors using the following command: # sudo service monit reload – Test Monit syntax is valid using the following command: # sudo monit -t If the size of the folder /home/lotfi is greater than 90 MB Monit will send an email alert. – Monit will check the size of the folder /home/lotfi/ every 300 cycles (the Monit interval defined in the /etc/monit/monitrc). With path "/root/scripts/foldersizecheck.sh /home/lotfi/ 90" – Create a Monit configuration file under the /etc/monit.d/ directory # sudo vi /etc/monit/conf.d/foldersize_check You will see this output with the size of folder, here the output size is 100 MB /home/lotfi/ - 100 MB – Run the script and pass the FOLDER_PATH variable and the REFERENCE_SIZE in megabytes to check if the script working properly: # sudo bash /root/scripts/foldersizecheck.sh /home/lotfi/ 90 – Make the script executable using the following command: # sudo chmod +x /root/scripts/foldersizecheck.sh SIZE=$(/usr/bin/du -s $FOLDER_PATH | /usr/bin/awk '') – Paste the following lines which will check the size of a folder: #!/bin/bash # sudo vi /root/scripts/foldersizecheck.sh – Let’s create the bash script foldersizecheck.sh: # sudo mkdir -p /root/scripts How to Install and Configure Monit on CentOS 7 / RHEL 7. ![]() If you didn’t yet install Monit on your server you can check this article: Today we will show you how to check the size of a folder with Monit using a shell script and to send alert mail in case of exceeding an allowable certain size limit. ![]()
0 Comments
Leave a Reply. |