echo "graph_info Slony st_lag_time for ${PGDATABASE}"
echo "graph_title Slony lag time for ${PGDATABASE}"
echo "graph_vlabel \${graph_period}"
psql -h ${PGHOST} -d ${PGDATABASE} -U ${PGUSER} -tc "SELECT no_id,regexp_replace(pa_conninfo, '.*host=(.*?) .*$', '\\\\1') FROM ${PGSCHEMA}.sl_node JOIN ${PGSCHEMA}.sl_path ON (pa_server=no_id) WHERE pa_client=${PGSCHEMA}.getlocalnodeid('${PGSCHEMA}'::name);" | while read node_id sep host
do
test -z "${node_id}" && continue
echo "${node_id}.label ${host}"
echo "${node_id}.type GAUGE"
echo "${node_id}.draw LINE2"
echo "${node_id}.info difference between st_last_event_ts and st_last_received_ts"
echo "${node_id}.warning 300"
echo "${node_id}.critical 600"
done
exit 0
fi
psql -h ${PGHOST} -d ${PGDATABASE} -U ${PGUSER} -tc "SELECT st_received, extract(epoch FROM st_lag_time)::integer FROM ${PGSCHEMA}.sl_status ORDER BY 1;" | while read node_id sep time