Hello everyone,
Encountering a problem while applying a custom discovery rule via a Zabbix template on a Windows Server to identify the cluster shared volume. My Zabbix server is running version 5.0.15, as is my agent. Although we're able to fetch the JSON output during discovery, when fetching the item value discovery, the values aren't coming through, and the error displayed is "Unsupported item Key".
Here are the detailed steps:
$objs = @()
$csvs = Get-ClusterSharedVolume
foreach ($csv in $csvs)
{
$csvinfos = $csv | Select-Object -Property Name -ExpandProperty SharedVolumeInfo
foreach ($csvinfo in $csvinfos)
{
$obj = [PSCustomObject]@{
Name = $csv.Name
CSVPATH = $csvinfo.FriendlyVolumeName
Size = $csvinfo.Partition.Size
FreeSpace = $csvinfo.Partition.FreeSpace
UsedSpace = $csvinfo.Partition.UsedSpace
PercentFree = $csvinfo.Partition.PercentFree
}
$objs += $obj
}
}
$objs | ConvertTo-Json
{
"Name": "Cluster Disk 1",
"CSVPATH": "C:\\ClusterStorage\\Volume1",
"Size": 2894926442496,
"FreeSpace": 279024824320,
"UsedSpace": 2615901618176,
"PercentFree": 9.638409
},
{
"Name": "Cluster Disk 2",
"CSVPATH": "C:\\ClusterStorage\\Volume2",
"Size": 699863658496,
"FreeSpace": 679058444288,
"UsedSpace": 20805214208,
"PercentFree": 97.02725
}
]
UserParameter=csv.discovery,powershell.exe -ExecutionPolicy Bypass -file "C:\Program Files\Zabbix Agent\csv_latest.ps1"
Configuration on Zabbix Server GUI
Any assistance in identifying the issue or providing a fix would be greatly appreciated.
Any help in identifying the issue or any fix.
Encountering a problem while applying a custom discovery rule via a Zabbix template on a Windows Server to identify the cluster shared volume. My Zabbix server is running version 5.0.15, as is my agent. Although we're able to fetch the JSON output during discovery, when fetching the item value discovery, the values aren't coming through, and the error displayed is "Unsupported item Key".
Here are the detailed steps:
- Developed a PowerShell script to retrieve CSV details (script path: C:\Program Files\Zabbix Agent\csv_latest.ps1). The script snippet is as follows:
$objs = @()
$csvs = Get-ClusterSharedVolume
foreach ($csv in $csvs)
{
$csvinfos = $csv | Select-Object -Property Name -ExpandProperty SharedVolumeInfo
foreach ($csvinfo in $csvinfos)
{
$obj = [PSCustomObject]@{
Name = $csv.Name
CSVPATH = $csvinfo.FriendlyVolumeName
Size = $csvinfo.Partition.Size
FreeSpace = $csvinfo.Partition.FreeSpace
UsedSpace = $csvinfo.Partition.UsedSpace
PercentFree = $csvinfo.Partition.PercentFree
}
$objs += $obj
}
}
$objs | ConvertTo-Json
- Output of the PowerShell script in JSON format after execution:
{
"Name": "Cluster Disk 1",
"CSVPATH": "C:\\ClusterStorage\\Volume1",
"Size": 2894926442496,
"FreeSpace": 279024824320,
"UsedSpace": 2615901618176,
"PercentFree": 9.638409
},
{
"Name": "Cluster Disk 2",
"CSVPATH": "C:\\ClusterStorage\\Volume2",
"Size": 699863658496,
"FreeSpace": 679058444288,
"UsedSpace": 20805214208,
"PercentFree": 97.02725
}
]
- Integrated the script into UserParameters in zabbix_agentd.conf on the Windows client host:
UserParameter=csv.discovery,powershell.exe -ExecutionPolicy Bypass -file "C:\Program Files\Zabbix Agent\csv_latest.ps1"
Configuration on Zabbix Server GUI
- Template creation
- Discovery rule Creation
- LLD macros creation in discovery rule
- Discovery rule Tested and is giving proper json format response as per below screen
- Item Prototype Creation within the discovery rule – “cluster discovery”
- Item Prototype Testing is giving error as “Unsupported item key”
Any assistance in identifying the issue or providing a fix would be greatly appreciated.
Any help in identifying the issue or any fix.
Your discovery script already returns all the values, you should change item type to depending item, add some preprocessing to extract that value from master data (jsonpath).
Comment