In this tutorial, you will learn how to add hosts to LibreNMS server for monitoring. LibreNMS is a fully featured MySQL/PHP and SNMP based network monitoring system.
Add Hosts to LibreNMS Server for Monitoring
If you haven’t installed LibreNMS server, you can check our guides on how to install and setup LibreNMS server.
Once you have LibreNMS server up and running, proceed to add hosts for monitoring.
Install SNMP on Hosts to Monitor
Before you can add hosts to LibreNMS server, you need to install and configure SNMP on the remote hosts to monitor.
You can use SNMP v3 or SNMP v2c as you so wish.
See sample guides on how to configure SNMP v2c and SNMP v3 on various hosts;
Install and Configure SNMP on Ubuntu 22.04/Debian 11
Install and Configure SNMP on Rocky Linux 8
There are two ways in which you can add hosts to LibreNMS server.
Add hosts to LibreNMS server via Web UI
- To begin with, ensure you can ping the host from the LibreNMS server.
fping 192.168.58.26
192.168.58.26 is alive
- Next, login to LibreNMS web interface and navigate to Devices > Add Device.
- Next;
- specify the hostname/IP of the remote host,
- SNMP: ON
- Turn it off if you just want to check aliveness of the host via ping. Also if the host doesn’t support SNMP.
- SNMP version, port and protocol.
- Port Association mode: We will leave the default: IfIndex.
- Configure specific SNMP version details.
LibreNMS hosts/devices using SNMP v2c sample configuration details;
LibreNMS hosts/devices using SNMP v3 sample configuration details;
You can check how to configure SNMP v3.
Click Add Device once done with settings configuration.
If all is well, the host will be added to LibreNMS server.
You can click on the host link to check host details;
To list all the devices, you can navigate to Devices > All Devices > Servers.
Add Host via Command Line
To add hosts via the command line, login to LibreNMS via SSH.
- Switch to librenms user;
sudo su - librenms
- Run the
./lnms device:add
command to add the hosts to LibreNMS server.
You can see how to use this command by reading the help page.
./lnms device:add --help
Description:
Add a new device
Usage:
device:add [options] [--]
Arguments:
device spec Hostname or IP to add
Options:
-1, --v1 Use SNMP v1
-2, --v2c Use SNMP v2c
-3, --v3 Use SNMP v3
-c, --community=COMMUNITY SNMP v1 or v2 community
-r, --port=PORT SNMP transport port [default: 161]
-t, --transport=TRANSPORT Transport to connect to the device [udp, udp6, tcp, tcp6] [default: "udp"]
-d, --display-name=DISPLAY-NAME A string to display as the name of this device, defaults to hostname.
May be a simple template using replacements: {{ $hostname }}, {{ $sysName }}, {{ $sysName_fallback }}, {{ $ip }}
-u, --security-name=SECURITY-NAME SNMPv3 security username [default: "root"]
-A, --auth-password=AUTH-PASSWORD SNMPv3 authentication password
-a, --auth-protocol=AUTH-PROTOCOL SNMPv3 authentication protocol [SHA, SHA-224, SHA-256, SHA-384, SHA-512, MD5] [default: "MD5"]
-X, --privacy-password=PRIVACY-PASSWORD SNMPv3 privacy password
-x, --privacy-protocol=PRIVACY-PROTOCOL SNMPv3 privacy protocol [AES, AES-192, AES-256, AES-256-C, DES] [default: "AES"]
-f, --force Just add the device, do not make any safety checks
-b, --ping-fallback Add the device as ping only if it does not respond to SNMP
-g, --poller-group=POLLER-GROUP commands.device:add.options.poller-group [default: 0]
-p, --port-association-mode=PORT-ASSOCIATION-MODE Sets how ports are mapped. ifName is suggested for Linux/Unix [ifIndex, ifName, ifDescr, ifAlias] [default: "ifIndex"]
-P, --ping-only Add a ping only device
-o, --os=OS Ping only: specify OS
-w, --hardware=HARDWARE Ping only: specify hardware
-s, --sysName=SYSNAME Ping only: specify sysName
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
- Add SNMP v2c Host via Command Line
If your host is using SNMP v2c, then run the command below to add it to LibreNMS server. Replace the string and the IP address accordingly.
./lnms device:add -2 -c Ex@mPL3 -r 161 -t udp 192.168.60.22
Sample output;
Added device 192.168.60.22 (4)
You can remove the device using ./lnms device:remove
.
./lnms device:remove --help
You can remove the device using ./lnms device:rename
.
./lnms device:rename --help
- Add SNMP v2 Host via Command Line
To add SNMP v3 host via command line, run the command below;
./lnms device:add -3 -u snmpadmin -A STrP@SSWRD -a SHA -X STr0ngP@SSWRD -x AES -r 161 -t udp 192.168.58.26
Replace the username, authentication password/protocol, privacy password/protocol, host IP accordingly.
You can then go back to the dashboard to view collected details about your hosts.
Sample memory health status.
You can also add the dashboard for various events under Overview > Dashboards.
That marks the end of our tutorial on how to monitor remote hosts with LibreNMS server.