[英]How to monitor database file size using Zabbix
I need to be able to monitor database file space in Zabbix. 我需要能够监视Zabbix中的数据库文件空间。 I have tried out many of the templates for monitoring SQL Server and they don't seem to do what I need them to do.
我已经尝试了许多用于监视SQL Server的模板,但它们似乎并没有执行我需要它们执行的操作。 Essentially, I need to know when a database file or log file (.mdf or .ldf) for a particular database is within a certain percentage of being full.
本质上,我需要知道特定数据库的数据库文件或日志文件(.mdf或.ldf)何时处于充满状态的一定百分比之内。
Essentially I'm looking to: 本质上,我正在寻找:
Using ODBC is not an option due to the size of our environment and network restrictions. 由于我们的环境规模和网络限制,不能选择使用ODBC。 I believe I need some type of discovery script using PowerShell, then another script to fetch the values for the items, but I'm not sure.
我相信我需要使用PowerShell的某种类型的发现脚本,然后是另一个脚本来获取项目的值,但是我不确定。
No idea what Zabbix is (I'll take a peek later), but in SQL Server, you have sp_MSforeachdb
不知道Zabbix是什么(稍后再看),但是在SQL Server中,您有
sp_MSforeachdb
Here we create a #Temp
table to collect the results from each database on the server 在这里,我们创建一个
#Temp
表来收集服务器上每个数据库的结果
Example 例
Use Master;
Create table #Temp (DBName varchar(150),FileType varchar(50),MBytes bigint,MBytesMax bigint)
EXEC sp_MSforeachdb '
Insert Into #Temp
Select DBName = ''?''
,FileType = case when physical_name like ''%.mdf'' then ''Database'' else ''Log'' end
,MBytes = try_convert(bigint,size) * 8 / 1024
,MBytesMax = try_convert(bigint,max_size) * 8 / 1024
From [?].sys.database_files
'
Select *
,Pct = convert(decimal(10,1),(MBytes *100.0) / nullif(MBytesMax,0))
From #Temp
Returns 返回
DBName FileType MBytes MBytesMax Pct
master Database 4 0 NULL
master Log 1 0 NULL
tempdb Database 816 0 NULL
tempdb Log 894 0 NULL
msdb Database 201 0 NULL
msdb Log 19 2097152 0.0
xxxxxxx Database 761 4096 18.6
xxxxxxx Log 1 2097152 0.0
yyyyyyy Database 533 4096 13.0
yyyyyyy Log 1 2097152 0.0
zzzzzzz Database 1641 4096 40.1
zzzzzzz Log 1 2097152 0.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.