zabbix_export: version: '5.4' date: '2021-11-21T21:55:33Z' groups: - uuid: 8895384bbc774097bc579e4d02ee6350 name: 'Templates Prod' templates: - uuid: e6def4c1814c49a69c2d950dd72db381 template: 'Service HLS' name: 'Service HLS' description: | ## Overview This is beta version of HLS checker. This template can discovery different streams (playlist in playlists file) and show next parameters: There is presented ts file Total lenght of ts file Target duration of ts file Duration of ts file Spended time for download ts file Average speed for download ts file Not created: different paraneters of ts file from ffprobe. May be later. You need install python2, m3u8 library and ffmpeg if you want: apt install python python-m3u8 python-requests ffmpeg 1. Put script to /path\_to\_script/check\_hls 2. Give him executable flag by: chmod ugo+x check\_hls 3. Add userparameter into zabbix agent: echo "UserParameter=hls[*], /usr/bin/python /path\_to\_script/check\_hls \$1 \$2" > /etc/zabbix/zabbix\_agentd.d/hls.conf 4. Import template into zabbix server 5. Apply template to host 6. Add macros {$HLSURI} = "http://yourdmain.local/playlist.m3u8" If you have additions or comments you are welcome! ## Author Kirill Savin groups: - name: 'Templates Prod' discovery_rules: - uuid: a875521dc12a40be8122e75dfbaf3ada name: 'm3u8 lists' key: 'hls["-d",{$HLSURI}]' delay: 1h lifetime: 5d item_prototypes: - uuid: 4b6f11b22cf649539c8f970eeba31181 name: 'HLS average speed $1' type: DEPENDENT key: 'hls.averagespeed[{#PROFILE}]' delay: '0' history: 7d trends: 30d units: b preprocessing: - type: JSONPATH parameters: - '$..[''#DOWNLOAD-OPTS'']..[''#AVERAGE-SPEED'']' - type: JAVASCRIPT parameters: - 'return(value.slice(0,-1).slice(1))' master_item: key: 'hls["-g",{#PROFILE}]' tags: - tag: Application value: hls - uuid: ede4e392d1664bdd9240b49552c85b99 name: 'HLS duration $1' type: DEPENDENT key: 'hls.duration[{#PROFILE}]' delay: '0' history: 7d trends: 30d value_type: FLOAT units: s preprocessing: - type: JSONPATH parameters: - '$..[''#DURATION'']' - type: JAVASCRIPT parameters: - 'return(value.slice(0,-1).slice(1))' master_item: key: 'hls["-g",{#PROFILE}]' tags: - tag: Application value: hls trigger_prototypes: - uuid: 49ed3d36245f42caba46519c6a1be991 expression: 'last(/Service HLS/hls.duration[{#PROFILE}])<8' name: 'HLS duration is below 8 in {#PROFILE}' priority: WARNING - uuid: ff5103ccbb6e4fd8b8101da7cce77486 name: 'HLS spended time $1' type: DEPENDENT key: 'hls.spendedtime[{#PROFILE}]' delay: '0' history: 7d trends: 30d value_type: FLOAT units: s preprocessing: - type: JSONPATH parameters: - '$..[''#DOWNLOAD-OPTS'']..[''#SPENDED-TIME'']' - type: JAVASCRIPT parameters: - 'return(value.slice(0,-1).slice(1))' master_item: key: 'hls["-g",{#PROFILE}]' tags: - tag: Application value: hls trigger_prototypes: - uuid: 3aaf1ee150734cdfa1ffff45e8ec0c49 expression: 'last(/Service HLS/hls.spendedtime[{#PROFILE}])>200' name: 'HLS spended time is more 200ms in {#PROFILE}' priority: INFO - uuid: 9a742a279c614402abd188a61d2b9750 name: 'HLS target duration $1' type: DEPENDENT key: 'hls.target_duration[{#PROFILE}]' delay: '0' history: 7d trends: 30d value_type: FLOAT units: s preprocessing: - type: JSONPATH parameters: - '$..[''#TARGETDURATION'']' - type: JAVASCRIPT parameters: - 'return(value.slice(0,-1).slice(1))' master_item: key: 'hls["-g",{#PROFILE}]' tags: - tag: Application value: hls - uuid: 843619afbc8745a3baab6f5dc4f96b71 name: 'HLS total legth $1' type: DEPENDENT key: 'hls.totallength[{#PROFILE}]' delay: '0' history: 7d trends: 30d units: b preprocessing: - type: JSONPATH parameters: - '$..[''#DOWNLOAD-OPTS'']..[''#TOTAL-LENGTH'']' - type: JAVASCRIPT parameters: - 'return(value.slice(0,-1).slice(1))' master_item: key: 'hls["-g",{#PROFILE}]' tags: - tag: Application value: hls trigger_prototypes: - uuid: 631e4348837e49b4b7e037260366db25 expression: 'last(/Service HLS/hls.totallength[{#PROFILE}]) < (avg(/Service HLS/hls.totallength[{#PROFILE}],5m) * 0.9)' name: 'HLS there''s unstable bitrate in {#PROFILE}' - uuid: a820f76b992f4f8690149655e0ece189 name: 'HLS ts present $1' type: DEPENDENT key: 'hls.tsuri[{#PROFILE}]' delay: '0' history: 7d trends: 30d preprocessing: - type: JSONPATH parameters: - '$..[''#TSURI'']' - type: JAVASCRIPT parameters: - 'return(value.slice(0,-1).slice(1))' master_item: key: 'hls["-g",{#PROFILE}]' tags: - tag: Application value: hls trigger_prototypes: - uuid: 3f56f3f9cf974f21b4bc0943a7d58929 expression: 'last(/Service HLS/hls.tsuri[{#PROFILE}])=0' name: 'HLS TS isn''t present in {#PROFILE}' priority: HIGH - uuid: 9a6a2a3e978448668d36d3285658a16d name: 'HLS playlist $2' key: 'hls["-g",{#PROFILE}]' delay: 2m history: 7d trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - '$.*' tags: - tag: Application value: hls trigger_prototypes: - uuid: 2da3da066d074c7bbed60ada9ad77a75 expression: | last(/Service HLS/hls.duration[{#PROFILE}]) < last(/Service HLS/hls.target_duration[{#PROFILE}]) or last(/Service HLS/hls.duration[{#PROFILE}]) > last(/Service HLS/hls.target_duration[{#PROFILE}]) name: 'HLS duration is different on target duration in {#PROFILE}' status: DISABLED macros: - macro: '{$HLSURI}' description: 'URI to m3u8'