nagios-nrpe : handle the case where cached_mem is in GB to convert it in MB in check_free_mem.sh
This commit is contained in:
parent
eb96fd41b2
commit
40ed5b0437
|
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- base: fix shell configuration, increase $HISTSIZE, and change history alias so it displays full history
|
- base: fix shell configuration, increase $HISTSIZE, and change history alias so it displays full history
|
||||||
|
- nagios-nrpe : handle the case where cached_mem is in GB to convert it in MB in check_free_mem.sh
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,14 @@ tot_mem=$(( `/sbin/sysctl -n hw.physmem` / BYTES_IN_MB))
|
||||||
{% if ansible_distribution_version is version_compare("6.2",'<') %}
|
{% if ansible_distribution_version is version_compare("6.2",'<') %}
|
||||||
free_mem=$(( `/usr/bin/vmstat | /usr/bin/tail -1 | /usr/bin/awk '{ print $5 }'` / KB_IN_MB ))
|
free_mem=$(( `/usr/bin/vmstat | /usr/bin/tail -1 | /usr/bin/awk '{ print $5 }'` / KB_IN_MB ))
|
||||||
{% else %}
|
{% else %}
|
||||||
free_mem=$(($(/usr/bin/vmstat | /usr/bin/tail -1 | /usr/bin/awk '{ print $4 }' | tr -d 'M') + $(top -n | grep Memory | awk '{print $8}' | tr -d 'M')))
|
if [ "$(top -n | grep Memory | awk '{print $8}' | tr -d 'M')" == "$(top -n | grep Memory | awk '{print $8}' | tr -d 'G')G" ]; then
|
||||||
|
# If cached_mem = XG then cached_mem = X*1024M
|
||||||
|
cached_mem=$(($(top -n | grep Memory | awk '{print $8}' | tr -d 'G') * 1024))
|
||||||
|
else
|
||||||
|
# Else, cached_mem = XM
|
||||||
|
cached_mem=$(top -n | grep Memory | awk '{print $8}' | tr -d 'M')
|
||||||
|
fi
|
||||||
|
free_mem=$(($(/usr/bin/vmstat | /usr/bin/tail -1 | /usr/bin/awk '{ print $4 }' | tr -d 'M') + $cached_mem))
|
||||||
{% endif %}
|
{% endif %}
|
||||||
# Free memory size (in percentage)
|
# Free memory size (in percentage)
|
||||||
free_mem_perc=$(( free_mem * 100 / tot_mem ))
|
free_mem_perc=$(( free_mem * 100 / tot_mem ))
|
||||||
|
|
Loading…
Reference in a new issue