Ad Widget

Collapse

Zabbix monitoring a service / app connection to a database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheTIGuy
    Junior Member
    • Apr 2026
    • 2

    #1

    Zabbix monitoring a service / app connection to a database

    Good Morning Everyone!

    Any ideas are welcome here! Does anyone have any idears on ensuring my connection from my app to database is working? These apps are running as a service on different servers but all reaching back to a sql server. Any help would be appreciated! I am also fairly new to Zabbix!
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4904

    #2
    There is "ping" item for most used sql DB-s available in agent2. mysql.ping, mssql.ping, oracle.ping,pgsql.ping

    Comment

    • TheTIGuy
      Junior Member
      • Apr 2026
      • 2

      #3
      Originally posted by cyber
      There is "ping" item for most used sql DB-s available in agent2. mysql.ping, mssql.ping, oracle.ping,pgsql.ping
      https://www.zabbix.com/documentation.../zabbix_agent2
      cyber, thank you for responding! I understand I can ping the DB. The biggest issue is we have app's built using services to connect. I need to ensure the service has access to the DB more or less. I would really prefer to write and delete a table / row on the db through the service.

      Comment

      • Manuel Deschambault
        Junior Member
        • Jan 2026
        • 18

        #4
        Do you have an API that these apps use to transact with the Database? If so, you can regularly send a bogus command (I often use the famed 'get version') and both see if it responds, and how long it takes.

        I basically wrote a shell script (I use bash but any shell script will do) adding a UserParameter, where I do:
        1. get parameter of the service to test (passed via an argument to the UserParameter)
        2. get timestamp
        3. call api with curl command
        4. get timestamp
        5. parse curl output to confirm proper response
        6. Return time to execute (delta between two timestamp) and status of service
        This allow my Zabbix to keep track of all my web services and also their response time

        Comment

        • tim.mooney
          Senior Member
          • Dec 2012
          • 1432

          #5
          Originally posted by TheTIGuy
          I would really prefer to write and delete a table / row on the db through the service.
          Most database engines have a way to ask them what users are connected and from where.

          Assuming you use a service user specific to the application, you should be able to set up a Zabbix monitor that just asks the database periodically. It should be possible to split it up by source, too, so you can see that appsserver1 and appdserver2 each have connections to the database but appserver3 does not.

          If you don't use a DB user specific to the application (you should, but anyway...) then you can still count the number of connections to the database.

          For postgresql, here's an example that might be a starting point for what you're trying to do:

          Code:
          --
          -- summarize counts of unique (database,user,client_addr) connections
          --
          
          SELECT datname AS "Database",
                  usename AS "Username",
                  client_addr AS "Client Address",
                  COUNT(datname) AS "Connections"
          FROM    pg_stat_activity
          WHERE
                  datname IS NOT NULL
          AND     client_addr IS NOT NULL
          GROUP BY datname,usename,client_addr
          ORDER BY datname;
          Something similar is also possible with MySQL/MariaDB

          Comment

          • irontmp
            Member
            • Sep 2023
            • 54

            #6
            Originally posted by TheTIGuy
            Good Morning Everyone!

            Any ideas are welcome here! Does anyone have any idears on ensuring my connection from my app to CNC Machining Services database is working? These apps are running as a service on different servers but all reaching back to a sql server. Any help would be appreciated! I am also fairly new to Zabbix!
            To verify your app-to-database connection in Zabbix, start with a simple TCP check on the SQL port (like 1433) using net.tcp.service to confirm basic connectivity. Then add a database check that runs a basic query like SELECT 1 to ensure the database is actually responding. You can also use the built-in Microsoft SQL Server template in Zabbix to monitor connections, response time, and errors. Finally, check firewall rules, DNS resolution, and service account permissions between the servers if issues appear.

            Comment

            Working...