I need to monitor number of opened files
Posted: Tue Feb 11, 2025 2:18 pm
Hello,
I have below script that I would like to set up a monitor in Nagios to display the thresholds. What type of service do I use for this? Does this require a new command and plugin? Sorry if these are really simple questions for most of you, I am fairly new to Nagios XI. Speaking of that, we are behind due to being on RHEL 7.9. Our current version of Nagios XI is 5.11.3.
Thanks so much.
#!/bin/bash
# Set the warning and critical thresholds using environment variables
warning_threshold=80
critical_threshold=90
USERNAME=imanadm
file_count=`/usr/bin/time -p sudo lsof -u $USERNAME | wc -l`
# Print the number of files found
echo "Number of open files found: $file_count"
# Check the number of open files and print the appropriate message
if [ "$file_count" -ge "$critical_threshold" ]; then
echo "Critical: The number of open files is greater than or equal to $critical_threshold!"
elif [ "$file_count" -ge "$warning_threshold" ]; then
echo "Warning: The number of open files is between $warning_threshold and $(($critical_threshold - 1))!"
else
echo "Okay: The number of open files is less than $warning_threshold."
fi
I have below script that I would like to set up a monitor in Nagios to display the thresholds. What type of service do I use for this? Does this require a new command and plugin? Sorry if these are really simple questions for most of you, I am fairly new to Nagios XI. Speaking of that, we are behind due to being on RHEL 7.9. Our current version of Nagios XI is 5.11.3.
Thanks so much.
#!/bin/bash
# Set the warning and critical thresholds using environment variables
warning_threshold=80
critical_threshold=90
USERNAME=imanadm
file_count=`/usr/bin/time -p sudo lsof -u $USERNAME | wc -l`
# Print the number of files found
echo "Number of open files found: $file_count"
# Check the number of open files and print the appropriate message
if [ "$file_count" -ge "$critical_threshold" ]; then
echo "Critical: The number of open files is greater than or equal to $critical_threshold!"
elif [ "$file_count" -ge "$warning_threshold" ]; then
echo "Warning: The number of open files is between $warning_threshold and $(($critical_threshold - 1))!"
else
echo "Okay: The number of open files is less than $warning_threshold."
fi