window 環境下vb 磁碟空間監控指令碼!

來源:互聯網
上載者:User

標籤:空間   監控   window   


Set objFSO = CreateObject ("Scripting.FileSystemObject")

Set colDrives = objFSO.Drives

Dim msg

For Each objDrive in colDrives

       If objDrive.IsReady and  objDrive.DriveLetter ="D" and  int(objDrive.FreeSpace/(1024*1024*1024))<=400 Then

        

       call CheckFile("備份伺服器10.158.32.142的空間小於40G ,請清理曆史備份檔案或是添加磁碟空間,否則備份將異常終止")         

      

       End If

Next


‘定義一個函數,檢查每天的備份是否產生


function CheckFile(byval TextBody )

   Const Email_From = "[email protected]" ‘寄件者郵箱 

Const Password = "123456" ‘寄件者郵箱密碼 

Const Email_To = "[email protected];[email protected]" ‘收件者郵箱 


Set CDO = CreateObject("CDO.Message") ‘建立CDO.Message對象 

CDO.Subject = "磁碟空間不足"  ‘郵件主題 

CDO.From = Email_From ‘寄件者地址 

CDO.To = Email_To ‘收件者地址 

CDO.TextBody = TextBody ‘郵件內文 

‘cdo.AddAttachment = "C:\hello.txt" ‘郵件附件檔案路徑 

Const schema = "http://schemas.microsoft.com/cdo/configuration/" ‘規定必須是這個,我也不知道為什麼 


With CDO.Configuration.Fields ‘用with關鍵字減少代碼輸入 

.Item(schema & "sendusing") = 2 ‘使用網路上的SMTP伺服器而不是本地的SMTP伺服器 

.Item(schema & "smtpserver") = "smtp.163.com" ‘SMTP伺服器位址 

.Item(schema & "smtpauthenticate") = 1 ‘伺服器認證方式 

.Item(schema & "sendusername") = Email_From ‘寄件者郵箱 

.Item(schema & "sendpassword") = Password ‘寄件者郵箱密碼 

.Item(schema & "smtpserverport") = 25 ‘SMTP伺服器連接埠 

.Item(schema & "smtpusessl") = True ‘是否使用SSL 

.Item(schema & "smtpconnectiontimeout") = 60 ‘串連伺服器的逾時時間 

.Update ‘更新設定 

End With 


 CDO.Send ‘發送郵件 

 

End function 


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.