# Documentation:
#   https://collectd.org/wiki/index.php/Plugin:PostgreSQL

# System modifications:
#   Postgresql plugin use PostgreSQL's statistics collector which should be enabled by default.
#   The flags are 'track_activities' and 'track_counts'

# Config file modifications:
#   Change the hostname to location of the postgresql host, username and password.

LoadPlugin postgresql

<Plugin postgresql>
  <Query custom_deadlocks>
      Statement "SELECT deadlocks as num_deadlocks \
          FROM pg_stat_database \
          WHERE datname = $1;"

      Param database

      <Result>
          Type "pg_xact"
          InstancePrefix "num_deadlocks"
          ValuesFrom "num_deadlocks"
      </Result>
  </Query>

  <Database postgres>
    Host "%%%hostname%%%"
    User "%%%username%%%"
    Password "%%%password%%%"
    Query custom_deadlocks
    Query backends
    Query transactions
    Query queries
    Query queries_by_table
    Query query_plans
    Query table_states
    Query query_plans_by_table
    Query table_states_by_tables
    Query disk_io
    Query disk_io_by_table
    Query disk_usage
  </Database>
</Plugin>
