diff --git a/check_memory b/check_memory index ffd36321b76fdb979d80841e4fe490c171b0503b..f231a643077002831cb25aa2bc357780025cf189 100755 --- a/check_memory +++ b/check_memory @@ -25,13 +25,13 @@ # 2022-03-09 v1.6 <axel.hahn@iml.unibe.ch> show most ram intensive processes # 2022-03-10 v1.7 <axel.hahn@iml.unibe.ch> add cli param -p; update help # 2023-02-13 v1.8 <axel.hahn@unibe.ch> shell fixes +# 2023-07-28 v1.9 <axel.hahn@unibe.ch> update help page # ====================================================================== . "$(dirname $0)/inc_pluginfunctions" -self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.8 +self_APPVERSION=1.9 # ---------------------------------------------------------------------- # FUNCTIONS @@ -44,21 +44,18 @@ function getMemvalue(){ echo $( grep "^$1:" /proc/meminfo | awk '{ print $2 }' ) / 1024 | bc } +# show help text function showHelp(){ + local _self; _self=$(basename $0) cat <<EOF -______________________________________________________________________ - -$self_APPNAME -v$self_APPVERSION - -(c) Institute for Medical Education - University of Bern -Licence: GNU GPL 3 -______________________________________________________________________ +$( ph.showImlHelpHeader ) Check memory usage incl. free, used and total memory. On higher memory usage the process table with top 5 top consumers will be shown. +This plugin sends performancedata. + SYNTAX: $(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-s SWAP_LIMIT] [-p PROCESS_LIMIT] [-h] diff --git a/check_mysqlserver b/check_mysqlserver index a4217bbdd3f65c206f9a8613e9a46c0dd6c92c9b..bb9ac837d053b62e178b0628ec917af244d5c832 100755 --- a/check_mysqlserver +++ b/check_mysqlserver @@ -19,13 +19,12 @@ # 2021-06-08 v0.1 <axel.hahn@iml.unibe.ch> update HOME .. better implement a param and ENV var # 2021-06-24 v0.2 <axel.hahn@iml.unibe.ch> check if query cache is enabled as a shared function # 2023-06-06 v0.3 <axel.hahn@unibe.ch> some shell fixes +# 2023-07-28 v1.0 <axel.hahn@unibe.ch> update help page; fix [client]: command not found # ====================================================================== - . $( dirname $0 )/inc_pluginfunctions -self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=0.3 +export self_APPVERSION=1.0 # --- set HOME HOME=/etc/icingaclient @@ -33,7 +32,7 @@ HOME=/etc/icingaclient # --- other vars... cfgfile=$HOME/.my.cnf myuser=icingamonitor -datafile=/tmp/mysqlvars.out +datafile=/tmp/mysqlvars_$USER.out # new line NL=" @@ -100,17 +99,11 @@ EOF fi } -# show usage -function _usage(){ - local _self=$( basename $0 ) - cat <<EOH -______________________________________________________________________ - -${self_APPNAME} :: v${self_APPVERSION} - -(c) Institute for Medical Education - University of Bern -Licence: GNU GPL 3 -______________________________________________________________________ +# show help text +function showHelp(){ + local _self; _self=$(basename $0) +cat <<EOF +$( ph.showImlHelpHeader ) USAGE: $_self [OPTIONS] -m METHOD @@ -133,7 +126,7 @@ EXAMPLES: $_self -i $_self -m commands -EOH +EOF } function _mysqlreadvars(){ @@ -206,7 +199,7 @@ bOptUninstall=$( ph.hasParamoption "u" "$@") bOptHelp=$( ph.hasParamoption "h" "$@") if [ $bOptHelp -eq 1 -o $# -lt 1 ]; then - _usage + showHelp exit 0 fi @@ -245,7 +238,6 @@ fi if ! grep $myuser $cfgfile >/dev/null 2>&1; then ph.abort "MYSQL access not possible yet. You need to install the monitoring user first: as root execute $(basename $0) -i" fi -. "${cfgfile}" # ---------------------------------------------------------------------- @@ -328,7 +320,7 @@ case "${sMode}" in *) echo ERRROR: [${sMode}] is an INVALID mode - _usage + showHelp ph.abort esac diff --git a/docs/20_Checks/_index.md b/docs/20_Checks/_index.md index 4aed7e2eaa290e5c7348eb4f149a56a6865a9bdb..547b3ac5fee81bf473db066fc0f7d85719e941aa 100644 --- a/docs/20_Checks/_index.md +++ b/docs/20_Checks/_index.md @@ -24,8 +24,8 @@ There is one include script used by all checks: * [check_fs_writable](check_fs_writable.md) * [check_haproxy_health](check_haproxy_health.md) * [check_haproxy_status](check_haproxy_status.md) -* check_memory -* check_mysqlserver +* [check_memory](check_memory.md) +* [check_mysqlserver](check_mysqlserver.md) * check_netio * [check_netstat](check_netstat.md) * [check_onehost](check_onehost.md) diff --git a/docs/20_Checks/check_memory.md b/docs/20_Checks/check_memory.md new file mode 100644 index 0000000000000000000000000000000000000000..c0fbc952f7d2af1a022e3e9169e483f9e5375113 --- /dev/null +++ b/docs/20_Checks/check_memory.md @@ -0,0 +1,86 @@ +# Check Memory (RAM) + +## Introduction + +**check_memory** Check memory usage incl. free, used and total memory. + +It reads /proc/meminfo and fetches the needed values. + +* MemTotal: Total usable ram (i.e. physical ram minus a few reserved bits and the kernel binary code) +* MemFree: Is sum of LowFree+HighFree (overall stat) +* MemAvailable: delta of total - free +* Buffers: Memory in buffer cache. mostly useless as metric nowadays Relatively temporary storage for raw disk blocks shouldn’t get tremendously large +* Cached: Memory in the pagecache (diskcache) minus SwapCache, Doesn’t include SwapCached +* SwapCached: Memory that once was swapped out, is swapped back in but still also is in the swapfile (if memory is needed it doesn’t need to be swapped out AGAIN because it is already in the swapfile. This saves I/O ) +* SwapTotal: Total amount of physical swap memory. +* SwapFree: Total amount of swap memory free. Memory which has been evicted from RAM, and is temporarily on the disk +* Slab: in-kernel data structures cache +* SReclaimable: reclaimable parts of Slab, e.g., caches + +This plugin sends all values as performance data. + +### Requirements + +* bc + +## Syntax + +```txt +______________________________________________________________________ + +CHECK_MEMORY +v1.9 + +(c) Institute for Medical Education - University of Bern +Licence: GNU GPL 3 + +https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_memory.html +______________________________________________________________________ + +Check memory usage incl. free, used and total memory. +On higher memory usage the process table with top 5 top consumers will +be shown. + +This plugin sends performancedata. + +SYNTAX: +check_memory [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-s SWAP_LIMIT] [-p PROCESS_LIMIT] [-h] + +OPTIONS: + -w VALUE Warning level for RAM usage [%]; default: 75 + -c VALUE Critical level for RAM usage; default: 90 + + -s VALUE Critical level for SWAP usage; default: 50 + -p VALUE show process info with highest memory consumption if + usage is > NN %; default: 50 + + -h or --help show this help. + +PARAMETERS: + + none + +EXAMPLE: +check_memory -w 90 -c 95 -p 70 + +``` + +## Examples + +`$ check_memory -w 90 -c 95 -p 70` returns + +```txt +OK: RAM usage 46 % of 7955 MB (machine has no Swap) + +MemTotal: 8146916 kB +MemFree: 901724 kB +MemAvailable: 4328748 kB +Buffers: 117988 kB +Cached: 3045292 kB +SwapCached: 0 kB +SwapTotal: 0 kB +SwapFree: 0 kB +Slab: 682424 kB +SReclaimable: 591596 kB + |memory-total=7955MB;;;0;7955 memory-used=3729MB;;;0;7955 memory-avail=4226MB;;;0;7955 memory-free=880MB;;;0;7955 memory-buffers=115MB;;;0;7955 memory-cached=2973MB;;;0;7955 memory-sreclaim=577MB;;;0;7955 +``` diff --git a/docs/20_Checks/check_mysqlserver.md b/docs/20_Checks/check_mysqlserver.md new file mode 100644 index 0000000000000000000000000000000000000000..85fca2b975c63ce2ea28c6510baff4a02801df18 --- /dev/null +++ b/docs/20_Checks/check_mysqlserver.md @@ -0,0 +1,164 @@ +# check Mysql / mariadb server + +## Introduction + +**check_mysqlserver** is a plugin execute different checks on a mysql server instance. +The kind of check is defined by a parameter `-m METHOD`. + +## Requirements + +* mysql (cli tool) +* The icinga user needs to connect to the database server (see Installation). + +## Syntax + +`$ check_mysqlserver [-i|-u|-m METHOD]` + +```txt +______________________________________________________________________ + +CHECK_MYSQLSERVER +v1.0 + +(c) Institute for Medical Education - University of Bern +Licence: GNU GPL 3 + +https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_mysqlserver.html +______________________________________________________________________ + +USAGE: + check_mysqlserver [OPTIONS] -m METHOD + +OPTIONS: + -h this help + -i install monitoring user (must be executed as root) + -u uninstall monitoring user (must be executed as root) + +PARAMETERS: + -m method; valid methods are: + connections current/ max connections + connects connects per min and aborted connections/ clients + commands current running statements insert, select, ... + qcache-blocks query cache blocks total vs free + qcache-queries cached / non cached queries; low memeory prunes + qcache-hits query cache efficiency: cached vs non cached and inserted + +EXAMPLES: + check_mysqlserver -i + check_mysqlserver -m commands + +``` + +## Installation + +To give access to the database there is the param `-i`(for "install"). +This command needs to be run as root. + +```txt +./check_mysqlserver -i +``` + +This creates a database user "icingamonitor" with a 64 byte random password. +To store the credentials a file file be created: `/etc/icingaclient/.my.cnf`. It is the known mysql password file. The mysql check plugin sets $HOME to /etc/icingaclient and this config will be found automatically. + +```txt +cat /etc/icingaclient/.my.cnf +# +# generated on Tue Jun 8 10:01:31 CEST 2021 +# +[client] +user=icingamonitor +host=localhost +password=qrYEiPG33qNoedO4oWNrmtDOtEmQ9tw8pYEYcPbuYphUweemJEOC4fzZXIWJFvZ5 +``` + +To test the connection run `./check_mysqlserver -m connections`. + +## Checks + +### connections + +current/ max connections + +```txt +./check_mysqlserver -m connections +OK: Mysql connections :: current/ max connections + max_connections: 151 + Max_used_connections: 11 + --> 7 % + + Threads_connected: 3 + --> 1 % + + Questions: 1 + + |maxconnections=151;; maxusedconnections=11;; threadsconnected=3;; questions=1;; +``` + +### connects + +connects per min and aborted connections/ clients + +```txt +./check_mysqlserver -m connects +OK: Mysql connects :: connects per min and aborted connections/ clients + Connections: 956785 ... delta = per min + Aborted_clients: 19 ... delta = per min + Aborted_connects: 1 ... delta = per min + + |connections=0;; abortedclients=0;; abortedconnects=0;; +``` + +### commands + +current running statements insert, select, ... + +```txt +./check_mysqlserver -m commands +OK: Mysql commands :: currently executed commands + delete: 0 + insert: 0 + replace: 0 + select: 0 + update: 0 + + |delete=0;; insert=0;; replace=0;; select=0;; update=0;; +``` + +### qcache-blocks + +query cache blocks total vs free + +```txt +./check_mysqlserver -m qcache-blocks +INFO: Query cache (have_query_cache) is active but query_cache_type is OFF. +``` + +### qcache-queries + +cached / non cached queries; low memeory prunes + +```txt +./check_mysqlserver -m qcache-queries +INFO: Query cache (have_query_cache) is active but query_cache_type is OFF. +``` + +### qcache-hits + +query cache efficiency: cached vs non cached and inserted + +```txt +./check_mysqlserver -m qcache-hits +INFO: Query cache (have_query_cache) is active but query_cache_type is OFF. +``` + + +## Uninstall + +As root run + +```txt +./check_mysqlserver -u +``` + +This drops the database user `icingaclient` and removes the config file `/etc/icingaclient/.my.cnf`.