5.34. postgres

The postgres module allows queries to be performaed against targets as checks. The results of the query are used as metrics.

loader

C

image

postgres.so

5.34.1. Module Configuration

5.34.2. Check Configuration

dsn
required

required

allowed

.+

The connect string for PostgreSQL. The syntax of this string is documented in your PostgreSQL documentation. See Database Connection Control Functions.

sql
required

required

allowed

.+

The query that will be executed.

Example 5.35. Tracking PostgreSQL database sizes.

This will track the sizes of all databases on 10.225.209.35 and 10.225.209.56. We will connect to the postgres database as the user "noit" with password "noit." We only run this check every 5 minutes.

      <noit>
        <modules>
          <module image="postgres" name="postgres"/>
        </modules>
        <checks>
          <databases>
            <postgres  module="postgres" period="300000">
              <config>
                <dsn>host=%[target] dbname=%[name] user=noit password=noit</dsn>
                <sql>select datname, pg_database_size(datname) as size, xact_commit, xact_rollback from pg_stat_database</sql>
              </config>
              <check uuid="8c5ca46c-77d7-11dd-ab5b-53bc659517d6" target="10.225.209.35"/>
              <check uuid="90b8aea2-77d7-11dd-8447-0f381e6a48eb" target="10.225.209.56"/>
            </postgres>
          </databases>
        </checks>
      </noit>