Question
How to get a list of customers, domains and their IP addresses from the Plesk database?
Answer
It is possible to retrieve corresponding information from the Plesk database via the command-line interface:
Plesk For Linux
-
Connect to the server via SSH
-
Run one of the following commands to retrieve the necessary information:
-
Get a list of domains and their IP addresses:
# plesk db "SELECT d.id AS 'Domain ID', d.name AS 'Domain', ipc.ipAddressId AS 'IP ID', ip.ip_address AS 'IPv4/IPv6' FROM domains d, DomainServices ds, IpAddressesCollections ipc, IP_Addresses ip WHERE d.id = ds.dom_id AND ds.type = 'web' AND ds.ipCollectionId = ipc.ipCollectionId AND ip.id = ipc.ipAddressId ORDER BY d.id ASC"
The output of the command will look as follows:
+-----------+-----------------+-------+-----------------------+
| Domain ID | Domain | IP ID | IPv4/IPv6 |
+-----------+-----------------+-------+-----------------------+
| 1 | example.com | 1 | 203.0.113.2 |
| 2 | sub.example.com | 1 | 203.0.113.2 |
| 3 | example.org | 1 | 203.0.113.2 |
| 3 | example.org | 2 | 2001:db8:f61:a1ff::80 |
+-----------+-----------------+-------+-----------------------+If it's necessary to retrieve the content without box/table format, run this command instead:
# plesk db -Ne "SELECT d.id, d.name, ipc.ipAddressId, ip.ip_address FROM domains d, DomainServices ds, IpAddressesCollections ipc, IP_Addresses ip WHERE d.id = ds.dom_id AND ds.type = 'web' AND ds.ipCollectionId = ipc.ipCollectionId AND ip.id = ipc.ipAddressId ORDER BY d.id ASC"
-
Get a list of customers, domains and their IP addresses:
# plesk db "SELECT cl.id AS 'Client ID', cl.pname AS 'Name', cl.login AS 'Login', d.id AS 'Domain ID', d.name AS 'Domain', ipc.ipAddressId AS 'IP ID', ip.ip_address AS 'IPv4/IPv6' FROM clients cl, domains d, DomainServices ds, IpAddressesCollections ipc, IP_Addresses ip WHERE d.id = ds.dom_id AND d.cl_id = cl.id AND ds.type = 'web' AND ds.ipCollectionId = ipc.ipCollectionId AND ip.id = ipc.ipAddressId ORDER BY cl.id ASC"
The output of the command will look as follows:
+-----------+-------+-------+-----------+-----------------+-------+-----------------------+
| Client ID | Name | Login | Domain ID | Domain | IP ID | IPv4/IPv6 |
+-----------+-------+-------+-----------+-----------------+-------+-----------------------+
| 1 | Admin | admin | 1 | example.com | 1 | 203.0.113.2 |
| 1 | Admin | admin | 2 | sub.example.com | 1 | 203.0.113.2 |
| 2 | John | jdoe | 3 | example…
-