Hello,
I want to create a trigger that counts the number of discovered OIDs. To make it more concrete: I discover the vlans on a switch, and when the number of vlans change, I want a trigger to be activated.
There is no OID for the number of vlans.
My attempt was to discover the vlans, and use Javascript preprocessing to count the number of items. This would create a LLD macro. Then I create a calculated item, using that macro.
Unfortunately, this gives the error 'item with the same key "xxx" already exists.' It looks like the discovery process loops over each item in the returned list, and preprocesses the complete list for each item.
This is the discovery rule:
discovery[{#VLAN_NAME_FOR_COUNT},1.3.6.1.4.1.9.9.46.1.3.1.1. 4.1]
This is the JS preprocessor:
d = JSON.parse(value);
return '[ {"{#TOTAL_NUMBER_OF_VLANS}": ' + d.length + '}]';
The calculated item is created with a fixed key (no macro used there) and formula:
{#TOTAL_NUMBER_OF_VLANS}
A side effect is that, although I get the duplicate item error, no item was created.
Any ideas how to fix this?
I want to create a trigger that counts the number of discovered OIDs. To make it more concrete: I discover the vlans on a switch, and when the number of vlans change, I want a trigger to be activated.
There is no OID for the number of vlans.
My attempt was to discover the vlans, and use Javascript preprocessing to count the number of items. This would create a LLD macro. Then I create a calculated item, using that macro.
Unfortunately, this gives the error 'item with the same key "xxx" already exists.' It looks like the discovery process loops over each item in the returned list, and preprocesses the complete list for each item.
This is the discovery rule:
discovery[{#VLAN_NAME_FOR_COUNT},1.3.6.1.4.1.9.9.46.1.3.1.1. 4.1]
This is the JS preprocessor:
d = JSON.parse(value);
return '[ {"{#TOTAL_NUMBER_OF_VLANS}": ' + d.length + '}]';
The calculated item is created with a fixed key (no macro used there) and formula:
{#TOTAL_NUMBER_OF_VLANS}
A side effect is that, although I get the duplicate item error, no item was created.
Any ideas how to fix this?