If we want to implement a custom alert on the Nagios, then we can follow this guide.

Client Side:

First of all you have to write the script.

In the script below, we are actually running a SQL query in which we are checking if the value on the column “version” has reached to the value of “1073741824”. We are implementing this alert because the maximum that can be reached is “2147483648”. So, we are making the alert for half of this value.

The script is:

#!/bin/bash

# Variables
critical=1073741824
init11_max_limit=2147483648

##AccountID and Max Version
result=$(mysql -urefill -prefill -h localhost accounts -N -e "select accountId, version from accounts order by version desc limit 1;")
#####Extracting the accountId and Version from the query output
accountId=$(echo "$result" | awk '{print $1}')
version=$(echo "$result" | awk '{print $2}')

if [ "$version" -ge "$critical" ]; then
  echo "CRITICAL: accounts.accounts current version is $version for $accountId reaches to the $critical threshold"
  exit 2
else
  echo "OK: accounts.accounts current version $version for $accountId is safe"
  exit 0
fi

Now we have a condition. This alert is to be implemented on node “YEDB01B”. On this node the NRPE client should be installed. If it is not, then you have to install as follows:

yum install nrpe nagios-plugins
systemctl enable nrpe
systemctl start nrpe

Now update the file “/etc/nagios/nrpe.cfg” with the following at end of file:

command[check_accounts_version]=/path/to/your/script.sh

The path is usually for the script is “/usr/lib64/nagios/plugins/”

Now reload the nrpe:

systemctl reload nrpe

Server Side:

Now as the NRPE client has been installed. Now we will need a Nagios Server. We are assuming that it is already installed.

Now we will go towards the default directory of the Nagios Server. The path is:

/usr/local/nagios/etc/objects/

Here we will be using the following two important files:

  1. commands.cfg
  2. services.cfg