很简单,我试图从Windows 2003服务器触发一个电子邮件警报,告诉我什么时候磁盘空间不足。
有没有人有设置这个经验?
谢谢。
而不是只为这一个项目创build一个警报,你应该考虑设置Nagios或类似的。 然后,您可以让它监视任何您喜欢的事情,并在事件超出预定义的参数时提醒您。 设置它所需要的时间相对较less,而不是通过手动监视和检查来偿还。
几个选项:
a)安装一个监控代理(例如nsclient ++)并让监控系统(例如Nagios)监控它,并在磁盘空间不足时发出警报。
b)创build一个触发每一分钟的计划任务,读取适当的WMI计数器(例如\\ LogicalDisk(C:)\\ Free Megabytes)并使用CDO.Message WScript对象发送一个邮件(例如: http:// blogs .technet.com / heyscriptingguy / archive / 2004/11/29 / how-can-i-attach-a-file-to-an-email-sent-using-cdo.aspx )
对于nagios(或opsview等衍生产品)和nsclient ++的+1。 如果您知道脚本,您可以轻松地编写自己的自定义插件,以满足您可能需要的任何内容。
如果你还没有监测,现在开始做!
请参阅此处: Microsoft KB 324796
我在我们的环境中使用它,它的工作很好。 您确实需要SMTP服务器才能发送邮件,但不一定必须是同一个邮箱。
我检查低内存(每5分钟检查一次,看空闲内存是否低于100 MB),处理器监视器(每30秒检查一次以确保处理器运行不超过95%)和低磁盘空间(每30分钟检查一次该磁盘空间不低于20%)。 他们超级容易添加,我没有任何问题。
这里是VBScript文件我有一个关于高CPU使用率的警报。 如有必要,您可以修改脚本以包含凭据:
' Get command line parameters Dim ArgObj Set ArgObj = WScript.Arguments Dim strFrom, strTo, strSubject, strBody, strIPAddress strFrom = "SERVERNA<E <[email protected]>" strTo = "RECIPIENT <[email protected]>" strSubject = "Automated CPU Alert from SERVERNAME" strIPAddress = "IPADDRESS" ' get the body from the command line If ArgObj.Count > 0 Then strBody = ArgObj( 0 ) ' if the subject is specified as an argument then add it If ArgObj.Count > 1 Then strSubject = ArgObj( 1 ) End If Else strBody = "Default alert message body" End if Call SendEmail( strFrom, strTo, strSubject, strBody ) ' release memory Set ArgObj = Nothing ' Sub-routing to send an e-mail using the CDO component Sub SendEmail(sFromEmail, sToEmail, sSubject, sText ) Dim objMail Set objMail = CreateObject( "CDO.Message" ) objMail.From = sFromEmail objMail.To = sToEmail objMail.Subject = sSubject ' Send using an SMTP server objMail.Configuration.Fields.Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ) = 2 ' Name or IP of remote SMTP server objMail.Configuration.Fields.Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ) = strIPAddress ' Server port objMail.Configuration.Fields.Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ) = 25 objMail.Configuration.Fields.Update objMail.TextBody = sText objMail.Send Set objMail = nothing End Sub