nagios-plugins , nrpe, and Enterprise Linux

Photo by Kat Med on Unsplash

On Rocky Linux 8 it requires both EPEL and powertools.

On Rocky Linux 9 is requires both EPEL and crb (powertools).

If you don’t have those on, you will see:

dnf install nagios-plugins-all
 
Error:
 Problem: package nagios-plugins-all-2.4.9-1.el8.x86_64 from epel requires nagios-plugins-disk_smb, but none of the providers can be installed                                                       
  - package nagios-plugins-disk_smb-2.4.9-1.el8.x86_64 from epel requires perl(utf8::all), but none of the providers can be installed                                                                
  - conflicting requests
  - nothing provides perl(PerlIO::utf8_strict) needed by perl-utf8-all-0.024-7.el8.noarch from epel                                                                                                  
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)  

Compiling Nagios-Plugins-All

This for example is needed right now for Rocky 10 as its not available:

#!/bin/bash
set -e
# Install dependencies
sudo dnf install -y gcc glibc glibc-common curl perl net-snmp net-snmp-utils openssl-devel make unzip tar gd gd-devel jq

# Get latest release info from GitHub API
LATEST_JSON=$(curl -s https://api.github.com/repos/nagios-plugins/nagios-plugins/releases/latest)
TAG=$(echo "$LATEST_JSON" | jq -r .tag_name)
TARBALL_URL=$(echo "$LATEST_JSON" | jq -r '.assets[] | select(.name | endswith(".tar.gz")) | .browser_download_url')

if [[ -z "$TARBALL_URL" ]]; then
    echo "Could not find latest tarball URL."
    exit 1
fi

echo "Downloading Nagios Plugins $TAG from $TARBALL_URL"
cd /tmp
curl -L "$TARBALL_URL" -o nagios-plugins.tar.gz

# Extract the tarball
tar xzf nagios-plugins.tar.gz

# Find the extracted directory
DIR=$(tar tzf nagios-plugins.tar.gz | head -1 | cut -f1 -d"/")
cd "$DIR"

# Create nagios user/group if needed
if ! id -u nagios >/dev/null 2>&1; then
    sudo useradd -r -m -s /sbin/nologin nagios
fi

# Configure, compile, and install
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install

# Clean up
cd /
#rm -rf /tmp/nagios-plugins*

It will put them in /usr/local/nagios/libexec so a different place to than the standard rpm /usr/lib64/nagios/plugins directory.

Compiling nrpe

Again, its needed right now as nrpe isn’t available for Rocky 10

#!/bin/bash
set -e
# Install dependencies
sudo dnf install -y gcc glibc glibc-common curl perl openssl-devel make unzip tar autoconf automake libtool net-snmp net-snmp-utils jq
# Get latest NRPE release info from GitHub API
LATEST_JSON=$(curl -s https://api.github.com/repos/NagiosEnterprises/nrpe/releases/latest)
TAG=$(echo "$LATEST_JSON" | jq -r .tag_name)
TARBALL_URL=$(echo "$LATEST_JSON" | jq -r '.assets[] | select(.name | endswith(".tar.gz")) | .browser_download_url')

if [[ -z "$TARBALL_URL" ]]; then
    echo "Could not find latest NRPE tarball URL."
    exit 1
fi

echo "Downloading NRPE $TAG from $TARBALL_URL"
cd /tmp
curl -L "$TARBALL_URL" -o nrpe.tar.gz

# Extract the tarball
tar xzf nrpe.tar.gz

# Find the extracted directory
DIR=$(tar tzf nrpe.tar.gz | head -1 | cut -f1 -d"/")
cd "$DIR"

# Create nagios user/group if needed
if ! id -u nagios >/dev/null 2>&1; then
    sudo useradd -r -m -s /sbin/nologin nagios
fi

# Prepare, configure, compile, and install
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make all
sudo make install-groups-users
sudo make install
sudo make install-config
sudo make install-init

# Optional: install check_nrpe plugin for Nagios server
sudo make install-plugin

# Clean up
cd /
rm -rf /tmp/nrpe*