Last active
January 22, 2018 18:20
-
-
Save c0mpiler/51f9ec158d9743cf8e708554f3e69158 to your computer and use it in GitHub Desktop.
Monitor the number of file handles opened by the web-app and handle as needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run this script as a cron job or using watch | |
# | |
# e.g: | |
# Using 'watch' - to run the script every 5 mins | |
# # watch -n 300 ./file_handles.sh | |
# | |
# Using a cron job to run every 5 mins. Run | |
# # crontab –e | |
# then add the following line to the editor | |
# '*/10 * * * * /home/hvkrishn/file_handles.sh' | |
pid=$(lsof -i:9420 -t) | |
echo "pid: " $pid | |
handles_count=$(lsof -p $pid | wc -l) | |
echo "File handles: " $handles_count | |
if [ "$handles_count" -gt 20000 ] | |
then | |
echo "handles > 20K. Run: 'fuser -k -n tcp 9420' or 'kill -9 $pid'" | |
else | |
echo "handles < 20K. We are all good" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment