Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Needs to be configurable
  • Loading branch information
vincent committed Feb 6, 2013
1 parent 5adc1a5 commit 38d6598
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts-available/postgresql.coffee
@@ -1,7 +1,7 @@
pg = require 'pg'

# Metrics to get as s from the client_info object
metrics =
metrics =
'server.numbackends' : 'select sum(numbackends) as s from pg_stat_database' # backends currently connected
'server.committed_transactions' : 'select sum(xact_commit) as s from pg_stat_database' # transactions that have been committed
'server.rolledback_transactions' : 'select sum(xact_rollback) as s from pg_stat_database' # transactions that have been rolled back
Expand All @@ -22,7 +22,12 @@ module.exports = (server) ->
metricPrefix = "#{server.fqdn}.postgresql"
server.cli.debug "Running the postgresql plugin"

conn = pg.connect 'postgres://postgres:1234@localhost:5432/postgres', (error, client) ->
# This script needs configuration
confPath = Path.join server.sPath, 'postgresql.json'
configFile = Fs.readFileSync confPath, 'utf-8'
conf = JSON.parse configFile

conn = pg.connect conf, (error, client) ->
return server.cli.error "Error when connect to PostgreSQL: #{error}" if error?

for own metricKey, metricQuery of metrics
Expand Down
7 changes: 7 additions & 0 deletions scripts-available/postgresql.json
@@ -0,0 +1,7 @@
{
"host": "localhost",
"user": "postgres",
"password": "changeme"
"database": "postgres",
"port": 5432
}

0 comments on commit 38d6598

Please sign in to comment.