Ad Widget

Collapse

MSSQL - monitoring user permissions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lukas.zeleny
    Junior Member
    • Apr 2024
    • 4

    #1

    MSSQL - monitoring user permissions

    Hi,
    I have a problem with monitoring MSSQL database using Zabbix agent 2. Our ZABBIX is on version 6.4.13, the server is running Zabbix agent 2 (6.4.13). Our SQL (Microsoft SQL Server 2022) database run on Windows Server 2022 DC and is managed by an external company, to which I have submitted a request to create a monitoring account according to the instructions (https://www.zabbix.com/cz/integrations/mssql)

    View Server State and View Any Definition permissions should be granted to the user. Grant this user read permissions to the sysjobschedules, sysjobhistory, and sysjobs tables.
    For example, using T-SQL commands:
    GRANT SELECT ON OBJECT::msdb.dbo.sysjobs TO zbx_monitor;
    GRANT SELECT ON OBJECT::msdb.dbo.sysjobservers TO zbx_monitor;
    GRANT SELECT ON OBJECT::msdb.dbo.sysjobactivity TO zbx_monitor;
    GRANT EXECUTE ON OBJECT::msdb.dbo.agent_datetime TO zbx_monitor;


    After they created the zbx_monitor account I set everything up and zabbix was able to find all the databases, create graphs for them, but unfortunately it still doesn't read any data.

    Click image for larger version

Name:	image-2024-03-27-13-39-54-475.png
Views:	1264
Size:	56.0 KB
ID:	482815

    I found the following errors in the latest data and reported to our external contractor that it was a permissions issue.









    The contractor modified the zbx_monitor account settings and added permissions for msdb, but unfortunately the situation is still the same and no data is being retrieved.

    Click image for larger version

Name:	image-2024-04-08-15-15-52-545.png
Views:	959
Size:	34.3 KB
ID:	482816

    ​As a next step they tried to change the default schema for one DB from dbo to dba, but still no data in graphs.


    Click image for larger version

Name:	image-2024-04-17-12-51-43-215.png
Views:	991
Size:	17.7 KB
ID:	482817


    Therefore I would like to ask for advice here. Thank you very much for any suggestions

    LZ.​
  • LukaK12
    Junior Member
    • Feb 2025
    • 1

    #2
    I have same problem

    But if I give sysadmin rules, I can see the values in zabbix. Can I ask for help. How to set the minimum permissions for zabbix_user in MSSQL.

    Thanks

    Comment

    • justcore
      Junior Member
      • Mar 2025
      • 4

      #3
      Hi all. Have you checked the "latest data" in the monitoring tab of Zabbix? I had a similar issue that informed me it was user permission error:

      Click image for larger version

Name:	image.png
Views:	511
Size:	15.9 KB
ID:	501129

      Comment

      • mixer
        Junior Member
        • Jan 2022
        • 15

        #4
        Originally posted by justcore
        permission error
        What rights? How to understand if the rights are given according to the instructions on the site.
        How can I see a request that I don't have permission for?

        Comment

        • justcore
          Junior Member
          • Mar 2025
          • 4

          #5
          Originally posted by mixer
          What rights? How to understand if the rights are given according to the instructions on the site.
          How can I see a request that I don't have permission for?
          Can you send a screenshot of your items in "latest data" like I posted above?

          Comment

          • mixer
            Junior Member
            • Jan 2022
            • 15

            #6
            Originally posted by justcore
            Can you send a screenshot of your items in "latest data" like I posted above?
            Here is the data

            Attached Files

            Comment

            • mrnobody
              Member
              • Oct 2024
              • 61

              #7
              On Linux with mariadb (i know it's not same OS or DB, but same grants should work)

              show grants for 'zbx_monitor'@'%';
              GRANT PROCESS, SHOW DATABASES, REPLICATION CLIENT, SHOW VIEW ON *.* TO `zbx_monitor`@`%`

              Instead of % you can put IPv4 or hostname, for each Source of Query reqs.

              Comment

              • mixer
                Junior Member
                • Jan 2022
                • 15

                #8
                Originally posted by mrnobody
                show grants
                Read first post again please.

                Comment

                • justcore
                  Junior Member
                  • Mar 2025
                  • 4

                  #9
                  Originally posted by mixer
                  Here is the data
                  I had to translate but what I said still stands....
                  Failed to execute handler: failed to execute handler: failed to query: mssql: The user does not have permission to perform this action.

                  You need to set up the correct permissions for the user account you have setup.

                  You need $MSSQL.username
                  You need $MSSQL.password
                  You need $MSSQL.url > sqlserver://ipORhostname:<port>
                  1. Create an MSSQL user for monitoring. For example, "zbx_monitor".

                  View Server State and View Any Definition permissions should be granted to the user. Grant this user read permissions to the sysjobschedules, sysjobhistory, and sysjobs tables.

                  For example, using T-SQL commands:
                  GRANT SELECT ON OBJECT::msdb.dbo.sysjobs TO zbx_monitor;
                  GRANT SELECT ON OBJECT::msdb.dbo.sysjobservers TO zbx_monitor;
                  GRANT SELECT ON OBJECT::msdb.dbo.sysjobactivity TO zbx_monitor;
                  GRANT EXECUTE ON OBJECT::msdb.dbo.agent_datetime TO zbx_monitor;


                  EDIT* I had our DB guy re-check the perms on the account because it didnt work and drove me up the wall. Turned out it was on them fixing perms.
                  Last edited by justcore; 16-04-2025, 20:21.

                  Comment

                  • mixer
                    Junior Member
                    • Jan 2022
                    • 15

                    #10
                    I looked at the queries with a profiler. They were missing
                    Code:
                    USE master;
                    GRANT VIEW SERVER STATE TO UserName;
                    GO
                    You need to read the documentation more carefully.

                    Comment

                    • justcore
                      Junior Member
                      • Mar 2025
                      • 4

                      #11
                      Originally posted by mixer
                      I looked at the queries with a profiler. They were missing
                      Code:
                      USE master;
                      GRANT VIEW SERVER STATE TO UserName;
                      GO
                      You need to read the documentation more carefully.
                      So... permission error. Glad its resolved.

                      Comment

                      Working...