2017-11-09 13:57:41 +01:00
|
|
|
source: Support/CLI-Tools.md
|
2018-10-27 23:04:34 +01:00
|
|
|
path: blob/master/doc/
|
2019-07-18 21:25:53 -05:00
|
|
|
|
|
|
|
# Command line tools
|
2017-11-09 13:57:41 +01:00
|
|
|
|
|
|
|
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 :-)
|
|
|
|
|
2019-07-18 21:25:53 -05:00
|
|
|
# purge-ports.php
|
2017-11-09 13:57:41 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2019-07-18 21:25:53 -05:00
|
|
|
```
|
2017-11-09 13:57:41 +01:00
|
|
|
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.
|
2019-07-18 21:25:53 -05:00
|
|
|
```
|
2017-11-09 13:57:41 +01:00
|
|
|
|
2019-07-18 21:25:53 -05:00
|
|
|
# Querying port IDs from the database
|
2017-11-09 13:57:41 +01:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
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
|
|
|
|
```
|
|
|
|
|
2019-07-18 21:25:53 -05:00
|
|
|
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:
|
2017-11-09 13:57:41 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
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
|
|
|
|
```
|