With a Windows 2012 Cluster Microsoft introduced a new file system - CSVFS. I found that currently the zabbix agent does not return this file system when using the vfs.fs.discovery low level discovery for the file system. Additionally the low level discovery will not work on volumes that have been mapped to a directory instead of a driver letter. So I wrote a powershell script to handle the volume discovery and disk free space monitoring:
More on setting up the script:
Code:
param(
[Parameter(Mandatory=$False)]
[string]$QueryName,
[string]$FSName
)
if ($QueryName -eq '') {
$colItems = gwmi win32_volume | select Name,FileSystem
write-host "{"
write-host " `"data`":["
write-host
foreach ($objItem in $colItems) {
$objItem.Name = $objItem.Name -replace "\\\\\?\\Volume{","Volume-"
$objItem.Name = $objItem.Name -replace "}\\","`+"
$objItem.Name = $objItem.Name -replace "\\","/"
$line = " { `"{#FSNAME}`":`"" + $objItem.Name + "`" , `"{#FSTYPE}`":`"" + $objItem.FileSystem + "`" },"
write-host $line
}
write-host
write-host " ]"
write-host "}"
write-host
}
else {
#$FSName = [regex]::escape($FSName)
$FSName = $FSName -replace "Volume-","\\\\?\\Volume{"
$FSName = $FSName -replace "\+","}\\"
$FSName = $FSName -replace "/","\\"
switch ($QueryName)
{
('Capacity') {$Results = gwmi win32_volume -Filter "name = '$FSName'" | select Capacity | Format-Table -HideTableHeaders -AutoSize}
('FreeSpace') {$Results = gwmi win32_volume -Filter "name = '$FSName'" | select FreeSpace | Format-Table -HideTableHeaders -AutoSize}
default {$Results = "Incorrect Command Given"}
}
$Results = $Results | Out-String
$Results = $Results.trim()
Write-Host $Results
}
Comment