Network Monitoring Setup

Comprehensive guide to implementing network monitoring and management solutions
Network Administration Intermediate 30 min read

Overview

This comprehensive guide covers essential network monitoring setup and configuration using popular tools like Nagios, Zabbix, PRTG, and open-source solutions. Learn how to monitor network performance, set up alerts, and implement comprehensive network management solutions.

Quick Reference

  • Monitoring Tools: Nagios, Zabbix, PRTG, LibreNMS
  • SNMP Configuration: Community strings, MIBs, OIDs
  • Alerting: Email, SMS, webhook notifications
  • Dashboards: Grafana, custom web interfaces

1. Network Monitoring Fundamentals

1.1 Monitoring Types

Understanding different types of network monitoring and their applications.

Monitoring Categories:

  • Availability Monitoring: Device uptime, service availability
  • Performance Monitoring: Bandwidth usage, latency, packet loss
  • Traffic Analysis: Flow analysis, protocol distribution
  • Security Monitoring: Intrusion detection, anomaly detection
  • Capacity Planning: Resource utilization, growth trends

1.2 SNMP Configuration

Setting up SNMP for network device monitoring.

SNMP Agent Configuration (Linux):

# Install SNMP agent
sudo apt install snmpd snmp-mibs-downloader

# Configure SNMP agent
sudo nano /etc/snmp/snmpd.conf

# Basic configuration
agentAddress udp:161
rocommunity public 127.0.0.1
rocommunity public 192.168.1.0/24
sysLocation "Data Center"
sysContact "admin@company.com"
sysName "monitoring-server"

# Restart SNMP service
sudo systemctl restart snmpd
sudo systemctl enable snmpd

# Test SNMP
snmpwalk -v2c -c public localhost 1.3.6.1.2.1.1.1

SNMP Community Strings:

# Create SNMP community with access control
rocommunity public 192.168.1.0/24
rocommunity monitoring 10.0.0.0/8
rwcommunity admin 127.0.0.1

# SNMPv3 configuration
createUser monitoring SHA "password123" AES "password123"
rouser monitoring priv

2. Nagios Monitoring Setup

2.1 Nagios Installation

Installing and configuring Nagios Core for network monitoring.

Nagios Core Installation:

#!/bin/bash
# nagios_install.sh

# Update system
sudo apt update && sudo apt upgrade -y

# Install dependencies
sudo apt install -y build-essential apache2 php libapache2-mod-php7.4 \
    php-gd libgd-dev sendmail wget unzip

# Create nagios user
sudo useradd -m -s /bin/bash nagios
sudo groupadd nagios
sudo usermod -a -G nagios www-data

# Download and install Nagios
cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
tar xzf nagios-4.4.6.tar.gz
cd nagios-4.4.6

# Configure and compile
./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
sudo make install
sudo make install-init
sudo make install-commandmode
sudo make install-config

# Install Nagios plugins
cd /tmp
wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
tar xzf nagios-plugins-2.3.3.tar.gz
cd nagios-plugins-2.3.3

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install

# Configure Apache
sudo a2enmod rewrite cgi
sudo systemctl restart apache2

# Start Nagios
sudo systemctl start nagios
sudo systemctl enable nagios

2.2 Nagios Configuration

Configuring Nagios for network device monitoring.

Host Configuration:

# /usr/local/nagios/etc/objects/hosts.cfg
define host {
    use                     linux-server
    host_name               router-01
    alias                   Core Router
    address                 192.168.1.1
    check_command           check-host-alive
    max_check_attempts      3
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   30
    notification_period     24x7
    notification_options    d,u,r
    contact_groups          admins
}

define host {
    use                     generic-switch
    host_name               switch-01
    alias                   Access Switch
    address                 192.168.1.10
    check_command           check-host-alive
    max_check_attempts      3
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   30
    notification_period     24x7
    notification_options    d,u,r
    contact_groups          admins
}

Service Configuration:

# /usr/local/nagios/etc/objects/services.cfg
define service {
    use                     generic-service
    host_name               router-01
    service_description     PING
    check_command           check_ping!100.0,20%!500.0,60%
    max_check_attempts      3
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   30
    notification_period     24x7
    notification_options    w,u,c,r
    contact_groups          admins
}

define service {
    use                     generic-service
    host_name               router-01
    service_description     SSH
    check_command           check_ssh
    max_check_attempts      3
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   30
    notification_period     24x7
    notification_options    w,u,c,r
    contact_groups          admins
}

define service {
    use                     generic-service
    host_name               switch-01
    service_description     SNMP
    check_command           check_snmp!-C public -o sysUpTime.0
    max_check_attempts      3
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   30
    notification_period     24x7
    notification_options    w,u,c,r
    contact_groups          admins
}

3. Zabbix Monitoring Setup

3.1 Zabbix Installation

Installing and configuring Zabbix for comprehensive network monitoring.

Zabbix Server Installation:

#!/bin/bash
# zabbix_install.sh

# Install Zabbix repository
wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4+ubuntu20.04_all.deb
sudo dpkg -i zabbix-release_6.0-4+ubuntu20.04_all.deb
sudo apt update

# Install Zabbix server and agent
sudo apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf \
    zabbix-sql-scripts zabbix-agent

# Install MySQL
sudo apt install -y mysql-server

# Create Zabbix database
sudo mysql -e "CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;"
sudo mysql -e "CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password';"
sudo mysql -e "GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';"
sudo mysql -e "FLUSH PRIVILEGES;"

# Import Zabbix database schema
sudo zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | \
    mysql -u zabbix -p zabbix

# Configure Zabbix server
sudo nano /etc/zabbix/zabbix_server.conf
# Set DBPassword=password

# Start Zabbix services
sudo systemctl restart zabbix-server zabbix-agent apache2
sudo systemctl enable zabbix-server zabbix-agent apache2

3.2 Zabbix Configuration

Configuring Zabbix for network device monitoring.

Host Configuration via API:

#!/bin/bash
# zabbix_host_config.sh

ZABBIX_URL="http://localhost/zabbix/api_jsonrpc.php"
ZABBIX_USER="Admin"
ZABBIX_PASS="zabbix"

# Get authentication token
AUTH_TOKEN=$(curl -s -X POST \
    -H "Content-Type: application/json" \
    -d '{
        "jsonrpc": "2.0",
        "method": "user.login",
        "params": {
            "user": "'$ZABBIX_USER'",
            "password": "'$ZABBIX_PASS'"
        },
        "id": 1
    }' \
    $ZABBIX_URL | jq -r '.result')

# Create host group
curl -s -X POST \
    -H "Content-Type: application/json" \
    -d '{
        "jsonrpc": "2.0",
        "method": "hostgroup.create",
        "params": {
            "name": "Network Devices"
        },
        "auth": "'$AUTH_TOKEN'",
        "id": 1
    }' \
    $ZABBIX_URL

# Create host
curl -s -X POST \
    -H "Content-Type: application/json" \
    -d '{
        "jsonrpc": "2.0",
        "method": "host.create",
        "params": {
            "host": "router-01",
            "name": "Core Router",
            "interfaces": [
                {
                    "type": 2,
                    "main": 1,
                    "useip": 1,
                    "ip": "192.168.1.1",
                    "dns": "",
                    "port": "161"
                }
            ],
            "groups": [
                {
                    "groupid": "1"
                }
            ],
            "templates": [
                {
                    "templateid": "10001"
                }
            ]
        },
        "auth": "'$AUTH_TOKEN'",
        "id": 1
    }' \
    $ZABBIX_URL

4. LibreNMS Monitoring Setup

4.1 LibreNMS Installation

Installing LibreNMS for open-source network monitoring.

LibreNMS Installation Script:

#!/bin/bash
# librenms_install.sh

# Update system
sudo apt update && sudo apt upgrade -y

# Install dependencies
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

sudo apt install -y nginx php8.1-fpm php8.1-cli php8.1-mysql php8.1-gd \
    php8.1-snmp php8.1-curl php8.1-mbstring php8.1-xml php8.1-zip \
    php8.1-json php8.1-gmp php8.1-bcmath php8.1-ldap php8.1-imap \
    php8.1-common php8.1-curl php8.1-zip php8.1-dev php8.1-pear \
    php8.1-memcached php8.1-redis php8.1-bcmath php8.1-gd \
    php8.1-mysql php8.1-xml php8.1-cli php8.1-common php8.1-curl \
    php8.1-zip unzip git fping composer mtr-tiny nmap python3-mysqldb \
    snmp snmpd python3-pip python3-dev python3-venv python3-wheel \
    libpython3-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev \
    libfreetype6-dev libjpeg62-turbo-dev libpng-dev zlib1g-dev \
    libzip-dev libonig-dev libc6-dev libreadline-dev libsqlite3-dev \
    libbz2-dev libncurses5-dev libncursesw5-dev xz-utils tk-dev \
    libffi-dev liblzma-dev python3-openssl git

# Install MySQL
sudo apt install -y mysql-server

# Create LibreNMS database
sudo mysql -e "CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
sudo mysql -e "CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password';"
sudo mysql -e "GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';"
sudo mysql -e "FLUSH PRIVILEGES;"

# Create LibreNMS user
sudo useradd -m -s /bin/bash librenms
sudo usermod -a -G librenms www-data

# Download LibreNMS
cd /opt
sudo git clone https://github.com/librenms/librenms.git
sudo chown -R librenms:librenms /opt/librenms
sudo chmod 771 /opt/librenms

# Install PHP dependencies
cd /opt/librenms
sudo -u librenms ./scripts/composer_wrapper.php install --no-dev

# Set permissions
sudo chown -R librenms:librenms /opt/librenms
sudo chmod -R 775 /opt/librenms
sudo setfacl -d -m g::775 /opt/librenms/rrd
sudo setfacl -d -m g::775 /opt/librenms/logs
sudo setfacl -R -m g::775 /opt/librenms/rrd
sudo setfacl -R -m g::775 /opt/librenms/logs

# Configure web server
sudo cp /opt/librenms/dist/librenms.conf /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/librenms.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

# Run installation script
sudo -u librenms php /opt/librenms/scripts/generate-config.php

# Start services
sudo systemctl restart nginx
sudo systemctl restart php8.1-fpm

4.2 LibreNMS Configuration

Configuring LibreNMS for network device discovery and monitoring.

Device Discovery:

# Add device via CLI
sudo -u librenms php /opt/librenms/addhost.php 192.168.1.1 public v2c

# Add device via web interface
# Go to http://your-server/librenms/
# Click on "Add Device" and enter:
# - Hostname: 192.168.1.1
# - Community: public
# - Version: v2c
# - Port: 161

# Configure SNMP for device discovery
sudo nano /etc/snmp/snmpd.conf
# Add:
# rocommunity public 192.168.1.0/24
# rocommunity monitoring 10.0.0.0/8

# Restart SNMP service
sudo systemctl restart snmpd

5. Grafana Dashboard Setup

5.1 Grafana Installation

Installing and configuring Grafana for network monitoring dashboards.

Grafana Installation:

#!/bin/bash
# grafana_install.sh

# Install Grafana
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

sudo apt update
sudo apt install -y grafana

# Start and enable Grafana
sudo systemctl start grafana-server
sudo systemctl enable grafana-server

# Configure Grafana
sudo nano /etc/grafana/grafana.ini
# Set:
# [server]
# http_port = 3000
# [security]
# admin_user = admin
# admin_password = admin

# Restart Grafana
sudo systemctl restart grafana-server

5.2 Grafana Dashboard Configuration

Creating network monitoring dashboards in Grafana.

Dashboard JSON Configuration:

{
  "dashboard": {
    "id": null,
    "title": "Network Monitoring Dashboard",
    "tags": ["network", "monitoring"],
    "timezone": "browser",
    "panels": [
      {
        "id": 1,
        "title": "Network Traffic",
        "type": "graph",
        "targets": [
          {
            "expr": "rate(node_network_receive_bytes_total[5m])",
            "legendFormat": "{{device}} - RX"
          },
          {
            "expr": "rate(node_network_transmit_bytes_total[5m])",
            "legendFormat": "{{device}} - TX"
          }
        ],
        "yAxes": [
          {
            "label": "Bytes/sec",
            "min": 0
          }
        ],
        "xAxes": [
          {
            "type": "time"
          }
        ]
      },
      {
        "id": 2,
        "title": "Ping Latency",
        "type": "graph",
        "targets": [
          {
            "expr": "probe_duration_seconds",
            "legendFormat": "{{instance}}"
          }
        ],
        "yAxes": [
          {
            "label": "Latency (ms)",
            "min": 0
          }
        ]
      },
      {
        "id": 3,
        "title": "Device Status",
        "type": "stat",
        "targets": [
          {
            "expr": "up",
            "legendFormat": "{{instance}}"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "mappings": [
              {
                "type": "value",
                "value": "1",
                "text": "UP"
              },
              {
                "type": "value",
                "value": "0",
                "text": "DOWN"
              }
            ]
          }
        }
      }
    ],
    "time": {
      "from": "now-1h",
      "to": "now"
    },
    "refresh": "5s"
  }
}

6. Alerting and Notifications

6.1 Email Notifications

Setting up email notifications for network alerts.

Nagios Email Configuration:

# /usr/local/nagios/etc/objects/contacts.cfg
define contact {
    contact_name                    nagiosadmin
    use                            generic-contact
    alias                          Nagios Administrator
    email                          admin@company.com
}

define contactgroup {
    contactgroup_name              admins
    alias                          Administrators
    members                        nagiosadmin
}

# /usr/local/nagios/etc/objects/commands.cfg
define command {
    command_name                   notify-host-by-email
    command_line                   /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

define command {
    command_name                   notify-service-by-email
    command_line                   /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}

6.2 Webhook Notifications

Setting up webhook notifications for modern alerting systems.

Slack Webhook Configuration:

#!/bin/bash
# slack_notification.sh

SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"
ALERT_TYPE="$1"
HOST_NAME="$2"
SERVICE_NAME="$3"
STATE="$4"
OUTPUT="$5"

# Create Slack message
MESSAGE="{
    \"text\": \"Network Alert\",
    \"attachments\": [
        {
            \"color\": \"danger\",
            \"fields\": [
                {
                    \"title\": \"Alert Type\",
                    \"value\": \"$ALERT_TYPE\",
                    \"short\": true
                },
                {
                    \"title\": \"Host\",
                    \"value\": \"$HOST_NAME\",
                    \"short\": true
                },
                {
                    \"title\": \"Service\",
                    \"value\": \"$SERVICE_NAME\",
                    \"short\": true
                },
                {
                    \"title\": \"State\",
                    \"value\": \"$STATE\",
                    \"short\": true
                },
                {
                    \"title\": \"Output\",
                    \"value\": \"$OUTPUT\",
                    \"short\": false
                }
            ]
        }
    ]
}"

# Send to Slack
curl -X POST -H 'Content-type: application/json' \
    --data "$MESSAGE" \
    $SLACK_WEBHOOK_URL

7. Network Flow Analysis

7.1 NetFlow Configuration

Setting up NetFlow for network traffic analysis.

Cisco Router NetFlow Configuration:

# Configure NetFlow on Cisco router
configure terminal

# Enable NetFlow on interfaces
interface GigabitEthernet0/0
 ip flow ingress
 ip flow egress
exit

interface GigabitEthernet0/1
 ip flow ingress
 ip flow egress
exit

# Configure NetFlow export
ip flow-export version 9
ip flow-export destination 192.168.1.100 9996
ip flow-export source GigabitEthernet0/0
ip flow-export template timeout-rate 1

# Configure NetFlow cache
ip flow-cache timeout active 1
ip flow-cache timeout inactive 15
ip flow-cache entries 32768

# Enable NetFlow on VRF (if applicable)
ip flow-export version 9 vrf VRF_NAME destination 192.168.1.100 9996

end

7.2 ntopng Installation

Installing ntopng for network traffic analysis.

ntopng Installation:

#!/bin/bash
# ntopng_install.sh

# Install dependencies
sudo apt update
sudo apt install -y wget curl gnupg2 software-properties-common apt-transport-https ca-certificates

# Add ntopng repository
wget https://packages.ntop.org/apt/ntop.key
sudo apt-key add ntop.key
echo "deb https://packages.ntop.org/apt/20.04/amd64/ ./" | sudo tee /etc/apt/sources.list.d/ntop.list

# Install ntopng
sudo apt update
sudo apt install -y ntopng

# Configure ntopng
sudo nano /etc/ntopng/ntopng.conf
# Add:
# -i=eth0
# -w=3000
# -P=/var/lib/ntopng/ntopng.pid
# -d=/var/lib/ntopng
# -e

# Start ntopng
sudo systemctl start ntopng
sudo systemctl enable ntopng

# Access web interface
# http://your-server:3000
# Default username: admin
# Default password: admin

Download the Complete Guide

Get the full PDF version with additional monitoring configurations, alerting setups, and troubleshooting procedures.

Download PDF