zabbix-tools / libzbxpgsql

Monitor PostgreSQL with Zabbix
http://cavaliercoder.com/libzbxpgsql/
Other
157 stars 64 forks source link

Connecting to PostgreSQL on Windows Server #50

Closed cristianoisaac closed 8 years ago

cristianoisaac commented 8 years ago

Hi, I've searched here a lot and didn't find anything saying it is or isn't possible connecting to a PostgreSQL server on a Windows.

In the configuration, it is said I can connect to a remote server without using the agent, so I thought it could access a PostgreSQL on a Windows database without using the Agent and the lib used on linux, but I can't make the connection work. It tries to use the agent on Windows PostgreSQL Server with this error:

Zabbix Agent [STURESPPTG10]. Zabbix 3.0.0 (revision 58455).
52720:20160706:152802.654 **** Enabled features ****
52720:20160706:152802.669 IPv6 support:          YES
52720:20160706:152802.669 TLS support:            NO
52720:20160706:152802.669 **************************
52720:20160706:152802.685 using configuration file: C:\Zabbix\zabbix_agentd.conf
52720:20160706:152802.685 agent #0 started [main process]
13124:20160706:152802.701 agent #1 started [collector]
37224:20160706:152802.701 agent #2 started [listener #1]
72972:20160706:152802.701 agent #3 started [listener #2]
65864:20160706:152802.716 agent #4 started [listener #3]
79660:20160706:152802.716 agent #5 started [active checks #1]
79660:20160706:230606.586 active check configuration update from [10.0.1.146:10051] started to fail (ZBX_TCP_READ() failed: [0x0000274C] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
79660:20160706:230706.273 active check configuration update from [10.0.1.146:10051] is working again
79660:20160713:172002.250 active check "pg.db.discovery[host=10.0.1.107 port=5434 user=zabbix,postgres]" is not supported: Unsupported item key.
79660:20160713:172002.266 active check "pg.tablespace.discovery[host=10.0.1.107 port=5434 user=zabbix,postgres]" is not supported: Unsupported item key.
79660:20160713:172002.266 active check "pg.prepared_xacts_ratio[host=10.0.1.107 port=5434 user=zabbix,postgres]" is not supported: Unsupported item key.
.....

I've installed the libzbxpgsql, PostgreSQL Client/Libs and the libzbxpgsql.so on the Zabbix Server to try to access remotely. Is there a way to connect on a PostgreSQL on a Windows Server 2012?

Thanks,

Cristiano

cavaliercoder commented 8 years ago

It seems you are using Active Checks which means the Zabbix server expects the Windows agent to manage its own configuration, checks and submissions. In your case, the agent is not running the libzbxpgsql.so module so these items are not supported.

What you need to do, is change all of the item types from Zabbix agent (active) to Zabbix agent. This way the checks will be scheduled and executed on the Zabbix server which has libzbxpgsql.so loaded correctly.

cristianoisaac commented 8 years ago

Hi Cavaliercoder,

Thanks for your quick answer! I was testing and I realized that I needed to configure my AGENT INTERFACE on Zabbix in HOST with the IP of the ZABBIX SERVER (since I installed the module libzbxpgsql.so loaded in it). Since I was using another template to monitor the SO, I had to do something different to adjust this.

In the PG SERVER HOST, it already have an AGENT INTERFACE with the IP of the server (to use SO template), so I've added the another AGENT INTERFACE with the IP of Zabbix Server, changed it to the DEFAULT and Updated the host.

Then, I've added the PostgreSQL Template, changing all the AGENT TYPE of the templates to ZABBIX AGENT (instead of ZABBIX AGENT (ACTIVE)), don't forget to change also the ITEMS on the DISCOVERY RULE. After it, change in the MACROS tab (also insed the Template) the parameter {$PG_CONN} = host=IP_PGSERVER port=PORT_PGSERVER user=USER_PGSERVER

After that, just add the template in the HOST and wait for the first discovery. It's working fine now! Also, don't forget to change in HOST the AGENT INTERFACE DEFAULT to the IP of the PostgreSQL server (just for new templates use the PG agent, not the Zabbix Server Agent).

I recommend to add some of this information on the WIKI so other people don't get confused (I got a lot confused when I was I could connect without installing the Agent on the PostgreSQL server but without information on how to do it.

Thank you very much for this module and for the help.

Regards,

Cristiano