When not to use user parameters

There are also cases where user parameters are best replaced with a different solution. Usually, that will be when the following happens:

  • The script takes a long time
  • The script returns many values

In the first case, the script could simply time out. The default timeout on the agent side is three seconds, and it's not suggested to increase it in most cases.

In the second case, we might be interested in 100 values that a script could return in a single invocation, but Zabbix doesn't allow several values to be obtained from a single key or from a single invocation, so we would have to run the script 100 timesnot very efficient.

If a script supplies values for multiple trapper items, it might be worth adding a nodata() trigger for some of themthat way, any issues with the script and missing data would be discovered quickly.

There're several potential solutions, with some drawbacks and benefits for each case:

  • A special item (usually an external check, discussed in the following, or another user parameter) that could send the data right away using zabbix_sender if the data collection script is quick. If not, it could write data to temporary files or invoke another script with nohup.
  • crontab: This is a classic solution that can help both when the script takes a long time and when it returns many values. It does have the drawback of having interval management outside Zabbix. Values are usually sent right away using zabbix_sender (discussed later in this chapter), although they could also be written to temporary files and read by other items using the vfs.file.contents or vfs.file.regexp keys.
  • A special item (usually another user parameter) that adds an atd job. This solution is a bit more complicated, but allows us to keep interval management in Zabbix while still allowing the use of long-running scripts for data collection. See http://zabbix.org/wiki/Escaping_timeouts_with_atd for more details.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.107.241