Mastering Network Infrastructure with LibreNMS: From Bandwidth Monitoring to Automated Telegram Alerts

Monitoring tutorial - IT technology blog
Monitoring tutorial - IT technology blog

Why I Chose LibreNMS Over Other Tools

Have you ever been in a situation where your boss is breathing down your neck, asking, “Why is the network so slow?” but you don’t have any concrete numbers in hand? In my early days as a SysAdmin, I often had to SSH into each Cisco switch and manually type show interfaces until my hands hurt, just to see which port was overloaded. This method was both slow and prone to missing critical information.

While Zabbix and Prometheus are powerful, for network devices specifically, LibreNMS is a real lifesaver. Its best feature is its incredibly smart auto-discovery capability. Just provide the IP, and LibreNMS will automatically scan, identify the model, and map out all network ports. You’ll save about 80% of configuration time compared to other tools.

Preparing the Installation Environment

To deploy quickly and avoid PHP library conflict errors, I recommend using Docker. This keeps the system clean and makes future upgrades easy.

Minimum configuration for smooth operation with about 30-50 devices:

  • Ubuntu 22.04 LTS Virtual Machine.
  • RAM: 4GB (LibreNMS is quite RAM-intensive when polling many devices).
  • CPU: 2 Cores.
  • Storage: 20GB SSD.
  • Docker and Docker Compose pre-installed.

Deploying LibreNMS with Docker Compose

First, create a dedicated directory to manage the configuration files:

mkdir librenms-docker && cd librenms-docker

Next, create the docker-compose.yml file. Use the command nano docker-compose.yml and paste the following content:

version: '3.5'

services:
  db:
    image: mariadb:10.5
    container_name: librenms_db
    volumes:
      - "./db:/var/lib/mysql"
    environment:
      - MYSQL_ROOT_PASSWORD=your_root_password
      - MYSQL_DATABASE=librenms
      - MYSQL_USER=librenms
      - MYSQL_PASSWORD=librenms_password
    restart: always

  redis:
    image: redis:6.0-alpine
    container_name: librenms_redis
    restart: always

  librenms:
    image: librenms/librenms:latest
    container_name: librenms
    ports:
      - "8000:80"
    volumes:
      - "./librenms:/data"
    environment:
      - TZ=Asia/Ho_Chi_Minh
      - PUID=1000
      - PGID=1000
      - DB_HOST=db
      - DB_NAME=librenms
      - DB_USER=librenms
      - DB_PASSWORD=librenms_password
      - REDIS_HOST=redis
    depends_on:
      - db
      - redis
    restart: always

Activate the system with a single command:

docker-compose up -d

After about 2 minutes, access http://your-ip:8000. The Web Installer interface will appear. Simply create an admin account and follow the “Next” prompts to finish.

Configuring SNMP on Target Devices

LibreNMS doesn’t use agents. It retrieves data via the SNMP protocol. Therefore, you need to “open the door” for SNMP on the devices you want to monitor.

For Linux Servers (Ubuntu/Debian)

Install the snmpd service package:

sudo apt update && sudo apt install snmpd -y

Open the /etc/snmp/snmpd.conf file. Find the community configuration line and modify it as follows for better security:

# Replace 'my-secret-string' with your SNMP password
rocommunity my-secret-string default

Restart to apply changes: sudo systemctl restart snmpd.

For Cisco Switches/Routers

On the Cisco CLI, simply perform a few quick steps:

conf t
snmp-server community my-secret-string RO
exit
write memory

Monitoring and Setting Up Alerts

Go back to the LibreNMS Dashboard, navigate to Devices -> Add Device. Enter the device IP, select SNMP v2c, and enter the my-secret-string you created. Click Add Device and wait about 5 minutes.

The system will automatically generate traffic graphs for each port. You can immediately see which ports are consuming the most bandwidth (Top Interfaces) or if a switch’s CPU is running unusually hot.

Receiving Alerts via Telegram

Monitoring by staring at a screen 24/7 is exhausting. Let LibreNMS alert you via Telegram when issues occur. Go to Alerts -> Transports, select Telegram, and enter your Bot API Token.

Don’t forget to activate the “Port state up -> down” rule. From now on, whenever a network cable is unplugged or a Switch loses power, your phone will notify you immediately.

Real-world Tips for a Stable System

After running it for a while, here are a few important notes to keep you out of trouble:

  • Control Polling: By default, the system retrieves data every 5 minutes. If you change this to 1 minute for real-time viewing, ensure your server has a strong enough CPU. With 100 devices, 1-minute polling can drive CPU load very high.
  • Database Cleanup: LibreNMS logs detailed data, which can quickly fill up your disk. Go to Global Settings -> Cleanup and limit log storage to 30 days to optimize space.
  • Avoid ‘public’ at all costs: Never use the default community string public. This is a vulnerability that allows hackers to scan your entire network configuration in seconds.

LibreNMS is an extremely reliable tool for IT professionals to deploy in offices or data centers. The feeling of mastering every bit of data flowing through your infrastructure is truly great. Good luck with your installation!

Share: