Hi Guys,
I've got question about JS in zabbix preprocessing. So... I want to read Serial number from Cisco switch. I've got lot of them in my company. So I prepared a template and added a few items, one of them is a serial number. I entered the OID, but it displays everything, not just the SN. Is there anyone who knows how to program in JS and can cut the characters before the STRING and after the serial number?
I prepared a template and added a few items, one of which is a serial number. I entered the OID, but it displays everything, not just the SN(screenshot 1). Is there anyone who knows how to program in JS and can cut the characters before the STRING and after the serial number? I know I could use the discovery function, but I want the SN to move into the inventory automatically
Below JS code that does not execute- error "SyntaxError: parse error (line 5)"
Thanks for your help


I've got question about JS in zabbix preprocessing. So... I want to read Serial number from Cisco switch. I've got lot of them in my company. So I prepared a template and added a few items, one of them is a serial number. I entered the OID, but it displays everything, not just the SN. Is there anyone who knows how to program in JS and can cut the characters before the STRING and after the serial number?
I prepared a template and added a few items, one of which is a serial number. I entered the OID, but it displays everything, not just the SN(screenshot 1). Is there anyone who knows how to program in JS and can cut the characters before the STRING and after the serial number? I know I could use the discovery function, but I want the SN to move into the inventory automatically
Below JS code that does not execute- error "SyntaxError: parse error (line 5)"
Code:
function extractValues(inputString) {
var lines = inputString.split('\n'); //Splitting the input string into lines
var values = [];
for (var line of lines) {
//Finding the occurrence index of 'STRING:'
var stringIndex = line.indexOf('STRING:');
if (stringIndex !== -1) {
// Extracting the value after 'STRING:'
var value = line.substring(stringIndex + 7).trim();
//Checking if the value starts with 'DN'
if (value.startsWith('DN')) {
values.push(value);
}
}
}
return values;
}
Comment