Articles in this section

How to get a list of customers, domains and their IP addresses from the Plesk database?

Plesk for Windows kb: how-to Plesk for Linux ABT: Group A

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:

Plesk For Linux
  1. Connect to the server via SSH

  2. 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"

Plesk For Windows
  1. Connect to the server via RDP

  2. Start a command prompt as Administrator

  3. 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"

Was this article helpful?

Comments

2 comments
Date Votes
  • 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.

    0
  • Is there a way to find which customers (domains) have one or more databases?

    0

Please sign in to leave a comment.