From 8746596e014ed5dec3b3ecbe178a013bf3e07838 Mon Sep 17 00:00:00 2001 From: Pavel Muhortov Date: Sat, 29 Jun 2024 11:22:42 +0300 Subject: [PATCH] added 'asterisk' --- README.md | 1 + templates/applications/asterisk/6.0/README.md | 65 ++++++++++ .../asterisk_by_http-tsp_network_check.yaml | 122 ++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100755 templates/applications/asterisk/6.0/README.md create mode 100644 templates/applications/asterisk/6.0/asterisk_by_http-tsp_network_check.yaml diff --git a/README.md b/README.md index 340e503..ee0ec30 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Templates, scripts and hints for Zabbix. ## [Templates](templates) * [Applications](templates/applications) + * [Asterisk](templates/applications/asterisk/6.0) * [check.business.ru](templates/applications/check.business.ru/6.0) * [MiniDLNA](templates/applications/minidlna/6.0) * [VPN](templates/applications/vpn) diff --git a/templates/applications/asterisk/6.0/README.md b/templates/applications/asterisk/6.0/README.md new file mode 100755 index 0000000..9b2467e --- /dev/null +++ b/templates/applications/asterisk/6.0/README.md @@ -0,0 +1,65 @@ + +# Asterisk by HTTP - TSP network check + +## Overview + +This template is designed for Asterisk custom web-page parse by HTTP agent and doesn't require any external scripts. + +Custom web-page request: + +```shell +curl http://asterisk/network_check.php +``` + +Custom web-page response: + +```json +{"providers":[{"name":"tsp-1","last_check":"2001-01-01 01:01:01"},{"name":"tsp-2","last_check":"2002-02-02 02:02:02"}]} +``` + +## Requirements + +- Zabbix version: 6.0 and higher. + +## Tested versions + +This template has been tested on: + +- [Debian GNU/Linux 12](http://ftp.debian.org/debian/dists/bookworm/) + +### Macros used + +|Name|Description|Default| +|----|-----------|-------| +|{$TSP.AVAIL.DEADLINE}|Availability deadline in seconds|`900`| +|{$TSP.STATUS.PATH}|path to custom web-page|`http://asterisk/network_check.php`| +|{$TSP.DESCRIPTION.}|trigger operational data info|| + +### Items + +|Name|Description|Type|Key and additional info| +|----|-----------|----|-----------------------| +|Asterisk TSP: Get stats|-|HTTP agent|asterisk.tsp.get_status| + +### Triggers + +There are no triggers in this template. + +### Discovery rules + +|Name|Description|Type|Key and additional info| +|----|-----------|----|-----------------------| +|Discovery Asterisk TSP|-|Dependent item|get.asterisk.tsp.stats| + +### Item prototypes + +|Name|Description|Type|Key and additional info| +|----|-----------|----|-----------------------| +|Asterisk TSP "{#TSP_NAME}" last success check|-|Dependent item|asterisk.tsp.last_check.name[{#TSP_NAME}]| +|Asterisk TSP "{#TSP_NAME}" last success check timestamp|-|Dependent item|asterisk.tsp.last_check.timestamp.name[{#TSP_NAME}]| + +### Trigger prototypes + +|Name|Description|Expression|Severity|Dependencies and additional info| +|----|-----------|----------|--------|--------------------------------| +|Asterisk TSP "{#TSP_NAME}" not available for {$TSP.AVAIL.DEADLINE} seconds|-|last(/Asterisk by HTTP - TSP network check/asterisk.tsp.last_check.name[{#TSP_NAME}],#1)>{$TSP.AVAIL.DEADLINE}|Average|Manual close: No, Operational data: {$TSP.DESCRIPTION.{#TSP_NAME}}| diff --git a/templates/applications/asterisk/6.0/asterisk_by_http-tsp_network_check.yaml b/templates/applications/asterisk/6.0/asterisk_by_http-tsp_network_check.yaml new file mode 100644 index 0000000..b232f3e --- /dev/null +++ b/templates/applications/asterisk/6.0/asterisk_by_http-tsp_network_check.yaml @@ -0,0 +1,122 @@ +zabbix_export: + version: '6.0' + date: '2024-06-27T00:00:00Z' + groups: + - + uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6 + name: Templates/Applications + templates: + - + uuid: ed25bfc3c7e84c8abc484ea208457db3 + template: 'Asterisk by HTTP - TSP network check' + name: 'Asterisk by HTTP - TSP network check' + groups: + - + name: Templates/Applications + items: + - + uuid: cdae5f6801b44131b951c5c75071b8bb + name: 'Asterisk TSP: Get stats' + type: HTTP_AGENT + key: asterisk.tsp.get_status + history: 1h + trends: '0' + value_type: TEXT + description: 'Converted Asterisk TSP status to JSON' + preprocessing: + - + type: JAVASCRIPT + parameters: + - 'return value.toUpperCase()' + url: '{$TSP.STATUS.PATH}' + tags: + - + tag: Application + value: Asterisk + - + tag: component + value: raw + discovery_rules: + - + uuid: 3925e2ee2f414dfb8f5ef35a986a14f2 + name: 'Discovery Asterisk TSP' + type: DEPENDENT + key: get.asterisk.tsp.stats + delay: '0' + item_prototypes: + - + uuid: e32065344b6042d9ac49a04daa15def1 + name: 'Asterisk TSP "{#TSP_NAME}" last success check' + type: DEPENDENT + key: 'asterisk.tsp.last_check.name[{#TSP_NAME}]' + delay: '0' + preprocessing: + - + type: JAVASCRIPT + parameters: + - 'return Math.trunc( (Date.now() - Date.parse(new Date(Date.parse(value)))) / 1000 + 10800 )' + master_item: + key: 'asterisk.tsp.last_check.timestamp.name[{#TSP_NAME}]' + tags: + - + tag: Application + value: Asterisk + - + tag: TSP + value: '{#TSP_NAME}' + trigger_prototypes: + - + uuid: ba610e0de2cd47229376252c90cda88f + expression: 'last(/Asterisk by HTTP - TSP network check/asterisk.tsp.last_check.name[{#TSP_NAME}],#1)>{$TSP.AVAIL.DEADLINE}' + name: 'Asterisk TSP "{#TSP_NAME}" not available for {$TSP.AVAIL.DEADLINE} seconds' + opdata: '{$TSP.DESCRIPTION.{#TSP_NAME}}' + priority: AVERAGE + - + uuid: 86667b8e0f68470eadd229d86a79362a + name: 'Asterisk TSP "{#TSP_NAME}" last success check timestamp' + type: DEPENDENT + key: 'asterisk.tsp.last_check.timestamp.name[{#TSP_NAME}]' + delay: '0' + trends: '0' + value_type: TEXT + preprocessing: + - + type: JSONPATH + parameters: + - '$.PROVIDERS.[?(@.NAME=="{#TSP_NAME}")].LAST_CHECK.first()' + master_item: + key: asterisk.tsp.get_status + tags: + - + tag: Application + value: Asterisk + - + tag: TSP + value: '{#TSP_NAME}' + master_item: + key: asterisk.tsp.get_status + lld_macro_paths: + - + lld_macro: '{#TSP_LAST_CHECK}' + path: $..LAST_CHECK.first() + - + lld_macro: '{#TSP_NAME}' + path: $..NAME.first() + preprocessing: + - + type: STR_REPLACE + parameters: + - PROVIDERS + - data + tags: + - + tag: Application + value: Asterisk + macros: + - + macro: '{$TSP.AVAIL.DEADLINE}' + value: '900' + description: 'Availability deadline in seconds' + - + macro: '{$TSP.STATUS.PATH}' + value: 'http://asterisk/network_check.php'