I have created a Discovery called Windows Disk Discovery, which uses a userparameter script to discover.
Script:
$drives = Get-WmiObject win32_PerfFormattedData_PerfDisk_PhysicalDisk | Where-Object { $_.name -ne "_Total" } | Select-Object Name
$idx = 1
Write-Host "{"
Write-Host " `"data`":[`n"
foreach ($perfDrives in $drives)
{
$line = "{ `"{#DISKLETTER}`" : `"" + ($perfDrives.Name -replace '[^a-zA-Z]', '') + ":`" },"
Write-Host $line
if ($idx -lt $drives.Count)
{
$line = "{ `"{#DISKNUMLET}`" : `"" + $perfDrives.Name + "`" },"
Write-Host $line
}
elseif ($idx -ge $drives.Count)
{
$line = "{ `"{#DISKNUMLET}`" : `"" + $perfDrives.Name + "`" }"
Write-Host $line
}
$idx++;
}
Write-Host
Write-Host " ]"
Write-Host "}"
And this returns the correct information, for example:
{
"data":[
{ "{#DISKLETTER}" : "C:" },
{ "{#DISKNUMLET}" : "0 C:" },
{ "{#DISKLETTER}" : "D:" },
{ "{#DISKNUMLET}" : "1 D:" },
{ "{#DISKLETTER}" : "E:" },
{ "{#DISKNUMLET}" : "2 E:" }
]
}
Zabbix Server then creates all the required Items / triggers etc...
But then next to the Discovery entry, I get the errors:
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\% Disk Time",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\% Disk Time",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Avg. Disk Queue Length",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Avg. Disk Queue Length",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Read Bytes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Read Bytes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Reads/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Reads/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Write Bytes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Write Bytes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Writes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Writes/sec",30]" already exists.
Cannot create item: item with the same key "vfs.fs.size[{#DISKLETTER},pfree]" already exists.
Cannot create item: item with the same key "vfs.fs.size[{#DISKLETTER},pfree]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\% Disk Time",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Avg. Disk Queue Length",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET}
The Items prototypes in the discovery are:

Can anyone see whats causing the errors?
Script:
$drives = Get-WmiObject win32_PerfFormattedData_PerfDisk_PhysicalDisk | Where-Object { $_.name -ne "_Total" } | Select-Object Name
$idx = 1
Write-Host "{"
Write-Host " `"data`":[`n"
foreach ($perfDrives in $drives)
{
$line = "{ `"{#DISKLETTER}`" : `"" + ($perfDrives.Name -replace '[^a-zA-Z]', '') + ":`" },"
Write-Host $line
if ($idx -lt $drives.Count)
{
$line = "{ `"{#DISKNUMLET}`" : `"" + $perfDrives.Name + "`" },"
Write-Host $line
}
elseif ($idx -ge $drives.Count)
{
$line = "{ `"{#DISKNUMLET}`" : `"" + $perfDrives.Name + "`" }"
Write-Host $line
}
$idx++;
}
Write-Host
Write-Host " ]"
Write-Host "}"
And this returns the correct information, for example:
{
"data":[
{ "{#DISKLETTER}" : "C:" },
{ "{#DISKNUMLET}" : "0 C:" },
{ "{#DISKLETTER}" : "D:" },
{ "{#DISKNUMLET}" : "1 D:" },
{ "{#DISKLETTER}" : "E:" },
{ "{#DISKNUMLET}" : "2 E:" }
]
}
Zabbix Server then creates all the required Items / triggers etc...
But then next to the Discovery entry, I get the errors:
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\% Disk Time",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\% Disk Time",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Avg. Disk Queue Length",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Avg. Disk Queue Length",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Read Bytes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Read Bytes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Reads/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Reads/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Write Bytes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Write Bytes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Writes/sec",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Disk Writes/sec",30]" already exists.
Cannot create item: item with the same key "vfs.fs.size[{#DISKLETTER},pfree]" already exists.
Cannot create item: item with the same key "vfs.fs.size[{#DISKLETTER},pfree]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\% Disk Time",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET})\Avg. Disk Queue Length",30]" already exists.
Cannot create item: item with the same key "perf_counter["\PhysicalDisk({#DISKNUMLET}
The Items prototypes in the discovery are:
Can anyone see whats causing the errors?