Item Preprocessing with JavaScript | Zabbix-6 | Lesson 26

Опубликовано: 04 Октябрь 2024
на канале: Kamran Awan
303
18

A small JavaScript function that extracts the first line of the log event description, and also extracts the username, concatenates them and returns that as a new value for further treatment in Zabbix.
The benefit of using JavaScript for extracting data from the log text is the many extra possible options you have in deciding on the final output.


This is the script used in the item preprocessor

var lines = value.split("\n");
var lineZero = lines[0];
var accountName = "";
lines.forEach(function (line) {
if (line.trim().substring(0, 13) === "Account Name:") {
accountName = line.substring(14).trim();
}
});
return accountName + " : " + lineZero;


#zabbix6
#zabbix
#OnlineITEducation
#OnlineEducation
#ITEducation