Zabbix: Monitoring Raid Windows

C:\scripts\check_raid.ps1

$dp = "list volume" | diskpart | ? { $_ -match "^ [^-]" }
 $checksum = "0"foreach ($row in $dp) {
 # skip first line
 if (!$row.Contains("Volume ###")) {# best match RegExp from http://www.eventlogblog.com/blog/2012/02/how-to-make-the-windows-softwa.html
 if ($row -match "\s\s(Volume\s\d)\s+([A-Z])\s+(.*)\s\s(NTFS|FAT)\s+(Mirror|RAID-5|Stripe|Spiegel|Spiegelung|Übergreifend|Spanned)\s+(\d+)\s+(..)\s\s([A-Za-z]*\s?[A-Za-z]*)(\s\s)*.*") {
 $disk = $matches[2]
 # 0 = OK, 1 = WARNING, 2 = CRITICAL
 $statusCode = 1
 $status = "WARNING"
 $text = "Could not parse line: $row"
 $line = $row
 if ($line -match "Fehlerfre |OK|Healthy") {
 $statusText = "is healthy"
 $statusCode = 0
 $status = "OK"
 elseif ($line -match "Rebuild") {
 $statusText = "is rebuilding"
 $statusCode = 1
 $checksum = i++
 }
 elseif ($line -match "Failed|At Risk|Fehlerhaf") {
 $statusText = "failed"
 $statusCode = 2
 $status = "CRITICAL"
 $checksum = i++
}
 #echo "$statusCode microsoft_software_raid - $status - Software RAID on disk ${disk}:\ $statusText"
 }
 }
}
echo $checksum

echo #CONTROLLO RAID >> c:\zabbix_agentd.conf
 echo UserParameter=custom.msraid,powershell -command "C:\scripts\check_raid.ps1" >> c:\zabbix_agentd.conf
net stop "Zabbix Agent"
 net start "Zabbix Agent"
On the Zabbix server add to the Windows Template:
Items:
 Host: Template_IS_Linux
 Description: MDStat
 Type: Zabbix_agent
 Key: custom.mdstat
 Applications: Availability, Filesystem
Trigger:
 Name: RAID on {HOSTNAME}
 Expression: {Template_OS_Linux:custom.mdstat.last(0)}>0