Postgresql – Zabbix + pg_monz shows service not running

monitoringpostgresqlzabbix

I am trying to setup monitoring for my PostgreSQL installation with zabbix ang pg_monz.
I've followed this standard installation guide(http://pg-monz.github.io/pg_monz/index-en.html#install). Everything seems working ok, besides PostgreSQL service running item, script that comes with pg_monz returns 0, however DB is running and other parameters are monitored.
What could be the issue here?

pgsql_simple.sh script
#!/bin/bash

PGSHELL_CONFDIR="$1"

# Load the psql connection option parameters.
source $PGSHELL_CONFDIR/pgsql_funcs.conf

psql -t -A -h $PGHOST -p $PGPORT -U $PGROLE $DBNAME -c "select 1;" 2>/dev/null
if [ $? -ne 0 ]; then
    echo 0
fi

zabbix userparameter:

UserParameter=psql.running[*],"$1"/pgsql_simple.sh "$2"

Best Answer

Wasn't expecting that, but problem was in the pg_monz script. Database name in configuration was declared as PGDATABASE but in the script that executes query $DBNAME was used to retrieve that name. Fixed that and monitoring started working.