Skip to content
Snippets Groups Projects
Commit 2a962b0e authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '6468-docs-and-harmonize' into 'master'

6468 docs and harmonize

See merge request !130
parents 0bd2e01a de425578
No related branches found
No related tags found
1 merge request!1306468 docs and harmonize
...@@ -25,13 +25,13 @@ ...@@ -25,13 +25,13 @@
# 2022-03-09 v1.6 <axel.hahn@iml.unibe.ch> show most ram intensive processes # 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 # 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-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" . "$(dirname $0)/inc_pluginfunctions"
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) self_APPVERSION=1.9
self_APPVERSION=1.8
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# FUNCTIONS # FUNCTIONS
...@@ -44,21 +44,18 @@ function getMemvalue(){ ...@@ -44,21 +44,18 @@ function getMemvalue(){
echo $( grep "^$1:" /proc/meminfo | awk '{ print $2 }' ) / 1024 | bc echo $( grep "^$1:" /proc/meminfo | awk '{ print $2 }' ) / 1024 | bc
} }
# show help text
function showHelp(){ function showHelp(){
local _self; _self=$(basename $0)
cat <<EOF cat <<EOF
______________________________________________________________________ $( ph.showImlHelpHeader )
$self_APPNAME
v$self_APPVERSION
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
Check memory usage incl. free, used and total memory. Check memory usage incl. free, used and total memory.
On higher memory usage the process table with top 5 top consumers will On higher memory usage the process table with top 5 top consumers will
be shown. be shown.
This plugin sends performancedata.
SYNTAX: SYNTAX:
$(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-s SWAP_LIMIT] [-p PROCESS_LIMIT] [-h] $(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-s SWAP_LIMIT] [-p PROCESS_LIMIT] [-h]
......
...@@ -19,13 +19,12 @@ ...@@ -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-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 # 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-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 . $( dirname $0 )/inc_pluginfunctions
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) export self_APPVERSION=1.0
self_APPVERSION=0.3
# --- set HOME # --- set HOME
HOME=/etc/icingaclient HOME=/etc/icingaclient
...@@ -33,7 +32,7 @@ HOME=/etc/icingaclient ...@@ -33,7 +32,7 @@ HOME=/etc/icingaclient
# --- other vars... # --- other vars...
cfgfile=$HOME/.my.cnf cfgfile=$HOME/.my.cnf
myuser=icingamonitor myuser=icingamonitor
datafile=/tmp/mysqlvars.out datafile=/tmp/mysqlvars_$USER.out
# new line # new line
NL=" NL="
...@@ -100,17 +99,11 @@ EOF ...@@ -100,17 +99,11 @@ EOF
fi fi
} }
# show usage # show help text
function _usage(){ function showHelp(){
local _self=$( basename $0 ) local _self; _self=$(basename $0)
cat <<EOH cat <<EOF
______________________________________________________________________ $( ph.showImlHelpHeader )
${self_APPNAME} :: v${self_APPVERSION}
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
USAGE: USAGE:
$_self [OPTIONS] -m METHOD $_self [OPTIONS] -m METHOD
...@@ -133,7 +126,7 @@ EXAMPLES: ...@@ -133,7 +126,7 @@ EXAMPLES:
$_self -i $_self -i
$_self -m commands $_self -m commands
EOH EOF
} }
function _mysqlreadvars(){ function _mysqlreadvars(){
...@@ -206,7 +199,7 @@ bOptUninstall=$( ph.hasParamoption "u" "$@") ...@@ -206,7 +199,7 @@ bOptUninstall=$( ph.hasParamoption "u" "$@")
bOptHelp=$( ph.hasParamoption "h" "$@") bOptHelp=$( ph.hasParamoption "h" "$@")
if [ $bOptHelp -eq 1 -o $# -lt 1 ]; then if [ $bOptHelp -eq 1 -o $# -lt 1 ]; then
_usage showHelp
exit 0 exit 0
fi fi
...@@ -245,7 +238,6 @@ fi ...@@ -245,7 +238,6 @@ fi
if ! grep $myuser $cfgfile >/dev/null 2>&1; then 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" ph.abort "MYSQL access not possible yet. You need to install the monitoring user first: as root execute $(basename $0) -i"
fi fi
. "${cfgfile}"
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -328,7 +320,7 @@ case "${sMode}" in ...@@ -328,7 +320,7 @@ case "${sMode}" in
*) *)
echo ERRROR: [${sMode}] is an INVALID mode echo ERRROR: [${sMode}] is an INVALID mode
_usage showHelp
ph.abort ph.abort
esac esac
......
...@@ -24,8 +24,8 @@ There is one include script used by all checks: ...@@ -24,8 +24,8 @@ There is one include script used by all checks:
* [check_fs_writable](check_fs_writable.md) * [check_fs_writable](check_fs_writable.md)
* [check_haproxy_health](check_haproxy_health.md) * [check_haproxy_health](check_haproxy_health.md)
* [check_haproxy_status](check_haproxy_status.md) * [check_haproxy_status](check_haproxy_status.md)
* check_memory * [check_memory](check_memory.md)
* check_mysqlserver * [check_mysqlserver](check_mysqlserver.md)
* check_netio * check_netio
* [check_netstat](check_netstat.md) * [check_netstat](check_netstat.md)
* [check_onehost](check_onehost.md) * [check_onehost](check_onehost.md)
......
# 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
```
# 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`.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment