Assuming you have SMART enabled on your windows disks, here's a powershell script that the Zabbix windows agent can use with template_smartd. While smart isn't a very good predictor of drive failure, it can alert you to heat issues. In this example, you'd call the script c:\drivetemp.ps1
Code:
#IT'S not my fault if you nuke your corp's domain controller hard disks.... #In a nutshell, this is a powershell v.1 script that calls smartctl.exe, does stuff with the values #and echoes the data back to Zabbix. #Define the parameters for Zabbix to call param($arg1,$arg2) #YOU MUST EDIT & TEST THIS for YOUR SYSTEM. #start by executing smartctl.exe -a hda > disk1.txt on your system #then open disk1.txt and start counting lines. #zabbix_agentd.conf line for this in windows: #UserParameter=system.smartd[*],C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe c:\disktemp.ps1 $1 $2 # below is because I'm too lazy to change the parameter names I stole from here: # http://www.zabbix.com/wiki/howto/monitor/os/linux/smart #/dev/sda = hda in Windows if ($arg1-eq "/dev/sda") {$arg1 = "hda"} # WTF powershell comparison operator for equals is actually "-eq", but assignment equals is "=". # Sorry, I did vbscript for a long time and would prefer to spend my syntax time learning # python, because that's what all the cool kids write in these days. if ($arg1-eq "/dev/sdb") {$arg1 = "hdb"} #requires smartmontools (windows) at the location of your choice as long as it's right on the next line # Execute smartctl and assign the output to a variable $smartctl ="c:\smartctl.exe -A " + $arg1 # the numbers between the [] are the lines on smartctl -A output that you want #each drive is different and windows doesn't have that many command-line tools to get everything you want #so you're left to edit a script below $smartdata = (Invoke-Expression $smartctl)[6..23] $i = 1 do { # all the below is necessary to replace one line of string manipulation in Linux. $length = $smartdata[$i].ToString().length $e = $smartdata[$i].ToString().Substring(4,24).Trim() $d = $smartdata[$i].ToString().Substring(87,($length-87)).Trim() # Temperature needs cleaning if ($e-eq "Temperature_Celsius") {$d = $smartdata[$i].ToString().Substring(87,2) } if ($e-eq $arg2) { echo $d } $i=$i+1 #echo $i #useful for figuring out how many attributes you can get when you're debugging. } # while number needs equal the number of your data lines. You may need to change 15 to something else. while ($i-le 15)
Comment