Skip to main content

On This Page

How I Installed Nagios on EC2 and Created My Own Disk Monitoring Plugin

2 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

How I Installed Nagios on EC2 and Created My Own Disk Monitoring Plugin

Krisha Arya installed Nagios Core 4.4.14 on an Ubuntu 22.04 EC2 instance, configuring it to monitor disk usage via a custom plugin. The setup includes SSH, HTTP, and disk health checks with alert thresholds.

Why This Matters

Nagios operates on a model where manual configuration and custom plugins are essential for real-world use. Unlike idealized automated systems, real deployments require precise host/service definitions and plugin scripting, which can fail silently if misconfigured. For example, a miswritten plugin or incorrect threshold could lead to undetected disk overflows, risking server downtime.

Key Insights

Working Example

#!/bin/bash
DISK_USAGE=$(df / | grep / | awk '{print $5}' | sed 's/%//')
WARN=$1
CRIT=$2
if [ "$DISK_USAGE" -ge "$CRIT" ]; then
    echo "CRITICAL - Disk usage ${DISK_USAGE}% | usage=${DISK_USAGE}"
    exit 2
elif [ "$DISK_USAGE" -ge "$WARN" ]; then
    echo "WARNING - Disk usage ${DISK_USAGE}% | usage=${DISK_USAGE}"
    exit 1
else
    echo "OK - Disk usage ${DISK_USAGE}% | usage=${DISK_USAGE}"
    exit 0
fi

Practical Applications

  • Use Case: DevOps teams using Nagios for real-time server health monitoring
  • Pitfall: Overcomplicating config files with too many hosts/services, leading to maintenance challenges

References:


Continue reading

Next article

Quesby Automates SEO for Eleventy Sites Without Plugins or Runtime Code

Related Content