Observium Network Monitoring: Install, Poll and Add Devices - 夜莺博客

Observium Network Monitoring: Install, Poll and Add Devices

Observium is the older, quieter cousin of LibreNMS: an SNMP polling and graphing platform with a low-friction setup and a device-centric interface. It is a good fit when you want interface graphs and device health without deploying a full monitoring stack, and its MIB handling is explicit enough to teach you what is actually happening on the wire. This guide covers the install on Debian or Ubuntu, adding devices, and verifying that polling is genuinely working.

Install

sudo apt update
sudo apt install -y apache2 libapache2-mod-php php-cli php-mysql php-mbstring \
  php-gd php-curl php-snmp php-xml mariadb-server snmp snmp-mibs-downloader \
  rrdtool fping graphviz imagemagick mtr-tiny nmap python3 python3-mysqldb \
  whois subversion

Then fetch the code. Observium publishes a stable SVN branch; the community edition is the free tier, with a paid subscription giving you access to the automated release repository and extra features.

cd /opt
sudo svn co https://svn.observium.org/svn/observium/branches/stable observium
cd observium

Database and Initial Setup

sudo mysql -e "CREATE DATABASE observium DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
sudo mysql -e "CREATE USER 'observium'@'localhost' IDENTIFIED BY 'strong-password';"
sudo mysql -e "GRANT ALL PRIVILEGES ON observium.* TO 'observium'@'localhost';"
sudo mysql -e "FLUSH PRIVILEGES;"

sudo cp config.php.default config.php
sudo -e config.php   # set $config['db_user'], $config['db_pass'], $config['db_host']
cd /opt/observium
sudo ./discovery.php -u            # create/update schema
sudo ./adduser.php admin 'password' 10

MIB Paths: Why Your OIDs Do Not Resolve

A MIB is a definition file that gives OIDs names, types and table structure — it holds no device data. Net-SNMP translates between names and numbers using an ordered directory list supplied with -M. Observium keeps its MIBs under /opt/observium/mibs:

/opt/observium/mibs/rfc
/opt/observium/mibs/net-snmp
/opt/observium/mibs/cisco

When a vendor and an RFC directory contain a module with the same name, whichever comes first in the list wins. That ordering is the reason a query that works from the shell prints numbers instead of names in the web UI.

Query a Device Before Adding It

# Translate a name to a numeric OID (no device contact)
snmptranslate -Pud -Ir -On -m 'IF-MIB' -M '/opt/observium/mibs/rfc:/opt/observium/mibs/net-snmp' 'IF-MIB::ifOperStatus'

# Read one scalar
snmpget -v2c -c 'community' -OQUv -m 'SNMPv2-MIB' 'udp:10.10.20.1:161' 'SNMPv2-MIB::sysUpTime.0'

# Walk an interface table efficiently
snmpbulkwalk -v2c -c 'community' -OQUs -m 'IF-MIB' 'udp:10.10.20.1:161' 'IF-MIB::ifTable'

# SNMPv3, the right choice in production
snmpwalk -v3 -l authPriv -u monitor -a SHA -A 'AuthPass' -x AES -X 'PrivPass' 10.10.20.1 sysDescr.0

Use snmpbulkwalk rather than snmpwalk whenever the device supports SNMPv2c or v3 — it retrieves rows in bulk and turns a slow walk into a fast one. Reserve plain snmpwalk for SNMPv1 or agents with broken bulk support.

Add Devices

From the web UI: Devices → Add Device, enter hostname/IP, SNMP version and community (or v3 credentials), and select a device template if you want a specific OS definition to be used at discovery time.

Bulk additions go through the CLI, which is far faster when onboarding a rack:

cd /opt/observium
./add_device.php --list-device-types
./add_device.php   v2c

Then run discovery and polling manually once so you are not waiting on cron:

./discovery.php -h all
./poller.php -h all
./poller.php -h new

Enable the Agent for Linux Hosts

SNMP alone cannot tell you about disk usage per mount or running processes on a server. Install the Observium agent over xinetd and enable the unix-agent module on the device or globally:

sudo apt install -y snmpd xinetd
# On the device: allow your Observium server as an agent client
sudo cp /opt/observium/scripts/observium_agent_xinetd /etc/xinetd.d/observium_agent
sudo nano /etc/xinetd.d/observium_agent     # set only_from = 
sudo cp /opt/observium/scripts/observium_agent /usr/bin/observium_agent
sudo mkdir -p /usr/lib/observium_agent/local
sudo systemctl restart xinetd
# config.php on the Observium server
$config['poller_modules']['unix-agent'] = 1;

Automate the Polling

# /etc/cron.d/observium
33 */6 * * *   root  cd /opt/observium && ./discovery.php -h all >> /dev/null 2>&1
*/5 * * * *   root  cd /opt/observium && ./poller.php -h all >> /dev/null 2>&1

Discovery every six hours, polling every five minutes, is the conventional split: polling collects counters, discovery rebuilds the inventory of what exists.

Verifying That It Works

./poller.php -h  -d | head -80    # -d shows per-module debug
tail -f logs/observium.log

Cross-check in the UI under Device → Metrics: if snmpwalk returns counters from the shell but the graph is flat, the device is being polled — you are simply looking at a counter that is ifIndex-dependent and the discovery step did not re-index it. Run ./discovery.php -h <host> again after an interface change on the device.

Related Reading

Deeper dives on the same topics from our archive:

原文链接:https://docs.observium.org/install_debian