Applicable to:
- Plesk for Linux
- Plesk for Windows
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:
-
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:
CONFIG_TEXT: +-----------+-----------------+-------+-----------------------+
| 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:
CONFIG_TEXT: +-----------+-------+-------+-----------+-----------------+-------+-----------------------+
| 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.org | 1 | 203.0.113.2 |
| 2 | John | jdoe | 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 cl.id, cl.pname, cl.login, d.id, d.name, ipc.ipAddressId, ip.ip_address 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"
-
-
Connect to the server via RDP
-
Run one of the following commands to retrieve the necessary information:
-
Get a list of domains and their IP addresses:
C:\> 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:
CONFIG_TEXT: +-----------+-----------------+-------+-----------------------+
| 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:
C:\> 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:
C:\> 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:
CONFIG_TEXT: +-----------+-------+-------+-----------+-----------------+-------+-----------------------+
| 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.org | 1 | 203.0.113.2 |
| 2 | John | jdoe | 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:
C:\> plesk db -Ne "SELECT cl.id, cl.pname, cl.login, d.id, d.name, ipc.ipAddressId, ip.ip_address 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"
-
Comments
2 comments
Very useful. One can also execute the following to see the exact domains being counted for Plesk License: plesk db "SELECT id,name FROM psa.domains WHERE parentDomainId = 0"
Inspired from this answer.
Is there a way to find which customers (domains) have one or more databases?
Please sign in to leave a comment.