====== S.M.A.R.T ====== Программы для мониторинга SMART: [[https://crystalmark.info/en/software/crystaldiskinfo/|CrystalDiskInfo]], [[https://www.smartmontools.org/|Smartmontools]], [[http://www.nirsoft.net/utils/disk_smart_view.html|DiskSmartView]], [[http://panterasoft.com/hdd-health/|HDD Health]], [[https://www.kcsoftwares.com/?hdde|HDD Expert]]. Самые важные параметры для отслеживания: * SMART 5 – Reallocated_Sector_Count. 1-4 keep an eye on it, more than 4 replace * SMART 187 – Reported_Uncorrectable_Errors. 1 or more replace * SMART 188 – Command_Timeout. 1-13 keep an eye on it, more than 13 replace * SMART 197 – Current_Pending_Sector_Count. 1 or more replace * SMART 198 – Offline_Uncorrectable. 1 or more replace https://superuser.com/questions/1222036/windows-script-for-now-hours-of-your-harddrive # показать статус всех дисков, у которых количество разделов больше 0 gcim Win32_DiskDrive |? Partitions -gt 0 | select SystemName,Model,@{n='Size(GB)';e={$_.Size / 1GB -as [int]}},InterfaceType,Status,MediaType,SerialNumber | ft -AutoSize -Wrap # Ещё варианты Get-PhysicalDisk | ft -AutoSize DeviceId,Model,MediaType,BusType,@{n='Size(GB)';e={$_.Size/1GB -as [int]}},SerialNumber,HealthStatus,OperationalStatus gwmi -Namespace root/wmi -Class MSStorageDriver_FailurePredictStatus |select instancename,PredictFailure,Reason,PSComputername gwmi -Namespace root/wmi -Class MSStorageDriver_ATAPISmartData ===== Проверка дисков ===== mountvol - показать точки подключения (полезно, если диск повреждён и не монтируется буквой). rem Пытаться исправить все ошибки на диске автоматически chkdsk \\?\Volume{0c45dbc7-0ff4-4b5c-8592-4f43b1573210}\ /F /R /X /B ===== DiskSmartView ===== # выгрузка и фильтрация отчёта, # если статус не OK, Unknown и не пустой, высылаем письмо $tmpcsv = '.\tmp.csv' $reportcsv = '.\report.csv' $tmphtml = '.\tmp.html' $reporthtml = '.\report.html' $header = 'Description,Raw value,Normalized value,Worst value,Threshold value,Status' $lastuser = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI |select -expand LastLoggedOnDisplayName & .\DiskSmartView.exe /scomma "$tmpcsv" sleep 5 $csv = -join $header, (gc "$tmpcsv") |ConvertFrom-Csv -Delimiter "," $status = $csv |where {$_.status -ne 'ok' -and $_.status -ne $null -and $_.status -ne 'unknown'} if ($status -ne $null) { # переделка отчёта в файл с разделителем ;, чтобы открывался в Экселе $csv |Export-Csv -Delimiter ';' -Encoding utf8 -NoTypeInformation $reportcsv # выгрузка и фильтрация отчёта в HTML & .\DiskSmartView.exe /shtml "$tmphtml" gc "$tmphtml" |where {$_ -notmatch 'html' -and $_ -notmatch 'body' -and $_ -notmatch 'Registry Key' -and $_ -notmatch 'h3'} | Set-Content "$reporthtml" $html = gc $reporthtml # мыло $from = 'user@yandex.ru' $to = 'user@outlook.com' $pass = gc .\mailpassword.txt $secpass = $pass | Convertto-SecureString -AsPlainText -Force $cred = New-Object -TypeName System.Management.Automation.PSCredential -Argumentlist $from,$secpass Send-MailMessage -From $from -To $to -Subject "Плохой отчёт SMART на компьютере $env:ComputerName" ` -SmtpServer smtp.yandex.ru -Encoding UTF8 -UseSsl -Credential $cred ` -Body "Пользователь: $lastuser
Логин: $env:UserName
Компьютер: $env:ComputerName $html" -BodyAsHtml ` -Attachments $reportcsv }
===== Smartmontools ===== Корректная работа пока не подтверждена https://github.com/deajan/smartmontools-win\\ Положить рядом с инсталлятором файлы erroraction_config.cmd (конфиг консольного почтаря) и smartd.conf.\\ Пароль в erroraction_config.cmd должен лежать в кодировке base64. Скрипт кодирования в base64 на Powershell: $Text = ‘This is a secret and should be hidden’ $Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text) $EncodedText =[Convert]::ToBase64String($Bytes) $EncodedText Установка из текущего каталога (cmd): %~dp0\smartmontools-win-6.5-1.exe /SUPPRESSMSGBOXES /SILENT