This is an old revision of the document!
Временами есть знаки о предстоящих событиях. Эти знаки могут быть обозначены так что действия могут быть выполнены в для предотвращения либо как минимум для уменьшения воздействия проблемы.
Zabbix имеет инструменты для предсказания будущего поведения наблюдаемой системы на основе исторических данных. Эти инструменты реализованы через функции предсказания триггеров.
Две вещи нужно знать, это как определить проблемное состояние и сколько времени нужно для получения действия. Далее есть два пути настроить триггер сигнализирующий о потенциально нежелательной ситуации. Первый: триггер должен “пожечься” когда система после “времени действия” как ожидается будет в проблемном состоянии. Второй: триггер должен “поджечься” когда система собирается достигнуть проблемного состояния в промежуток менее чем “время действия”. Соответсвующие функции триггеров используются это forecast и timeleft*. Обратите внимание что лежащая в основе статистический анализ является в основном идентичным для обоих функций. Вы можете настроить триггер предпочтительным вам способом с похожими результатами.
Обе функции используют почти одинаковый набор параметров. Используйте перечень поддерживаемых функций для уточнения.
В первую очередь вы должны определить период времени исторических данных которые Zabbix должен анализировать для предсказания. Вы можете сделать это знакомым способом определив параметр время
и опционально сдвиг_времени
как вы это делаете с функциями avg, count, delta, max, min and sum.
(только для forecast )
Параметр время
определяет как долго в будущем Zabbix должен предполагать зависимости которые он находит в данных истории. Не важно используете ли вы time_shift
или нет, time
всегда отсчитывается начиная с текущего момента.
(timeleft only)
Parameter threshold
specifies a value the analysed item has to reach, no difference if from above or from below. Once we have determined f(t) (see below) we should solve equation f(t) = f(t) = threshold
and return the root which is closer to now and to the right from now or 999999999999.9999 if there is no such root.
<note tip>When item values approach the threshold and then cross it, timeleft assumes that intersection is already in the past and therefore switches to the next intersection with threshold
level, if any. Best practice should be to use predictions as a complement to ordinary problem diagnostics, not as a substitution.1)</note>
Default fit
is the linear function. But if your monitored system is more complicated you have more options to choose from.
^ fit
^ x = f(t) ^
|linear |x = a + b*t |
|polynomialN2) |x = a0 + a1*t + a2*t2 + … + an*tn |
|exponential |x = a*exp(b*t) |
|logarithmic |x = a + b*log(t) |
|power |x = a*tb |
(forecast only)
Every time a trigger function is evaluated it gets data from the specified history period and fits a specified function to the data. So, if the data is slightly different the fitted function will be slightly different. If we simply calculate the value of the fitted function at a specified time in the future you will know nothing about how the analysed item is expected to behave between now and that moment in the future. For some fit
options (like polynomial) a simple value from the future may be misleading.
^ mode
^ forecast result ^
|value |f(now + time
) |
|max |maxnow <= t <= now + time
f(t) |
|min |minnow <= t <= now + time
f(t) |
|delta |max - min |
|avg |average of f(t) (now <= t <= now + time
) according to definition |
To avoid calculations with huge numbers we consider the timestamp of the first value in specified period plus 1 ns as a new zero-time (current epoch time is of order 109, epoch squared is 1018, double precision is about 10-16). 1 ns is added to provide all positive time values for logarithmic and power fits which involve calculating log(t). Time shift does not affect linear, polynomial, exponential (apart from easier and more precise calculations) but changes the shape of logarithmic and power functions.
Functions return -1 in such situations: * specified evaluation period contains no data; * result of mathematical operation is not defined3); * numerical complications (unfortunately, for some sets of input data range and precision of double-precision floating-point format become insufficient)4). <note tip>No warnings or errors are flagged if chosen fit poorly describes provided data or there is just too few data for accurate prediction.</note>
To get a warning when you are about to run out of free disk space on your host you may use a trigger expression like this: <code>{host:vfs.fs.size[/,free].timeleft(1h,,0)}<1h</code> However, error code -1 may come into play and put your trigger in a problem state. Generally it's good because you get a warning that your predictions don't work correctly and you should look at them more thoroughly to find out why. But sometimes it's bad because -1 can simply mean that there was no data about the host free disk space obtained in the last hour. If you are getting too many false positive alerts consider using more complicated trigger expression5): <code>{host:vfs.fs.size[/,free].timeleft(1h,,0)}<1h and {host:vfs.fs.size[/,free].timeleft(1h,,0)}<>-1</code> Situation is a bit more difficult with forecast. First of all, -1 may or may not put the trigger in a problem state depending on whether you have expression like <code>{host:item.forecast(…)}<…</code> or like <code>{host:item.forecast(…)}>…</code> Furthermore, -1 may be a valid forecast if it's normal for the item value to be negative. But probability of this situation in the real world situation is negligible (see how operator =** works). So add
... or {host:item.forecast(...)}=-1or
... and {host:item.forecast(...)}<>-1if you want or don't want to treat -1 as a problem respectively.
{host:item.timeleft(1h,,X)} < 1hmay go into problem state when the item value approaches X and then suddenly recover once value X is reached. If the problem is item value being below X use:
{host:item.last()} < X or {host:item.timeleft(1h,,X)} < 1hIf the problem is item value being above X use:
{host:item.last()} > X or {host:item.timeleft(1h,,X)} < 1h
{host:vfs.fs.size[/,free].timeleft(1h,,0)}<1h and ({TRIGGER.VALUE}=0 and {host:vfs.fs.size[/,free].timeleft(1h,,0)}<>-1 or {TRIGGER.VALUE}=1)