Monit alert script6/9/2023 ![]() ![]() Be sure to include your email ID in the script. In this example, we set threshold at 7 0% for testing purpose and you can change this limit based on your requirements. This script is very simple and straightforward, which triggers an email when the system reaches a given threshold. Method-1: Shell script to monitor disk space usage in Linux Test-script.sh: line 7: [: /dev/mapper/vg_2g-lv_root: integer expression expected ![]() Use “df -Ph” (POSIX output format) to deal with this problem. Make a note: When using “df -h” in the shell script in some distributions, you may end up with the below error message as the output is not in the correct format. These scripts will trigger an email to the corresponding email id when the system reaches a given threshold. We have included three shell scripts below and you can choose the one that suits your need. In this case, it is better to write a shell script based on what you need to monitor in your environment. However, it is suitable for small and large environments, but what is the best approach if you only have a few systems? There are various monitoring tools available that monitor everything, and trigger an email when the system reaches a given threshold. It is an important task for Linux administrators to monitor disk space usage on any system that’s used for hosting critical applications, in order to prevents the system from becoming unresponsive or get into an unknown problem.
0 Comments
Leave a Reply. |