Ad Widget

Collapse

Zabbix Agent2 and the PostgreSQL plugin not working -Debian12 Zabbix 7-

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rich@974
    Junior Member
    • Oct 2024
    • 13

    #1

    Zabbix Agent2 and the PostgreSQL plugin not working -Debian12 Zabbix 7-

    Hi
    I'm fighting like mad for days now, trying to get my Zabbix to monitor its own postegreSQL/TimeScaleDB server's Database.
    I've intalled the agent, installed the plugin in
    /usr/sbin/zabbix-agent2-plugin/zabbix-agent2-plugin-postgresql

    dpkg -l | grep zabbix-agent2-plugin-postgresql
    ii zabbix-agent2-plugin-postgresql 1:7.0.4-1+debian12 amd64 Zabbix Agent2 plugin for monitoring PostgreSQL installations

    I got the proper rights (-rwxr-xr-x 1 root root 8884312 24 sept. 10:23 /usr/sbin/zabbix-agent2-plugin/zabbix-agent2-plugin-postgresql)

    The plugin's conf is in
    /etc/zabbix/zabbix_agent2.d/plugins.d/postgresql.conf

    I've added
    Include=/etc/zabbix/zabbix_agent2.d/plugins.d/*.conf
    to the agent's conf

    And I know that I have proper access to my DB
    psql "host=localhost port=5432 dbname=zabbix user=zbx_monitor password=myPSW" -c "SELECT date_trunc('second', current_timestamp - pg_postmaster_start_time()) as uptime;"
    I get
    uptime----------------1 day 02:10:46​

    but for the life of me I cannot get 1 itemin Zabbix concerning my DB
    every item is red flagged , state is "not supported" and i get "Unknown metric pgsql.xxx" everywhere

    I spent so much time checking and rechecking everything that I'm turing crazy

    And yes, I found https://www.zabbix.com/forum/zabbix-...sql-monitoring, and https://www.zabbix.com/integrations/...tgresql_agent2​ and https://support.zabbix.com/browse/ZBX-21894
    but NOTHING moved anything

    Anyone could help ??
  • rich@974
    Junior Member
    • Oct 2024
    • 13

    #2
    Someone ? Anyone ? is that postgreSQL DB monitoring to much of a tricky subject for this forum ?

    Comment

    • troffasky
      Senior Member
      • Jul 2008
      • 567

      #3
      • Turn up log level on agent. Tail the agent log file whilst troubleshooting.
      • Use "zabbix_get" from server to troubleshoot your items, this is much quicker feedback loop than using GUI.

      Comment

      • ISiroshtan
        Senior Member
        • Nov 2019
        • 324

        #4
        Atm it all seems like a plugin setup issue. Tho I'll be honest, not worked much with Agent 2 or it plugins.

        What is suggested above by troffasky to get more info does make sense. Some blind guesses about what also might make sense to check:
        Can you show permissions of directory /usr/sbin/zabbix-agent2-plugin/?
        Can you show content of the plugin configuration file?

        Comment

        • rich@974
          Junior Member
          • Oct 2024
          • 13

          #5
          Thank you for helping
          I have checked and checked dozens of time for the conf file content and the permissions
          -rwxr-xr-x 1 root root 8884312 24 sept. 10:23 /usr/sbin/zabbix-agent2-plugin/zabbix-agent2-plugin-postgresql

          as for the plugins conf file I've tried
          Plugins.PostgreSQL.System.Path=/usr/sbin/zabbix-agent2-plugin/zabbix-agent2-plugin-postgresql
          Plugins.PostgreSQL.Enabled=true // Those two just make the zabbix agent status to error
          Plugins.PostgreSQL.Sessions.custom.Enabled=true //
          Plugins.PostgreSQL.Sessions.custom.Uri=postgresql://zbx_monitor:zabbix@localhost:5432/zabbix

          Want a new info from this morning ?
          I uninstalled and purge the postgreSQL by agent plugin
          remove the "include" the the agent2.conf
          Installed the ODBC (sudo apt install unixodbc odbc-postgresql)
          edited the /etc/odbcinst.ini to

          [PostgreSQL]
          Description=PostgreSQL ODBC Driver
          Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
          Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
          FileUsage = 1

          setup the proper permissions
          Edited the /etc/odbc.ini to
          HTML Code:
          [PostgreSQL_zabbix]
          Description=PostgreSQLconnection for Zabbix
          Driver=PostgreSQL
          Servername=localhost
          Port=5432
          Database=zabbix
          UserName=zbx_monitor
          Password=myPSW
          Verrified with isql -v PostgreSQL_zabbix
          that I was connected fine

          Setup the proper permission
          Install the ODBC postegreSQL template on my host in Zabbix
          Added the {$DSN} Macro with the proper value
          Gave the the proper values to {$PG.PASSWORD} and {$PG.USER}
          and guess what ?

          ...:~$ sudo /usr/sbin/zabbix_agent2 -t 'odbc.uptime["PostgreSQL_zabbix"]'
          ​odbc.uptime["PostgreSQL_zabbix"] [m|ZBX_NOTSUPPORTED] [Unknown metric odbc.uptime]

          So basicaly the same error with ODBC as with postgreSQL by zabbix_agent2

          Two things come to mind:
          1 I use postgreSQL 16 (things seems to be tested on 15...)
          2 I use TimeSacleDB 15 as suggested bu initMAX (https://www.initmax.com/wiki/)

          So is my problem coming from me using TimeScaleDB ?.

          Comment

          • rich@974
            Junior Member
            • Oct 2024
            • 13

            #6
            OK Guys, It seems I found out

            I reinstalled the postgreSQL by zabbix agent2 with the same setting as before BUT !!

            Make sure you have the following macros correctly defined without spaces:
            • {$PG.CONNSTRING}: postgresql://zbx_monitor:myPSW@localhost:5432/zabbix
            • {$PG.USER} and {$PG.PASSWORD} macros can be removed because they're now embedded in the connection string.
            One good thing I found that help me is this line
            sudo /usr/sbin/zabbix_agent2 -R metrics
            because it really shows you what your agent sees

            addendum

            Once the whole PostgreSQL by Zabbix agent 2 is working, you might get some red flag for the WAL items
            the solution is to grant some acces in the postgreDB, it'll unlock the situation
            for me it was:
            Code:
            GRANT SELECT ON pg_stat_wal_receiver TO zbx_monitor;
            and
            Code:
            GRANT EXECUTE ON FUNCTION pg_ls_waldir() TO zbx_monitor;
            Last edited by rich@974; 03-10-2024, 13:02.

            Comment

            Working...