<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>6.0</version>
    <date>2024-01-10T06:21:36Z</date>
    <groups>
        <group>
            <uuid>7df96b18c230490a9a0a9e2307226338</uuid>
            <name>Templates</name>
        </group>
    </groups>
    <templates>
        <template>
            <uuid>654a3955e4bc4b99abfcc723ab48f989</uuid>
            <template>Template Itgrix BX</template>
            <name>Template Itgrix BX</name>
            <description># Требования

Наличие программы curl на узле, к которому применен шаблон

# Установка

Добавьте в конфигурацию Zabbix агента узла строку с пользовательским параметром:

UserParameter=itgrix.bx.curl.auth[*],curl -s $4 -u '$2':'$3' '$1'

После чего нужно перезагрузить Zabbix агента.

# Настройка

Примените шаблон к узлу.

В настройках узла переопределите значения макросов {$ITGRIX_BX_USER}, {$ITGRIX_BX_PASSWORD} и при необходимости {$ITGRIX_BX_STATUS_URL}.</description>
            <groups>
                <group>
                    <name>Templates</name>
                </group>
            </groups>
            <items>
                <item>
                    <uuid>7fda3ae66d5548b2b3631eb85fdb0fe8</uuid>
                    <name>Состояние Itgrix BX</name>
                    <type>DEPENDENT</type>
                    <key>itgrix.bx.app_status</key>
                    <delay>0</delay>
                    <history>7d</history>
                    <trends>0</trends>
                    <value_type>TEXT</value_type>
                    <description>При рабочем состоянии должен возвращаться статус Ok</description>
                    <preprocessing>
                        <step>
                            <type>JSONPATH</type>
                            <parameters>
                                <parameter>$.app.master.general.app_status</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>itgrix.bx.curl.auth[{$ITGRIX_BX_STATUS_URL},{$ITGRIX_BX_USER},{$ITGRIX_BX_PASSWORD},{$ITGRIX_BX_CURL_OPT}]</key>
                    </master_item>
                    <tags>
                        <tag>
                            <tag>Application</tag>
                            <value>Itgrix BX</value>
                        </tag>
                    </tags>
                    <triggers>
                        <trigger>
                            <uuid>d32e1fa417f843ebb242ff8edfae4c02</uuid>
                            <expression>last(/Template Itgrix BX/itgrix.bx.app_status)&lt;&gt;&quot;Ok&quot;</expression>
                            <name>Itgrix BX : статус</name>
                            <opdata>Статус: {ITEM.LASTVALUE}</opdata>
                            <priority>AVERAGE</priority>
                            <tags>
                                <tag>
                                    <tag>service</tag>
                                    <value>Itgrix</value>
                                </tag>
                            </tags>
                        </trigger>
                    </triggers>
                </item>
                <item>
                    <uuid>dcccd2a8aeb94571b7011ca9a50fb9e5</uuid>
                    <name>Itgrix BX raw data</name>
                    <key>itgrix.bx.curl.auth[{$ITGRIX_BX_STATUS_URL},{$ITGRIX_BX_USER},{$ITGRIX_BX_PASSWORD},{$ITGRIX_BX_CURL_OPT}]</key>
                    <delay>30m</delay>
                    <history>0</history>
                    <trends>0</trends>
                    <value_type>TEXT</value_type>
                    <description>Результат запроса</description>
                    <preprocessing>
                        <step>
                            <type>NOT_MATCHES_REGEX</type>
                            <parameters>
                                <parameter>^Unauth</parameter>
                            </parameters>
                            <error_handler>CUSTOM_ERROR</error_handler>
                            <error_handler_params>Ошибка аутентификации, проверьте имя и пароль</error_handler_params>
                        </step>
                    </preprocessing>
                    <tags>
                        <tag>
                            <tag>Application</tag>
                            <value>Itgrix BX</value>
                        </tag>
                    </tags>
                </item>
                <item>
                    <uuid>d0e54c315f9a40af9bf00667a56342e0</uuid>
                    <name>Срок действия лицензии</name>
                    <type>DEPENDENT</type>
                    <key>itgrix.bx.valid_till</key>
                    <delay>0</delay>
                    <history>7d</history>
                    <trends>30d</trends>
                    <value_type>FLOAT</value_type>
                    <preprocessing>
                        <step>
                            <type>JSONPATH</type>
                            <parameters>
                                <parameter>$.app.license_manager.currentLicense.valid_till</parameter>
                            </parameters>
                            <error_handler>CUSTOM_VALUE</error_handler>
                            <error_handler_params>2000-01-01</error_handler_params>
                        </step>
                        <step>
                            <type>JAVASCRIPT</type>
                            <parameters>
                                <parameter>if ( /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.test(value) ) {
  return Math.ceil((new Date(value) - new Date()) / (1000 * 86400))
} else return -1000</parameter>
                            </parameters>
                        </step>
                    </preprocessing>
                    <master_item>
                        <key>itgrix.bx.curl.auth[{$ITGRIX_BX_STATUS_URL},{$ITGRIX_BX_USER},{$ITGRIX_BX_PASSWORD},{$ITGRIX_BX_CURL_OPT}]</key>
                    </master_item>
                    <tags>
                        <tag>
                            <tag>Application</tag>
                            <value>Itgrix BX</value>
                        </tag>
                    </tags>
                    <triggers>
                        <trigger>
                            <uuid>4ef0cc00b0974179bfdca9a35679b5a7</uuid>
                            <expression>last(/Template Itgrix BX/itgrix.bx.valid_till)&lt;={$ITGRIX_BX_LICENSE_WARN} and last(/Template Itgrix BX/itgrix.bx.valid_till)&gt;=0</expression>
                            <name>Itgrix BX : лицензия</name>
                            <opdata>Дней до окончания: {ITEM.LASTVALUE}</opdata>
                            <priority>AVERAGE</priority>
                        </trigger>
                        <trigger>
                            <uuid>623705ec642141c9b014aade355d7e2c</uuid>
                            <expression>last(/Template Itgrix BX/itgrix.bx.valid_till)&lt;0 and last(/Template Itgrix BX/itgrix.bx.valid_till)&gt;=-365</expression>
                            <name>Itgrix BX : лицензия истекла</name>
                            <priority>HIGH</priority>
                            <tags>
                                <tag>
                                    <tag>service</tag>
                                    <value>Itgrix</value>
                                </tag>
                            </tags>
                        </trigger>
                        <trigger>
                            <uuid>9a8531a59e3449fd90e2f65319b60d61</uuid>
                            <expression>last(/Template Itgrix BX/itgrix.bx.valid_till)&lt;-365</expression>
                            <name>Itgrix BX : проверка лицензии</name>
                            <opdata>Неожиданный результат</opdata>
                            <priority>AVERAGE</priority>
                            <description>Запрос срока лицензии Itgrix BX вернул неожиданный результат</description>
                        </trigger>
                    </triggers>
                </item>
            </items>
            <macros>
                <macro>
                    <macro>{$ITGRIX_BX_CURL_OPT}</macro>
                    <value>--digest</value>
                    <description>Опции curl</description>
                </macro>
                <macro>
                    <macro>{$ITGRIX_BX_LICENSE_WARN}</macro>
                    <value>7</value>
                    <description>Срок предупреждения об истечении лицензии</description>
                </macro>
                <macro>
                    <macro>{$ITGRIX_BX_PASSWORD}</macro>
                    <value>secret</value>
                    <description>Пароль от сервиса</description>
                </macro>
                <macro>
                    <macro>{$ITGRIX_BX_STATUS_URL}</macro>
                    <value>sip.example.ru:8077/status</value>
                    <description>Проверяемый адрес</description>
                </macro>
                <macro>
                    <macro>{$ITGRIX_BX_USER}</macro>
                    <value>user</value>
                    <description>Имя пользователя</description>
                </macro>
            </macros>
        </template>
    </templates>
</zabbix_export>
