Module: check_mk
Branch: master
Commit: d01a7488fc09d0a2023cbec4db94f0b19f7f6bd7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d01a7488fc09d0…
Author: Florian Heigl <fh(a)mathias-kettner.de>
Date: Wed Jul 4 17:00:52 2012 +0200
Update PostgreSQL Check_MK plugin to work with PostgreSQL 8.3 and 9.1
---
ChangeLog | 2 ++
agents/plugins/mk_postgres | 15 +++++++--------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a052e19..cc64d96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,8 @@
* FIX: winperf_phydisk: Fix typo (lead to WATO rule not being applied)
* Windows agent: new [global] option crash_debug (see online docu)
* AIX agent: new check for LVM volume status in rootvg.
+ * PostgreSQL plugin: agent is now modified to work with PostgreSQL
+ versions newer than 8.1. (multiple reports, thanks!)
Multisite:
* Show number of rows and number of selected rows in header line
diff --git a/agents/plugins/mk_postgres b/agents/plugins/mk_postgres
index ab69fd1..6667aab 100755
--- a/agents/plugins/mk_postgres
+++ b/agents/plugins/mk_postgres
@@ -1,11 +1,10 @@
-#!/bin/bash
+#!/bin/sh
-if id postgres >/dev/null ; then
+if id pgsql >/dev/null ; then
echo '<<<postgres_sessions>>>'
- echo "select current_query = '<IDLE>', count(*) from
pg_stat_activity group by (current_query = '<IDLE>');" | su - postgres
-c "psql -A -t -F' '"
- echo '<<<postgres_stat_database>>>'
- # The following statement might change in future for better cross-version
- # compatibility.
- echo 'select *, pg_database_size(datname) as "datsize" from
pg_stat_database;' \
- | su - postgres -c "psql -A -F' '" | sed '$d'
+ echo "select current_query = '<IDLE>', count(*) from
pg_stat_activity group by (current_query = '<IDLE>');" | su - pgsql -c
"psql -d postgres -A -t -F' '"
+
+ 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,conflicts,
pg_database_size(datname) as "datsize" from pg_stat_database;' \
+ | su - pgsql -c "psql -d postgres -A -F';'" | sed '$d'
fi