Nagios vs OpenNMS: Technical Comparison for Linux/BSD Server Monitoring Implementation


2 views

At their core, Nagios (C/C++ based) and OpenNMS (Java-based) represent fundamentally different architectural approaches:


// Nagios plugin structure example (Bash)
#!/bin/bash
check_disk() {
  threshold=90
  usage=$(df -h / | awk 'NR==2 {print $5}' | tr -d '%')
  [ $usage -ge $threshold ] && echo "CRITICAL" || echo "OK"
}

OpenNMS leverages JVM capabilities for distributed monitoring:


// Sample OpenNMS detector (Java snippet)
@Service(name = "SSHDetector")
public class SSHDetector extends AbstractServiceDetector {
  @Override
  public boolean isServiceDetected(InetAddress host) {
    try (Socket s = new Socket(host, 22)) {
      return s.getInputStream().read() != -1;
    }
  }
}

Nagios uses text-based configs with explicit dependencies:


# Sample Nagios host definition
define host {
  host_name        fileserver01
  alias            Primary File Server
  address          192.168.1.10
  check_command    check-host-alive
  max_check_attempts 3
}

OpenNMS employs XML configurations with discovery automation:


<!-- OpenNMS discovery config snippet -->
<detectors>
  <detector name="SNMP" class="org.opennms.netmgt.provision.detector.snmp.SnmpDetector"/>
  <detector name="HTTP" class="org.opennms.netmgt.provision.detector.http.HttpDetector">
    <parameter key="port" value="80"/>
  </detector>
</detectors>

For your FreeBSD monitoring host with 6 on-site and 2 remote servers:

  • Nagios: ~50MB RAM baseline, scales linearly with checks
  • OpenNMS: 1GB+ JVM heap minimum, grows with discovered nodes

Nagios uses state-based alerts:


# Notification command example
define command {
  command_name    notify-by-email
  command_line    /usr/bin/printf "%b" "$NOTIFICATIONTYPE$: $HOSTNAME$" | mail -s "$HOSTNAME$ $SERVICESTATE$" $CONTACTEMAIL$
}

OpenNMS provides correlation engine:


<!-- Event correlation rule example -->
<correlation>
  <rule name="SwitchLinkFailure">
    <criteria>
      <eventuei match="any">
        <uei>uei.opennms.org/nodes/nodeDown</uei>
        <uei>uei.opennms.org/traps/linkDown</uei>
      </eventuei>
    </criteria>
    <action type="notification">
      <target>admin@example.com</target>
    </action>
  </rule>
</correlation>

For your mixed environment (PBX, proxies, BSD servers):

  1. Nagios excels at:
    • Script-based custom checks (e.g., Asterisk PBX monitoring)
    • Lightweight infrastructure with clear service dependencies
  2. OpenNMS shines for:
    • Auto-discovery of network topology
    • SNMP-capable devices (switches/routers)

Nagios Core is written in C with plugins primarily using shell scripts (Bash), Perl, or Python. This makes it lightweight and ideal for FreeBSD systems. OpenNMS, being Java-based, requires JVM overhead which can be problematic on resource-constrained systems.

# Sample Nagios plugin structure
#!/bin/bash
check_http -H example.com -p 80 -u /status -e 'HTTP/1.1 200'
exit $?

OpenNMS excels at automated network discovery using protocols like SNMP:

# OpenNMS discovery configuration snippet
<discovery-configuration 
  packets-per-second="1" 
  initial-sleep-time="30000"
  restart-sleep-time="86400000">
  <include-range begin="192.168.1.1" end="192.168.1.254"/>
</discovery-configuration>

Nagios requires manual host/service definitions or external tools like Nmap for discovery:

# Nagios host definition example
define host {
    host_name        fileserver01
    alias            Primary File Server
    address          192.168.1.10
    use              linux-server
    max_check_attempts 5
}

For your environment (6 on-prem servers + 2 cloud instances):

Feature Nagios OpenNMS
SNMP Monitoring Requires plugins Native support
Service Checks Excellent Good
Distributed Monitoring Needs addons Built-in
BSD Compatibility Proven JVM-dependent

Given your FreeBSD constraint, Nagios installation is straightforward:

# Install Nagios on FreeBSD
pkg install nagios4
sysrc nagios_enable=YES
cp /usr/local/etc/nagios/nagios.cfg.sample /usr/local/etc/nagios/nagios.cfg
service nagios start

For your PBX server monitoring (assuming Asterisk):

# Custom Nagios check for Asterisk
#!/usr/bin/env python
import asterisk.manager
manager = asterisk.manager.Manager()
manager.connect('localhost')
manager.login('nagios', 'secret')
status = manager.command('core show channels')
print(status.data)
manager.close()

Both support graphing through addons:

  • Nagios: Grafana + PNP4Nagios
  • OpenNMS: Built-in JRobin charts

For your specific FreeBSD-based monitoring node with 8 servers:

  1. Choose Nagios if: You need lightweight operation and direct BSD compatibility
  2. Consider OpenNMS if: You anticipate significant growth beyond 20 nodes