简体   繁体   English

使用Powershell报告文件增长的最佳方法?

[英]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 : 想象一下这个设置:

  • SQL server with 100 databases 具有100个数据库的SQL Server

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.

相关问题 在PowerShell中组装字符串文件的最佳方法 - Best way to assemble a string file in PowerShell 使用PowerShell设置数据库的初始增长大小 - Set initial growth size for database using PowerShell 在PowerShell中使用全局变量的最佳方法? - Best way to using Global Variables in PowerShell? 使用 PowerShell 删除文件夹的最佳方法 - Best way to delete a folder using PowerShell 使用Powershell从SharePoint下载具有已知文件类型的多个文件的最佳方法是什么? - What is the best way to download multiple files with know file types from SharePoint using Powershell? 使用 PowerShell 从文件夹中获取文件名的最快\最好的方法是什么? - What is the fastest\best way to get file names from a folder using PowerShell? Powershell | 数据增长查询 - Powershell | data growth query 使用 powershell 将数据发布到 Elastic Search 的最佳方式是什么? - What's the best way to post data to Elastic Search using powershell? 有没有一种方法可以使用Powershell更改文件中的内容部分? - Is there a way of changing a section of content in a file using powershell? PowerShell:检查当前用户是否有权在PowerShell中覆盖文件的最佳方法是什么? - PowerShell: What is the best way to check whether the current user has permission to overwrite a file in PowerShell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM