-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update LVM cache template. Add scripts. Fix import issues.
- Loading branch information
Showing
10 changed files
with
547 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Operating_Systems/Linux/template_lvm_cache/6.0/scripts/lvmcache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}" |
2 changes: 2 additions & 0 deletions
2
Operating_Systems/Linux/template_lvm_cache/6.0/sudoers.d/sudoers_zabbix_lvmcache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Defaults:zabbix !requiretty | ||
zabbix ALL= (ALL) NOPASSWD: /usr/sbin/dmsetup status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Operating_Systems/Linux/template_lvm_cache/6.0/zabbix_agentd.d/lvmcache.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
UserParameter=lvmcache.raw,/etc/zabbix/scripts/lvmcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.kernel.org/doc/Documentation/device-mapper/cache.txt> | ||
|
||
|
||
**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|<p>-</p>|`Dependent item`|lvmcache.demotions<p>Update: 0</p>| | ||
|used_metadata_blocks|<p>-</p>|`Dependent item`|lvmcache.used_metadata_blocks<p>Update: 0</p>| | ||
|write_misses|<p>-</p>|`Dependent item`|lvmcache.write_misses<p>Update: 0</p>| | ||
|dirty|<p>-</p>|`Dependent item`|lvmcache.dirty<p>Update: 0</p>| | ||
|LVM data cache usage|<p>-</p>|`Calculated`|lvmcache.usage<p>Update: 3m</p>| | ||
|LVM meta cache usage|<p>-</p>|`Calculated`|lvmcache.metausage<p>Update: 3m</p>| | ||
|used_cache_blocks|<p>-</p>|`Dependent item`|lvmcache.used_cache_blocks<p>Update: 0</p>| | ||
|total_metadata_blocks|<p>-</p>|`Dependent item`|lvmcache.total_metadata_blocks<p>Update: 0</p>| | ||
|total_cache_blocks|<p>-</p>|`Dependent item`|lvmcache.total_cache_blocks<p>Update: 0</p>| | ||
|read_hits|<p>-</p>|`Dependent item`|lvmcache.read_hits<p>Update: 0</p>| | ||
|read_misses|<p>-</p>|`Dependent item`|lvmcache.read_misses<p>Update: 0</p>| | ||
|promotions|<p>-</p>|`Dependent item`|lvmcache.promotions<p>Update: 0</p>| | ||
|lvm raw data|<p>-</p>|`Zabbix agent`|lvmcache.raw<p>Update: 3m</p>| | ||
|write_hits|<p>-</p>|`Dependent item`|lvmcache.write_hits<p>Update: 0</p>| | ||
|
||
|
||
## Triggers | ||
|
||
There are no triggers in this template. | ||
|
36 changes: 36 additions & 0 deletions
36
Operating_Systems/Linux/template_lvm_cache/7.0/scripts/lvmcache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}" |
2 changes: 2 additions & 0 deletions
2
Operating_Systems/Linux/template_lvm_cache/7.0/sudoers.d/sudoers_zabbix_lvmcache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Defaults:zabbix !requiretty | ||
zabbix ALL= (ALL) NOPASSWD: /usr/sbin/dmsetup status |
Oops, something went wrong.