Page 1 of 1

I need to monitor number of opened files

Posted: Tue Feb 11, 2025 2:18 pm
by cjstgreen
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

Re: I need to monitor number of opened files

Posted: Thu Feb 13, 2025 4:55 pm
by lgute
Hi @cjstgreen,

Thanks for reaching out.

Without a wizard, it will take a couple of steps to setup your script to run as a Service Check. Navigate to the Core Config Manager (CCM)...
  1. Install your plugin script on your XI server.
  2. Setup a Command to run your script.
  3. Setup a Service.
This document should walk you through this process.Managing-Plugins-in-Nagios-XI. It also provides a link to the Plugin Guidelines, in case your plugin is not giving you the results you want.