checkcammer

function SendMail([String]$mailcontent)
{
    $From = "usr@qq.com"
    $To = "usr@qq.com"
    $Subject = $mailcontent
    $Body = $mailcontent
    $Password = 'pwd' | ConvertTo-SecureString -AsPlainText -Force
    $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $From, $Password

    Send-MailMessage -From $From -To $To -Subject $Subject -Body $Body -SmtpServer "smtp.qq.com" -port 587 -UseSsl -Credential $Credential
}


$cammer=@(
'192.168.2.23',
'192.168.2.25',
'192.168.2.27',
'192.168.2.28',
'192.168.2.29'
)

for ($i = 0; $i -lt 5; $i++){
    $mailcontent = "Empty"
    $nvrstor = Get-Process | Where-Object Name -eq 'NvrStorageSever'
    if ( $null -eq $nvrstor){
        $mailcontent = "NvrStorageSever is not running!"
        #SendMail( $mailcontent )
        Write-EventLog  -LogName Application -Source "hknvr" -EntryType Warning -EventID 1001 -Message $mailcontent
    }else{
        $cammer | ForEach-Object {
            $ip = $_
            $tcpcnt = Get-NetTCPConnection | Where-Object {$_.RemoteAddress -eq $ip -and $_.OwningProcess -eq $nvrstor.Id}

            if ($null -eq $tcpcnt)
            {
                $mailcontent = "IP:" + $ip + " has no tcp connetion."
                #SendMail( $mailcontent )
                Write-EventLog  -LogName Application -Source "hknvr" -EntryType Warning -EventID 1002 -Message $mailcontent
            }else{
                #$mailcontent = "IP:" + $ip + " has tcp connetion."
                #SendMail( $mailcontent )
            }
        }
    }

    $FindDate=Get-Date
    $rsl = Get-ChildItem -Path F:\,G:\ -Include *.mp4 -File -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -le $Finddate -and $_.LastWriteTime -ge $FindDate.AddHours(-1)  } | Select -First 1

    if ($null -eq $rsl) {
        Write-EventLog  -LogName Application -Source "hknvr" -EntryType Warning -EventID 1003 -Message "No new mp4 file created!"
    }
    Start-Sleep 600
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值