Module: check_mk
Branch: master
Commit: cc6467172b2a577f4c1e9cbcfdaa3c55b1f85531
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cc6467172b2a57…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Dec 16 18:15:02 2013 +0100
FIX postgres_sessions: make agent plugin compatible with PostgreSQL 9.2
Problem is that newer PostgreSQL versions have the column <tt>query</tt>
instead of <tt>current_query</tt>. The plugin now simply tries both
variants.
---
.werks/343 | 12 ++++++++++++
ChangeLog | 1 +
agents/plugins/mk_postgres | 10 ++++++++--
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/.werks/343 b/.werks/343
new file mode 100644
index 0000000..53dc7ae
--- /dev/null
+++ b/.werks/343
@@ -0,0 +1,12 @@
+Title: postgres_sessions: make agent plugin compatible with PostgreSQL 9.2
+Level: 1
+Component: checks
+Class: fix
+State: unknown
+Version: 1.2.5i1
+Date: 1387213935
+Targetversion: future
+
+Problem is that newer PostgreSQL versions have the column <tt>query</tt>
+instead of <tt>current_query</tt>. The plugin now simply tries both
+variants.
diff --git a/ChangeLog b/ChangeLog
index 83abf7a..7b7dc50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,7 @@
* 0366 FIX: heartbeat_crm: Agent code is now compatible to pacemaker 1.1.9...
* 0367 FIX: Now using /dev/null instead of closing stdin in linux agent...
* 0342 FIX: postgres_stat_database: make agent compatible with PostgreSQL 8.4.x...
+ * 0343 FIX: postgres_sessions: make agent plugin compatible with PostgreSQL 9.2...
Multisite:
* 0302 FIX: Fixed highlight of choosen elements in foldertee/views snapin in
Chrome/IE
diff --git a/agents/plugins/mk_postgres b/agents/plugins/mk_postgres
index 97e1865..3d928db 100755
--- a/agents/plugins/mk_postgres
+++ b/agents/plugins/mk_postgres
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Try to detect the postgres user
if id pgsql >/dev/null 2>&1; then
@@ -10,7 +10,13 @@ else
fi
echo '<<<postgres_sessions>>>'
-echo "select current_query = '<IDLE>', count(*) from pg_stat_activity
group by (current_query = '<IDLE>');" | su - $USER -c "psql -d
postgres -A -t -F' '"
+# Postgres 9.2 uses 'query' instead of 'current_query'
+for name in query current_query
+do
+ OUTPUT="$(echo "select $name = '<IDLE>', count(*) from
pg_stat_activity group by ($name = '<IDLE>');" |\
+ su - $USER -c "psql --variable ON_ERROR_STOP=1 -d postgres -A -t -F'
'" 2>/dev/null)" && break
+done
+echo "$OUTPUT"
echo '<<<postgres_stat_database:sep(59)>>>'
echo 'select datid, datname, numbackends, xact_commit, xact_rollback, blks_read,
blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted,
pg_database_size(datname) "datsize" from pg_stat_database;' \