5.02021-11-21T21:42:11ZTemplates/DatabasesPostgres ODBCPostgres ODBC## Overview
I have been looking for templates to use with the new ODBC database monitoring item type with out success.
I have created a rudimentary one for postgres. To use it follow these instructions for setting up ODBC on the server side.
https://www.zabbix.com/documentation/4.0/manual/config/items/itemtypes/odbc\_checks
We run multiple instances on each server so I create a host for each database and use the {HOST.NAME} macro in the item key. If you want to use a different macro like {$DATABASE.NAME} then do a find and replace before you import this. As well all items have the name zabbix set as the user and the password set as " my\_password". Again you may want to do a find and replace before importing.
Then import this template and add it to the host you are using and then go through and double check the items.
I know this functionality was in Zabbix 3 so this may work there but I created this in 4 so that is all I know it works with. I hope some one finds this useful.
## Author
J Villain
Templates/DatabasesBG writerLocksStatistics- accessexclusivelockODBCdb.odbc.select[accessexclusivelock,{HOST.NAME}]60s732dSELECT count(*) FROM pg_locks where mode='AccessExclusiveLock'zabbixmy_passwordLocks
- accesssharelockODBCdb.odbc.select[accesssharelock,{HOST.NAME}]60s732dSELECT count(*) FROM pg_locks where mode='AccessShareLock'zabbixmy_passwordLocks
- activeconnODBCdb.odbc.select[activeconn,{HOST.NAME}]60s732dselect sum(numbackends) from pg_stat_databasezabbixmy_passwordStatistics{last()}>=100Too many active connectionsWARNINGYES
- buffers_allocODBCdb.odbc.select[buffers_alloc,{HOST.NAME}]60s732dselect buffers_alloc from pg_stat_bgwriterzabbixmy_passwordBG writer
- buffers_backendODBCdb.odbc.select[buffers_backend,{HOST.NAME}]60s732dselect buffers_backend from pg_stat_bgwriterzabbixmy_passwordBG writer
- buffers_checkpointODBCdb.odbc.select[buffers_checkpoint,{HOST.NAME}]60s732dselect buffers_checkpoint from pg_stat_bgwriterzabbixmy_passwordBG writer
- buffers_cleanODBCdb.odbc.select[buffers_clean,{HOST.NAME}]60s732dselect buffers_clean from pg_stat_bgwriterzabbixmy_passwordBG writer
- checkpoints_reqODBCdb.odbc.select[checkpoints_req,{HOST.NAME}]60s732dselect checkpoints_req from pg_stat_bgwriterzabbixmy_passwordBG writer
- checkpoints_timedODBCdb.odbc.select[checkpoints_timed,{HOST.NAME}]60s732dselect checkpoints_timed from pg_stat_bgwriterzabbixmy_passwordBG writer
- exclusivelockODBCdb.odbc.select[exclusivelock,{HOST.NAME}]60s732dSELECT count(*) FROM pg_locks where mode='ExclusiveLock'zabbixmy_passwordLocks{last()}>2To many exclusive locksWARNINGYES
- maxwritten_cleanODBCdb.odbc.select[maxwritten_clean,{HOST.NAME}]60s732dselect maxwritten_clean from pg_stat_bgwriterzabbixmy_passwordBG writer
- oneODBCdb.odbc.select[one,{HOST.NAME}]60s732dselect 1 as "C1"zabbixmy_passwordStatistics{last()}<>1Database problemAVERAGEThis query does a select 1 as 1 if it doesn't return 1 some thing is really messed up.YES
- pmbcexclusivelockODBCdb.odbc.select[pmbcexclusivelock,{HOST.NAME}]60s732dSELECT count(*) from public.vwlock where lock_duration_in_minutes > 5zabbixmy_passwordLocks{last()}>6To many PMBC exclusive locksAVERAGEYES
- rowexclusivelockODBCdb.odbc.select[rowexclusivelock,{HOST.NAME}]60s732dSELECT count(*) FROM pg_locks where mode='RowExclusiveLock'zabbixmy_passwordLocks
- rowsharelockODBCdb.odbc.select[rowsharelock,{HOST.NAME}]60s732dSELECT count(*) FROM pg_locks where mode='RowShareLock'zabbixmy_passwordLocks
- sharerowexclusivelockODBCdb.odbc.select[sharerowexclusivelock,{HOST.NAME}]60s732dSELECT count(*) FROM pg_locks where mode='ShareRowExclusiveLock'zabbixmy_passwordLocks
- shareupdateexclusivelockODBCdb.odbc.select[shareupdateexclusivelock,{HOST.NAME}]60s732dSELECT count(*) FROM pg_locks where mode='ShareUpdateExclusiveLock'zabbixmy_passwordLocks
- tupdeletedODBCdb.odbc.select[tupdeleted,{HOST.NAME}]60s732dselect sum(tup_deleted) from pg_stat_databasezabbixmy_passwordStatistics
- tupfetchedODBCdb.odbc.select[tupfetched,{HOST.NAME}]60s732dselect sum(tup_fetched) from pg_stat_databasezabbixmy_passwordStatistics
- tupinsertedODBCdb.odbc.select[tupinserted,{HOST.NAME}]60s732dselect sum(tup_inserted) from pg_stat_databasezabbixmy_passwordStatistics
- tupreturnedODBCdb.odbc.select[tupreturned,{HOST.NAME}]60s732dselect sum(tup_returned) from pg_stat_databasezabbixmy_passwordStatistics
- tupupdatedODBCdb.odbc.select[tupupdated,{HOST.NAME}]60s732dselect sum(tup_updated) from pg_stat_databasezabbixmy_passwordStatistics
- xactcommitODBCdb.odbc.select[xactcommit,{HOST.NAME}]60s732dSELECT sum(xact_commit) FROM pg_stat_databasezabbixmy_passwordStatistics
- xactrollbackODBCdb.odbc.select[xactrollback,{HOST.NAME}]60s732dSELECT sum(xact_rollback) FROM pg_stat_databasezabbixmy_passwordStatistics