答案1
我将为此编写一个 powershell 脚本:
for(){
$params=@{
ClassName = 'Win32_PerfFormattedData_PerfDisk_LogicalDisk'
Filter = "Name = '_Total'"
ComputerName = $env:COMPUTERNAME
}
$data=gwmi @params
if($data.splitIOpersec -lt 20){
sleep -s 60
if($data.splitIOpersec -lt 20){
$email=@{
'From' = 'THE EMAIL ADDRESS OF SENDER COMPUTER'
'To' = 'THE EMAIL ADDRESS OF YOU'
'Subject' = 'Disk usage notification'
'Body' = 'Disk utilisation percentage is lower than 20% for more than 1 minute.'
'SMTPServer' = 'smtp.gmail.com'
'Port' = 587
}
$cred=New-Object Management.Automation.PSCredential "SENDER EMAIL ID", ("SENDER PASSWORD" | ConvertTo-SecureString -AsPlainText -Force)
Send-MailMessage @email -UseSSL -Credential $cred
}}}
这使用 GMail 通过 SMTP 服务器 smtp.gmail.com 和端口 587 以及 SSL 发送电子邮件。请根据需要进行替换。
(除非您使用 CTRL+C 终止,否则脚本将在发送方计算机上永久运行)