Hello. I was wondering if it is possible to set up a monitor that has multiple queries inside of Zabbix (version 4.0.4 on CentOS 7). I have other database monitors that work fine however, they are ran on 1 query only. I was asked from a DBA if we could set up a monitor that runs the following statement(s):
EXEC sys.sp_executesql N’ DECLARE @DBName TABLE ( DBName sysname ); INSERT INTO @DBName EXEC sys.sp_MSforeachdb ‘’USE [?] SELECT a.NAME FROM sysfiles a where groupid <> 0 and (a.size - FILEPROPERTY(a.NAME, ‘’'‘SpaceUsed’‘'')) < 128 * 50 and db_id(a.name) > 4 and (a.size - FILEPROPERTY(a.NAME, ‘’'‘SpaceUsed’’''))/ (a.size * 1.0) < .20''; SELECT COUNT(*) dbcount FROM @DBName;'
I was told this will set up a "temporary table" that will insert data into it, then it will run a query to find if there is anything with a more than 0 result. I couldn't find anything online and my assumption that this will not work, but I wanted to make sure before officially saying it is not support.
Any help is appreciated. Thanks!
EXEC sys.sp_executesql N’ DECLARE @DBName TABLE ( DBName sysname ); INSERT INTO @DBName EXEC sys.sp_MSforeachdb ‘’USE [?] SELECT a.NAME FROM sysfiles a where groupid <> 0 and (a.size - FILEPROPERTY(a.NAME, ‘’'‘SpaceUsed’‘'')) < 128 * 50 and db_id(a.name) > 4 and (a.size - FILEPROPERTY(a.NAME, ‘’'‘SpaceUsed’’''))/ (a.size * 1.0) < .20''; SELECT COUNT(*) dbcount FROM @DBName;'
I was told this will set up a "temporary table" that will insert data into it, then it will run a query to find if there is anything with a more than 0 result. I couldn't find anything online and my assumption that this will not work, but I wanted to make sure before officially saying it is not support.
Any help is appreciated. Thanks!