Home > Cpanel/WHM > Find cpanel users with postgresql databases

Find cpanel users with postgresql databases

OBJECTIVE

Find out the users who are using postgresql databases. Also find out the number of postgresql databases used by each users.

SOLUTION
In cpanel the number of postgresql database’s used by each user is recorded in file
“/var/cpanel/datastore/username/postgres-db-count”. The following code snippet can used to find out users who is having postgresql databases and the number of database’s each one hold,

 ls /var/cpanel/datastore/*/postgres-db-count > pgsqlcount.txt
 for i in $(cat pgsqlcount.txt)
  do
   count=$(cat ${i})
   if [ $count -ne 0 ];then
   echo `echo ${i}|cut -d\/ -f5`:${count}
  fi
 done

Output will be in the format(username:number of postgres databases) pasted below:

aoflx:1
diom:2
ezop:12
foets:4
maesthri:1
meolan:3
neiatur:7
photo:1
quality:2
trentin:1


INFORMATION

Other files that might be of interest 🙂

/var/cpanel/datastore/username/postgres-disk-usage
/var/cpanel/datastore/username/mysql-db-count
/var/cpanel/datastore/username/mysql-db-usage
Advertisements
Categories: Cpanel/WHM
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: