LibreNMS - LNMS Command Line Utility: Difference between revisions
Created page with "Category:Wiki == Overview == `lnms` is a command-line interface to interact with LibreNMS. The command is a wrapper around the core application, providing functionality to automate or quickly perform common tasks without the need for the web interface. This command is typically used on systems running LibreNMS where administrators may need to troubleshoot, configure, or automate tasks in a Linux environment. == Basic Command Syntax == The basic syntax for using th..." |
m Text replacement - "Category:Wiki" to "Category:Wiki '''''[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]''''' " |
||
| Line 1: | Line 1: | ||
[[Category:Wiki]] | [[Category:Wiki]] | ||
'''''[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]''''' | |||
== Overview == | == Overview == | ||
Latest revision as of 08:35, 17 January 2026
Overview
`lnms` is a command-line interface to interact with LibreNMS. The command is a wrapper around the core application, providing functionality to automate or quickly perform common tasks without the need for the web interface.
This command is typically used on systems running LibreNMS where administrators may need to troubleshoot, configure, or automate tasks in a Linux environment.
Basic Command Syntax
The basic syntax for using the `lnms` command is:
lnms <command> [options] [arguments]
Where `<command>` is one of the subcommands (e.g., `device`, `alert`, `user`) and the options/arguments modify the behavior of the command.
Common Commands
Device Management
The `device` subcommand is used to manage devices within LibreNMS.
List Devices
To list all devices in the LibreNMS database:
lnms device list
This will return a list of all devices, including their names, IPs, and status.
Add a Device
To add a device to LibreNMS, use the `add` subcommand with the device IP or hostname:
lnms device add <hostname_or_ip> --community <community_string> --snmp-version <version>
Example:
lnms device add 192.168.1.1 --community public --snmp-version v2c
This command adds the device with IP `192.168.1.1` using the `public` SNMP community string and SNMP version 2c.
Remove a Device
To remove a device from LibreNMS:
lnms device remove <device_id>
You can find the device ID by running `lnms device list`.
Alert Management
The `alert` subcommand allows interaction with LibreNMS alerts.
List Alerts
To view the current active alerts:
lnms alert list
This command displays a list of all active alerts, including their status and severity.
Acknowledge an Alert
To acknowledge a specific alert:
lnms alert ack <alert_id>
This will mark the alert with the given ID as acknowledged, typically meaning it has been reviewed or addressed.
Clear an Alert
To clear an alert after it has been resolved:
lnms alert clear <alert_id>
Example:
lnms alert clear 101
This command clears alert ID `101`.
User Management
The `user` subcommand provides tools for managing users within LibreNMS.
Add a User
To add a new user:
lnms user add <username> --password <password> --role <role>
Example:
lnms user add admin --password StrongPassword123 --role admin
This creates a new user `admin` with the specified password and assigns the user the `admin` role.
List Users
To list all users:
lnms user list
This will display all the users in LibreNMS, along with their roles.
Remove a User
To remove a user from LibreNMS:
lnms user remove <username>
Example:
lnms user remove admin
This removes the user `admin`.
Service Management
The `service` subcommand manages LibreNMS services.
Start a Service
To start a specific service (e.g., the poller):
lnms service start <service_name>
Example:
lnms service start poller
This starts the poller service.
Stop a Service
To stop a service:
lnms service stop <service_name>
Example:
lnms service stop poller
This stops the poller service.
Check Service Status
To check the status of a service:
lnms service status <service_name>
Example:
lnms service status poller
This displays the current status of the poller service.
Configuration Management
The `config` subcommand allows managing various system configuration settings.
View Current Configuration
To view the current system configuration:
lnms config show
This will display the current configuration settings for LibreNMS.
Edit Configuration
To edit the LibreNMS configuration:
lnms config edit
This opens the configuration editor, allowing you to modify settings like database connections, poller settings, and other system parameters.
Network Discovery
The `discover` subcommand is used to run network discovery.
Run Discovery
To run a network discovery scan:
lnms discover --force
This command forces a discovery of all devices, even if discovery is already scheduled or completed recently.
Run Discovery for Specific IP Range
To run discovery for a specific IP range:
lnms discover --ip <start_ip> <end_ip>
Example:
lnms discover --ip 192.168.1.1 192.168.1.255
This will discover devices within the IP range `192.168.1.1` to `192.168.1.255`.
Advanced Features
Data Collection
LibreNMS can be configured to collect additional data points, such as syslog entries, SNMP traps, or custom device data. To enable advanced data collection features, use the following:
lnms config set collect_syslog true lnms config set collect_traps true
These settings enable the collection of syslog messages and SNMP traps from devices.
Poller Management
LibreNMS uses pollers to gather performance metrics and device status information. You can scale and manage pollers via the following commands:
Check Poller Status
To check the status of the pollers:
lnms poller status
Run a Specific Poller
To run a specific poller manually:
lnms poller run <poller_id>
Example:
lnms poller run 1
This manually triggers poller ID `1`.
