Good afternoon. It is necessary to receive data from the Item and pass it to the "Discovery rules", and then use it in the key on each "Item prototypes".
1) I get the data of the "Item".
I get:
2) I convert the result to the form (through preprocessing in JavaScript) to Json.
Preprocessing:
I get:
3) I create a "Discovery rule":
Type: Dependent items
4) I create a "Item prototypes":
But data from №3 comes to №4 as ["sda"], but I need it as sda. For me to use them in the key of "Item prototypes". For example:
Can you please tell me how to pass the value sda to the key of "Item prototypes"?
1) I get the data of the "Item".
Code:
Type: Zabbix agent Key: system.run["smartctl --scan-open"]
Code:
/dev/sda -d ata # /dev/sda, ATA device /dev/sdb -d sat # /dev/sdb [SAT], ATA device /dev/sdc -d sat # /dev/sdc [SAT], ATA device
Preprocessing:
Code:
const sd = value.match(/sd(.)/g);
var data = [];
for (i = 0; i <= sd.length; i++) {
if (i % 2 == 0) {
data.push({"disk": sd[i]});
}
}
data.pop();
return JSON.stringify(data);
I get:
Code:
[{"disk":"sda"},{"disk":"sdb"},{"disk":"sdc"}]
3) I create a "Discovery rule":
Type: Dependent items
Code:
LLD macros: LLD - {#DISK} and JSONPath - $..disk
4) I create a "Item prototypes":
Code:
Type: Zabbix agent
Key: system.run["smartctl -A /dev/[{$DISK}]"]
But data from №3 comes to №4 as ["sda"], but I need it as sda. For me to use them in the key of "Item prototypes". For example:
Code:
system.run["smartctl -A /dev/sda"]
Comment