VVelox 06b85f5b07 docs: more md linting (#10371)
* clean 1-Minute-Polling.md formatting

* cleanup formatting for Adding-a-Device.md

* clean up formatting of Cleanup-options.md

* cleanup formatting some for CLI-Tools.md

* cleanup formatting for Syslog.md and Configuration.md

* cleanup formatting for Device-Sensors.md

* cleanup formatting for Device-Troubleshooting.md

* cleanup Discovery Support.md

* cleanup Environment-Variables.md

* cleanup Example-Hardware-Setup.md and FAQ.mg

* update Features.md, Install Validation.md, Perfermance.md, Poller Support.md, and index.md

* cleanup Remote-Monitoring-VPN.md, SNMP-Configuration-Examples.md, and SSL-Configuration.md

* lots of updates for Installation docs

* more installation doc cleanup

* more formatting cleanup

* clean Work-Map.md up some
2019-07-18 21:25:53 -05:00

1.5 KiB

source: Support/CLI-Tools.md path: blob/master/doc/

Command line tools

Here's a brief list of command line tools, some might be missing. If you think something is missing, feel free to ask us or send a pull request :-)

purge-ports.php

This script provides CLI access to the "delete port" function of the WebUI. This might come in handy when trying to clean up old ports after large changes within the network or when hacking on the poller/discovery functions.

LibreNMS Port purge tool
-p port_id  Purge single port by it's port-id
-f file     Purge a list of ports, read port-ids from _file_, one on each line
            A filename of - means reading from STDIN.

Querying port IDs from the database

One simple way to obtain port IDs is by querying the SQL database.

If you wanted to query all deleted ports from the database, you could to this with the following query:

echo 'SELECT port_id, hostname, ifDescr FROM ports, devices WHERE devices.device_id = ports.device_id AND deleted = 1' | mysql -h your_DB_server -u your_DB_user -p --skip-column-names your_DB_name

When you are sure that the list of ports is correct and you want to delete all of them, you can write the list into a file and call purge-ports.php with that file as input:

echo 'SELECT port_id FROM ports, devices WHERE devices.device_id = ports.device_id AND deleted = 1' | mysql -h your_DB_server -u your_DB_user -p --skip-column-names your_DB_name > ports_to_delete
./purge-ports.php -f ports_to_delete