Close
Log in to Zabbix Blog
Email
Password
Show password Hide password
Forgot password?
Incorrect e-mail and/or password
or
By creating an account or logging in with an existing account, you agree to our Terms of Service
Handy TipsTechnicalHow ToIntegrationsConferencesCommunityNewsSocialInterviewCase Study

Monitoring directory contents

With item pre-processing added to LLD workflow and new javascript pre-processing step, it’s possible to monitor a directory for its file changes. The trick is to use javascript pre-preprocessing step to convert file list to LLD format. The file list can be obtained with system.run key (requires enabled EnableRemoteCommands parameter in agent configuration file) or […]

With item pre-processing added to LLD workflow and new javascript pre-processing step, it’s possible to monitor a directory for its file changes.

The trick is to use javascript pre-preprocessing step to convert file list to LLD format. The file list can be obtained with system.run key (requires enabled EnableRemoteCommands parameter in agent configuration file) or by user parameter (the UserParameter parameters in agent configuration file).

Create a discovery rule based on system.run key:

system.run[find /etc/* -maxdepth 0 -type f]

Add javascript preprocessing step to convert the file list into Zabbix low level discovery data:

var lld = [];
var lines = value.split("\n");
var lines_num = lines.length;
for (i = 0; i < lines_num; i++)
{
  var row = {};
  row["{#FILE}"] = lines[i]
  lld.push(row);
}
return JSON.stringify(lld);

The script takes file list and command output and converts it into JSON format:

[
  {
    "{#FILE}": "<full path to file>"
  },
  {
    "{#FILE}": "<full path to file>"
  }
]

Add item prototype to monitor checksums:

 

And finally, the trigger to generate events:

Prev Post Prev Post Next Post Next Post
Subscribe
Notify of
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
author_85181
author_85181
5 years ago

This is a placeholder comment.

author_85285
author_85285
4 years ago

This is a placeholder comment.

2
0
Would love your thoughts, please comment.x
()
x