Warning: is_dir(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/data/web/virtuals/98151/virtual) in /data/web/virtuals/98151/virtual/www/subdom/postgresql/wp-content/plugins/wp-simple-firewall/src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Fs.php on line 465

Warning: Cannot modify header information - headers already sent by (output started at /data/web/virtuals/98151/virtual/www/subdom/postgresql/wp-content/plugins/wp-simple-firewall/src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Fs.php:465) in /data/web/virtuals/98151/virtual/www/subdom/postgresql/wp-content/plugins/disable-xml-rpc-pingback/disable-xml-rpc-pingback.php on line 51
pg-barman - check HW config of a server / instance - PostgreSQL Candies

This simple script lists important HW info about a server or cloud instance + pg version + pg tablespaces in simple INI format. If you store output into file you can process it with other program to extract necessary info in even better form. These information you will need in case your server dies and you will have to know disks configuration and postgresql.

#!/usr/bin/env bash

pgserver=$(hostname -f)

echo "[config]"

echo "hostname=$pgserver"$'\n'

# cpu cores count
echo "cpu=$(grep -c ^processor /proc/cpuinfo)"$'\n'

# memory statistics
echo 'memory="""'
echo $'"""\n'

# /etc/fstab content
echo 'fstab="""'
cat /etc/fstab
echo $'"""\n'

# mounted disks by df
echo 'df="""'
echo $'"""\n'

#mounted disks by df in human readable form
echo 'df_h="""'
df -h
echo $'"""\n'

#mounted disks - system info
echo 'proc_mounts="""'
cat /proc/mounts
echo $'"""\n'

#postgresql tablespaces
psqlexists=$(command -v psql|wc -l)
if [[ $psqlexists -eq 1 ]]; then
  echo "postgresql=\"$(sudo su -c "psql -t -c \"select version()\"" postgres)\""$'\n'
  echo 'tablespaces="""'
  sudo su -c "psql -c \"select oid, spcname, pg_tablespace_location(oid) from pg_tablespace;\"" postgres
  echo $'"""\n'

  echo 'pg_directories="""'
  sudo su -c "psql -c \"select name,setting from pg_settings where name like '%dir%';\"" postgres
  echo $'"""\n'
  echo "postgresql=psql command not found"