[英]Best way to report the growth of a file using powershell?
I would like to report the database size to myself via email every week and make a comparison to the week before and display the growth in Megabyte and/or %. 我想每周通过电子邮件向我自己报告数据库大小,并与前一周进行比较,并以兆字节和/或百分比显示增长情况。 I have everything besides the comparison done.
除了比较之外,我还有其他一切。
Imagine this setup : 想象一下这个设置:
Now there are plenty of ways to do a comparison, I thought about writing the sizes into XML by powershell and later read out using a second script and report to me. 现在有很多方法可以进行比较,我考虑过通过powershell将大小写入XML,然后使用第二个脚本进行读取并向我报告。
Since I trained myself in powershell I might have gaps here, so I am afraid to miss an easy way. 由于我已经接受过Powershell方面的培训,因此我在这里可能会遇到空白,因此,我担心错过一种简单的方法。
Does anyone has a nice Idea of how to compare the size? 有人对如何比较大小有个好主意吗?
The report and calculation I will manage myself later, I just need a good way to do that. 我将稍后管理报告和计算,我只需要一个好的方法即可。
Currently I am on Powershell 3.0 but I can upgrade to 4.0 目前,我使用的是Powershell 3.0,但可以升级到4.0
Don't invent the wheel again. 不要再发明轮子了。 Sql Server already has tools to monitor DB file sizes.
Sql Server已经具有监视数据库文件大小的工具。 So does Performance Monitor.
性能监视器也是如此。 There are several 3rd party products available too.
也有几种第三方产品。 Ask your local DBA if there already is such a system present.
询问您本地的DBA,是否已经存在这样的系统。
A common practice is to query the server for DB file sizes on, say, daily basis and store it in utility db table with timestamp. 通常的做法是每天查询服务器的数据库文件大小,并将其存储在带有时间戳的实用程序数据库表中。 Calculating change volumes, ratios and whatnot can be done on TSQL side.
在TSQL端可以计算变更量,比率等。 (Not that it is CPU intensive anyway.)
(这并不意味着它会占用大量CPU。)
I would creat foreach database an csv file. 我会为foreach数据库创建一个csv文件。 then write out two rows:
然后写出两行:
Date,Size 日期,大小
27.08.2014,1024 2014年8月27日,1024
28.08.2014,1040 2014年8月28日,1040
29.08.2014,1080 2014年8月29日,1080
Then you can import the csv file, sort the row by date, compare the last two sizes and send the result by mail. 然后,您可以导入csv文件,按日期对行进行排序,比较最后两个大小并通过邮件发送结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.