Do you need an alert for CPU, for network?
Here is an example for one network card.
You can put in a ps1 file and run it from task scheduler.
You should set the email and SMTP addresses:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
######## task scheduler ####################### # # prereq for powershel by task scheduler : # !! - Set-ExecutionPolicy Unrestricted - !! # # user: SYSTEM # # run whereher user is logged on or not # run with highest privileges # # action: start a program # program/script powershell # add arguments (optional) : -file D:\Budapest_DBA\MonitoringDiskSpaceReporting\volumespace-monitoring-smtp-mail.ps1 # Start in (optional): D:\Budapest_DBA\MonitoringDiskSpaceReporting\ ################################################ $perfvalue= (Get-Counter -counter "\\server0056\network interface(hp nc375i integrated quad port multifunction gigabit server adapter)\bytes total/sec" -MaxSamples 3 -SampleInterval 5 | select -expand CounterSamples | Measure-Object -average cookedvalue).Average Write-Output $perfvalue if( $perfvalue -ge 5000){ $body ="Automata monitoring alert email. Network Traffic is high, maybe take a look:<br> \Network Interface(*)\Bytes Total/sec value:<b> $perfvalue </b><br> Gábor" Send-MailMessage -Body $body -BodyAsHtml -From "sqlserver@company.com" -SmtpServer "smtp.company.com" -Subject "performance alert $env:computername Network Traffic" -To "dbateam@company.com" -Encoding utf8 } |