From 88b907f589f2195785e49bcf6973d45920b4aeae Mon Sep 17 00:00:00 2001 From: PavelZ Date: Tue, 31 Dec 2024 01:39:10 +0300 Subject: [PATCH] Update LVM cache template. Add scripts. Fix import issues. --- .../Linux/template_lvm_cache/6.0/README.md | 3 +- .../template_lvm_cache/6.0/scripts/lvmcache | 36 ++ .../6.0/sudoers.d/sudoers_zabbix_lvmcache | 2 + .../6.0/template_lvm_cache.yaml | 78 ++-- .../6.0/zabbix_agentd.d/lvmcache.conf | 1 + .../Linux/template_lvm_cache/7.0/README.md | 86 +++++ .../template_lvm_cache/7.0/scripts/lvmcache | 36 ++ .../7.0/sudoers.d/sudoers_zabbix_lvmcache | 2 + .../7.0/template_lvm_cache.yaml | 338 ++++++++++++++++++ .../7.0/zabbix_agentd.d/lvmcache.conf | 1 + 10 files changed, 547 insertions(+), 36 deletions(-) create mode 100755 Operating_Systems/Linux/template_lvm_cache/6.0/scripts/lvmcache create mode 100644 Operating_Systems/Linux/template_lvm_cache/6.0/sudoers.d/sudoers_zabbix_lvmcache create mode 100644 Operating_Systems/Linux/template_lvm_cache/6.0/zabbix_agentd.d/lvmcache.conf create mode 100644 Operating_Systems/Linux/template_lvm_cache/7.0/README.md create mode 100755 Operating_Systems/Linux/template_lvm_cache/7.0/scripts/lvmcache create mode 100644 Operating_Systems/Linux/template_lvm_cache/7.0/sudoers.d/sudoers_zabbix_lvmcache create mode 100644 Operating_Systems/Linux/template_lvm_cache/7.0/template_lvm_cache.yaml create mode 100644 Operating_Systems/Linux/template_lvm_cache/7.0/zabbix_agentd.d/lvmcache.conf diff --git a/Operating_Systems/Linux/template_lvm_cache/6.0/README.md b/Operating_Systems/Linux/template_lvm_cache/6.0/README.md index 601e3fe7d..131b7611b 100644 --- a/Operating_Systems/Linux/template_lvm_cache/6.0/README.md +++ b/Operating_Systems/Linux/template_lvm_cache/6.0/README.md @@ -10,7 +10,7 @@ LVM Cache monitoring template. ============================== - allows you to evaluate the efficiency of caching by the built-in dm-cache mechanism. + Allows you to evaluate the efficiency of caching by the built-in dm-cache mechanism. **What do these values mean?** @@ -74,6 +74,7 @@ There are no discovery rules in this template. |total_metadata_blocks|

-

|`Dependent item`|lvmcache.total_metadata_blocks

Update: 0

| |total_cache_blocks|

-

|`Dependent item`|lvmcache.total_cache_blocks

Update: 0

| |read_hits|

-

|`Dependent item`|lvmcache.read_hits

Update: 0

| +|read_misses|

-

|`Dependent item`|lvmcache.read_misses

Update: 0

| |promotions|

-

|`Dependent item`|lvmcache.promotions

Update: 0

| |lvm raw data|

-

|`Zabbix agent`|lvmcache.raw

Update: 3m

| |write_hits|

-

|`Dependent item`|lvmcache.write_hits

Update: 0

| diff --git a/Operating_Systems/Linux/template_lvm_cache/6.0/scripts/lvmcache b/Operating_Systems/Linux/template_lvm_cache/6.0/scripts/lvmcache new file mode 100755 index 000000000..3201f6401 --- /dev/null +++ b/Operating_Systems/Linux/template_lvm_cache/6.0/scripts/lvmcache @@ -0,0 +1,36 @@ +#!/bin/bash + +DMSTRING=$(sudo /usr/sbin/dmsetup status |grep -P -- '\d+\W+cache\W+\d+' | head -1) +# example: +# 11617255424 cache 8 3005/12288 1984 998185/998185 227992434 36220107 294608588 12215083 0 0 861691 3 metadata2 writethrough no_discard_passdown 2 migration_threshold 2048 cleaner 0 rw - + +IFS=' ' read -a POS <<< "${DMSTRING}" +metadata_blocksize="${POS[4]}" +used_metadata_blocks="${POS[5]%%/*}" +total_metadata_blocks="${POS[5]##*/}" +cache_block_size="${POS[6]}" +used_cache_blocks="${POS[7]%%/*}" +total_cache_blocks="${POS[7]##*/}" +read_hits="${POS[8]}" +read_misses="${POS[9]}" +write_hits="${POS[10]}" +write_misses="${POS[11]}" +demotions="${POS[12]}" +promotions="${POS[13]}" +dirty="${POS[14]}" + + + +echo "{ +\"used_metadata_blocks\": $used_metadata_blocks, +\"total_metadata_blocks\": $total_metadata_blocks, +\"used_cache_blocks\": $used_cache_blocks, +\"total_cache_blocks\": $total_cache_blocks, +\"read_hits\": $read_hits, +\"read_misses\": $read_misses, +\"write_hits\": $write_hits, +\"write_misses\": $write_misses, +\"demotions\": $demotions, +\"promotions\": $promotions, +\"dirty\": $dirty +}" diff --git a/Operating_Systems/Linux/template_lvm_cache/6.0/sudoers.d/sudoers_zabbix_lvmcache b/Operating_Systems/Linux/template_lvm_cache/6.0/sudoers.d/sudoers_zabbix_lvmcache new file mode 100644 index 000000000..2656b9915 --- /dev/null +++ b/Operating_Systems/Linux/template_lvm_cache/6.0/sudoers.d/sudoers_zabbix_lvmcache @@ -0,0 +1,2 @@ +Defaults:zabbix !requiretty +zabbix ALL= (ALL) NOPASSWD: /usr/sbin/dmsetup status diff --git a/Operating_Systems/Linux/template_lvm_cache/6.0/template_lvm_cache.yaml b/Operating_Systems/Linux/template_lvm_cache/6.0/template_lvm_cache.yaml index ccab0c309..66c80291a 100644 --- a/Operating_Systems/Linux/template_lvm_cache/6.0/template_lvm_cache.yaml +++ b/Operating_Systems/Linux/template_lvm_cache/6.0/template_lvm_cache.yaml @@ -1,10 +1,9 @@ zabbix_export: version: '6.0' - date: '2021-11-21T22:04:12Z' + date: '2024-12-30T00:04:12Z' groups: - - - uuid: b1a65eeba3cc4c9fb198e8f18f433839 - name: 'Templates/Operating Systems' + - uuid: 846977d1dfed4968bc5f8bdb363285bc + name: 'Templates/Operating systems' templates: - uuid: a81a5e460d8e420baab75a080d5f2375 @@ -12,57 +11,57 @@ zabbix_export: name: 'LVM Cache' description: | ## Description - + LVM cache monitoring Details in kernel documentation https://www.kernel.org/doc/Documentation/device-mapper/cache.txt - + ## Overview - + LVM Cache monitoring template. ============================== - - + + allows you to evaluate the efficiency of caching by the built-in dm-cache mechanism. - - + + **What do these values mean?** ------------------------------ - - + + Details about monitored values described in Linux Kernel Documentation - - + + **Usage** --------- - - + + 1. Put file lvmcache.conf to /etc/zabbix/zabbix\_agent.d/ 2. Put file sudoers\_lvmcache to /etc/sudoers.d/ (you need `sudo` program installed) 3. Put file vmcache to /etc/zabbix/scripts/. Then you can execut this file and test. This script produces JSON output. 4. Import the [`lvmcache_template.xml`](https://github.com/pavlozt/somezabbixtemplates/blob/master/lvmcache/lvmcache_template.xml) into your Zabbix server (click on the `Raw` button to download) 5. Add the template to your host 6. Check if new data arrives at Last Data section and Graphs. - - + + This script assumes that you have **ONLY ONE caching device** and polls the first device. Therefore, it does not require configuration and specifying a device name. Working with disks implies elevated privileges and therefore you need do not forget about sudoers\_zabbix\_lvmcache file. - - + + **Commands for debugging** -------------------------- - - + + * dmsetup status * /etc/zabbix/scripts/lvmcache * zabbix\_get -s 192.168.1.1 -k 'lvmcache.raw' (on zabbix server or zabbix proxy) - - + + ## Author - + pavlozt - - + + groups: - - name: 'Templates/Operating Systems' + name: 'Templates/Operating systems' items: - uuid: 6245993545644076a677d67342856d8e @@ -174,12 +173,21 @@ zabbix_export: - '' master_item: key: lvmcache.raw - tags: - - - tag: Application - value: 'LVM Cache' - - - uuid: 7f3f12b6642a4afdb91b10ed522144f2 + - uuid: a381ae2385e74dafba594395bef7e898 + name: read_misses + type: DEPENDENT + key: lvmcache.read_misses + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.read_misses + - type: SIMPLE_CHANGE + parameters: + - '' + master_item: + key: lvmcache.raw + - uuid: 7f3f12b6642a4afdb91b10ed522144f2 name: total_cache_blocks type: DEPENDENT key: lvmcache.total_cache_blocks diff --git a/Operating_Systems/Linux/template_lvm_cache/6.0/zabbix_agentd.d/lvmcache.conf b/Operating_Systems/Linux/template_lvm_cache/6.0/zabbix_agentd.d/lvmcache.conf new file mode 100644 index 000000000..131f7d80d --- /dev/null +++ b/Operating_Systems/Linux/template_lvm_cache/6.0/zabbix_agentd.d/lvmcache.conf @@ -0,0 +1 @@ +UserParameter=lvmcache.raw,/etc/zabbix/scripts/lvmcache \ No newline at end of file diff --git a/Operating_Systems/Linux/template_lvm_cache/7.0/README.md b/Operating_Systems/Linux/template_lvm_cache/7.0/README.md new file mode 100644 index 000000000..131b7611b --- /dev/null +++ b/Operating_Systems/Linux/template_lvm_cache/7.0/README.md @@ -0,0 +1,86 @@ +# LVM Cache + +## Description + +LVM cache monitoring Details in kernel documentation https://www.kernel.org/doc/Documentation/device-mapper/cache.txt + +## Overview + +LVM Cache monitoring template. +============================== + + + Allows you to evaluate the efficiency of caching by the built-in dm-cache mechanism. + + +**What do these values mean?** +------------------------------ + + +Details about monitored values described in Linux Kernel Documentation + + +**Usage** +--------- + + +1. Put file lvmcache.conf to /etc/zabbix/zabbix\_agent.d/ +2. Put file sudoers\_lvmcache to /etc/sudoers.d/ (you need `sudo` program installed) +3. Put file vmcache to /etc/zabbix/scripts/. Then you can execut this file and test. This script produces JSON output. +4. Import the [`lvmcache_template.xml`](https://github.com/pavlozt/somezabbixtemplates/blob/master/lvmcache/lvmcache_template.xml) into your Zabbix server (click on the `Raw` button to download) +5. Add the template to your host +6. Check if new data arrives at Last Data section and Graphs. + + +This script assumes that you have **ONLY ONE caching device** and polls the first device. Therefore, it does not require configuration and specifying a device name. Working with disks implies elevated privileges and therefore you need do not forget about sudoers\_zabbix\_lvmcache file. + + +**Commands for debugging** +-------------------------- + + +* dmsetup status +* /etc/zabbix/scripts/lvmcache +* zabbix\_get -s 192.168.1.1 -k 'lvmcache.raw' (on zabbix server or zabbix proxy) + + +## Author + +pavlozt + +## Macros used + +There are no macros links in this template. + +## Template links + +There are no template links in this template. + +## Discovery rules + +There are no discovery rules in this template. + +## Items collected + +|Name|Description|Type|Key and additional info| +|----|-----------|----|----| +|demotions|

-

|`Dependent item`|lvmcache.demotions

Update: 0

| +|used_metadata_blocks|

-

|`Dependent item`|lvmcache.used_metadata_blocks

Update: 0

| +|write_misses|

-

|`Dependent item`|lvmcache.write_misses

Update: 0

| +|dirty|

-

|`Dependent item`|lvmcache.dirty

Update: 0

| +|LVM data cache usage|

-

|`Calculated`|lvmcache.usage

Update: 3m

| +|LVM meta cache usage|

-

|`Calculated`|lvmcache.metausage

Update: 3m

| +|used_cache_blocks|

-

|`Dependent item`|lvmcache.used_cache_blocks

Update: 0

| +|total_metadata_blocks|

-

|`Dependent item`|lvmcache.total_metadata_blocks

Update: 0

| +|total_cache_blocks|

-

|`Dependent item`|lvmcache.total_cache_blocks

Update: 0

| +|read_hits|

-

|`Dependent item`|lvmcache.read_hits

Update: 0

| +|read_misses|

-

|`Dependent item`|lvmcache.read_misses

Update: 0

| +|promotions|

-

|`Dependent item`|lvmcache.promotions

Update: 0

| +|lvm raw data|

-

|`Zabbix agent`|lvmcache.raw

Update: 3m

| +|write_hits|

-

|`Dependent item`|lvmcache.write_hits

Update: 0

| + + +## Triggers + +There are no triggers in this template. + diff --git a/Operating_Systems/Linux/template_lvm_cache/7.0/scripts/lvmcache b/Operating_Systems/Linux/template_lvm_cache/7.0/scripts/lvmcache new file mode 100755 index 000000000..3201f6401 --- /dev/null +++ b/Operating_Systems/Linux/template_lvm_cache/7.0/scripts/lvmcache @@ -0,0 +1,36 @@ +#!/bin/bash + +DMSTRING=$(sudo /usr/sbin/dmsetup status |grep -P -- '\d+\W+cache\W+\d+' | head -1) +# example: +# 11617255424 cache 8 3005/12288 1984 998185/998185 227992434 36220107 294608588 12215083 0 0 861691 3 metadata2 writethrough no_discard_passdown 2 migration_threshold 2048 cleaner 0 rw - + +IFS=' ' read -a POS <<< "${DMSTRING}" +metadata_blocksize="${POS[4]}" +used_metadata_blocks="${POS[5]%%/*}" +total_metadata_blocks="${POS[5]##*/}" +cache_block_size="${POS[6]}" +used_cache_blocks="${POS[7]%%/*}" +total_cache_blocks="${POS[7]##*/}" +read_hits="${POS[8]}" +read_misses="${POS[9]}" +write_hits="${POS[10]}" +write_misses="${POS[11]}" +demotions="${POS[12]}" +promotions="${POS[13]}" +dirty="${POS[14]}" + + + +echo "{ +\"used_metadata_blocks\": $used_metadata_blocks, +\"total_metadata_blocks\": $total_metadata_blocks, +\"used_cache_blocks\": $used_cache_blocks, +\"total_cache_blocks\": $total_cache_blocks, +\"read_hits\": $read_hits, +\"read_misses\": $read_misses, +\"write_hits\": $write_hits, +\"write_misses\": $write_misses, +\"demotions\": $demotions, +\"promotions\": $promotions, +\"dirty\": $dirty +}" diff --git a/Operating_Systems/Linux/template_lvm_cache/7.0/sudoers.d/sudoers_zabbix_lvmcache b/Operating_Systems/Linux/template_lvm_cache/7.0/sudoers.d/sudoers_zabbix_lvmcache new file mode 100644 index 000000000..2656b9915 --- /dev/null +++ b/Operating_Systems/Linux/template_lvm_cache/7.0/sudoers.d/sudoers_zabbix_lvmcache @@ -0,0 +1,2 @@ +Defaults:zabbix !requiretty +zabbix ALL= (ALL) NOPASSWD: /usr/sbin/dmsetup status diff --git a/Operating_Systems/Linux/template_lvm_cache/7.0/template_lvm_cache.yaml b/Operating_Systems/Linux/template_lvm_cache/7.0/template_lvm_cache.yaml new file mode 100644 index 000000000..17a911652 --- /dev/null +++ b/Operating_Systems/Linux/template_lvm_cache/7.0/template_lvm_cache.yaml @@ -0,0 +1,338 @@ +zabbix_export: + version: '7.0' + template_groups: + - uuid: 846977d1dfed4968bc5f8bdb363285bc + name: 'Templates/Operating systems' + templates: + - uuid: a81a5e460d8e420baab75a080d5f2375 + template: 'LVM Cache' + name: 'LVM Cache' + description: | + ## Description + + LVM cache monitoring Details in kernel documentation https://www.kernel.org/doc/Documentation/device-mapper/cache.txt + + ## Overview + + LVM Cache monitoring template. + ============================== + + + allows you to evaluate the efficiency of caching by the built-in dm-cache mechanism. + + + **What do these values mean?** + ------------------------------ + + + Details about monitored values described in Linux Kernel Documentation + + + **Usage** + --------- + + + 1. Put file lvmcache.conf to /etc/zabbix/zabbix\_agent.d/ + 2. Put file sudoers\_lvmcache to /etc/sudoers.d/ (you need `sudo` program installed) + 3. Put file vmcache to /etc/zabbix/scripts/. Then you can execut this file and test. This script produces JSON output. + 4. Import the [`lvmcache_template.xml`](https://github.com/pavlozt/somezabbixtemplates/blob/master/lvmcache/lvmcache_template.xml) into your Zabbix server (click on the `Raw` button to download) + 5. Add the template to your host + 6. Check if new data arrives at Last Data section and Graphs. + + + This script assumes that you have **ONLY ONE caching device** and polls the first device. Therefore, it does not require configuration and specifying a device name. Working with disks implies elevated privileges and therefore you need do not forget about sudoers\_zabbix\_lvmcache file. + + + **Commands for debugging** + -------------------------- + + + * dmsetup status + * /etc/zabbix/scripts/lvmcache + * zabbix\_get -s 192.168.1.1 -k 'lvmcache.raw' (on zabbix server or zabbix proxy) + + + ## Author + + pavlozt + groups: + - name: 'Templates/Operating systems' + items: + - uuid: 6245993545644076a677d67342856d8e + name: demotions + type: DEPENDENT + key: lvmcache.demotions + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.demotions + - type: SIMPLE_CHANGE + parameters: + - '' + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: c4fc7c3dd5f7484fb1c39dffed61ce57 + name: dirty + type: DEPENDENT + key: lvmcache.dirty + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.dirty + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 99c56641bbdc4250b6acd19e1189640b + name: 'LVM meta cache usage' + type: CALCULATED + key: lvmcache.metausage + delay: 3m + value_type: FLOAT + params: last(//lvmcache.used_metadata_blocks)/last(//lvmcache.total_metadata_blocks) + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 4a297395cc364b35b97c9047a992be22 + name: promotions + type: DEPENDENT + key: lvmcache.promotions + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.promotions + - type: SIMPLE_CHANGE + parameters: + - '' + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 2d4c600613d24cac838f6e514dc4c434 + name: 'lvm raw data' + key: lvmcache.raw + delay: 3m + value_type: TEXT + trends: '0' + preprocessing: + - type: CHECK_JSON_ERROR + parameters: + - $.values + tags: + - tag: component + value: raw + - tag: target + value: lvm + - uuid: 9cd1a4801c8c4d29a954ab9f1ad061ea + name: read_hits + type: DEPENDENT + key: lvmcache.read_hits + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.read_hits + - type: SIMPLE_CHANGE + parameters: + - '' + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: a381ae2385e74dafba594395bef7e898 + name: read_misses + type: DEPENDENT + key: lvmcache.read_misses + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.read_misses + - type: SIMPLE_CHANGE + parameters: + - '' + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 7f3f12b6642a4afdb91b10ed522144f2 + name: total_cache_blocks + type: DEPENDENT + key: lvmcache.total_cache_blocks + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.total_cache_blocks + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 9f427a2388e24f9ba510d28160db20b5 + name: total_metadata_blocks + type: DEPENDENT + key: lvmcache.total_metadata_blocks + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.total_metadata_blocks + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 18e54b4030194ce9a69d28204d403fc0 + name: 'LVM data cache usage' + type: CALCULATED + key: lvmcache.usage + delay: 3m + value_type: FLOAT + params: last(//lvmcache.used_cache_blocks)/last(//lvmcache.total_cache_blocks) + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 7589e8fc80734474ab47b53ebfc1ce37 + name: used_cache_blocks + type: DEPENDENT + key: lvmcache.used_cache_blocks + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.used_cache_blocks + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 5ab792a5426349d3b0da44850f78d11b + name: used_metadata_blocks + type: DEPENDENT + key: lvmcache.used_metadata_blocks + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.used_metadata_blocks + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 122659ef11314ff1bfb6ef6b8c5151ac + name: write_hits + type: DEPENDENT + key: lvmcache.write_hits + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.write_hits + - type: SIMPLE_CHANGE + parameters: + - '' + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + - uuid: 8b38f882decb4f79ac009aeac611c005 + name: write_misses + type: DEPENDENT + key: lvmcache.write_misses + delay: '0' + preprocessing: + - type: JSONPATH + parameters: + - $.write_misses + - type: SIMPLE_CHANGE + parameters: + - '' + master_item: + key: lvmcache.raw + tags: + - tag: component + value: storage + - tag: target + value: lvm + tags: + - tag: class + value: storage + - tag: target + value: linux + - tag: target + value: lvm + graphs: + - uuid: 4a22b6726cc840a28208481b598e34ad + name: 'LVM Cache efficiency' + graph_items: + - color: 1A7C11 + item: + host: 'LVM Cache' + key: lvmcache.read_hits + - sortorder: '1' + color: F63100 + item: + host: 'LVM Cache' + key: lvmcache.write_hits + - sortorder: '2' + color: 2774A4 + item: + host: 'LVM Cache' + key: lvmcache.write_misses + - sortorder: '3' + color: '274482' + calc_fnc: ALL + item: + host: 'LVM Cache' + key: lvmcache.read_misses + - uuid: e5ed1f0742444dbc92e22b394dbd4aa0 + name: 'LVM Cache usage' + show_work_period: 'NO' + show_triggers: 'NO' + graph_items: + - color: F63100 + item: + host: 'LVM Cache' + key: lvmcache.usage + - sortorder: '1' + color: 2774A4 + item: + host: 'LVM Cache' + key: lvmcache.metausage diff --git a/Operating_Systems/Linux/template_lvm_cache/7.0/zabbix_agentd.d/lvmcache.conf b/Operating_Systems/Linux/template_lvm_cache/7.0/zabbix_agentd.d/lvmcache.conf new file mode 100644 index 000000000..131f7d80d --- /dev/null +++ b/Operating_Systems/Linux/template_lvm_cache/7.0/zabbix_agentd.d/lvmcache.conf @@ -0,0 +1 @@ +UserParameter=lvmcache.raw,/etc/zabbix/scripts/lvmcache \ No newline at end of file