Ad Widget

Collapse

Template 'PostgreSQL by Zabbix agent': Trigger on pgsql.ping in non-english locale

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ivanco
    Junior Member
    • May 2023
    • 5

    #1

    Template 'PostgreSQL by Zabbix agent': Trigger on pgsql.ping in non-english locale

    Hello Community,

    In templates/db/postgresql/template_db_postgresql.conf we have:
    Code:
    UserParameter=pgsql.ping[*], pg_isready -h "$1" -p "$2"
    In templates/db/postgresql/template_db_postgresql.yaml we have trigger that have dependence on locale:
    Code:
    - 'return value.search(/accepting connections/)>0 ? 1 : 0'
    So this solves the issue:
    In templates/db/postgresql/template_db_postgresql.conf:
    Code:
    UserParameter=pgsql.ping[*], LANG=C.UTF-8 pg_isready -h "$1" -p "$2"
  • ivanco
    Junior Member
    • May 2023
    • 5

    #2
    And one more issue with this template - it makes PostgreSQL noisy in logfile:
    Code:
    FATAL: role "zabbix" does not exist
    It was also reported as ZBX-23374
    ​Cause of the problem is that pg_isready called without username parameter. So it tries to connect to PostgreSQL with username of zabbix-agent process running - zabbix.
    It can be fixed:
    1. In templates/db/postgresql/template_db_postgresql.conf we have to add parameter:
    Code:
    UserParameter=pgsql.ping[*], LANG=C.UTF-8 pg_isready -h "$1" -p "$2" -U "$3"
    2. In templates/db/postgresql/template_db_postgresql.yaml we have to pass username to the script:
    Code:
    pgsql.ping["{$PG.HOST}","{$PG.PORT}","{$PG.USER}"]

    Comment


    • jakk
      jakk commented
      Editing a comment
      Hi,

      I also noticed this, but I changed the template to also include the database, otherwise postgresql complains about a zbx_monitor database not existing
      Code:
      UserParameter=pgsql.ping[*], LANG=C.UTF-8 pg_isready -h "$1" -p "$2" -U "$3" -d "$4"
      Code:
      pgsql.ping["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.DB}"]
Working...