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

Merge branch 'update-docs' into 'master'

Update docs

See merge request !270
parents d39c54d3 06a567a2
No related branches found
No related tags found
1 merge request!270Update docs
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
# #
# 2023-02-13 v1.0 ah initial version with check for processes, tcp/ udp # 2023-02-13 v1.0 ah initial version with check for processes, tcp/ udp
# 2023-02-15 v1.1 ah add label # 2023-02-15 v1.1 ah add label
# 2024-06-07 v1.2 ah use iml help and add link to docs
# ====================================================================== # ======================================================================
. "$( dirname $0 )/inc_pluginfunctions" . "$( dirname $0 )/inc_pluginfunctions"
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) self_APPVERSION=1.2
self_APPVERSION=1.1
self=$( basename $0 ) self=$( basename $0 )
...@@ -38,15 +38,8 @@ PROCESSES= ...@@ -38,15 +38,8 @@ PROCESSES=
# show help # show help
function showHelp(){ function showHelp(){
cat <<EOF cat <<EOH
______________________________________________________________________ $( ph.showImlHelpHeader )
$self_APPNAME
v$self_APPVERSION
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
Check if a list requirements regarding processes and network Check if a list requirements regarding processes and network
connections do exist. connections do exist.
...@@ -89,7 +82,7 @@ $self -p httpd -p mysqld -t 22 -t 80 -t 443 -t 3306 ...@@ -89,7 +82,7 @@ $self -p httpd -p mysqld -t 22 -t 80 -t 443 -t 3306
$self -l "webservice" -p httpd -t 80 -t 443 -l "database" -p mysqld -t 3306 $self -l "webservice" -p httpd -t 80 -t 443 -l "database" -p mysqld -t 3306
Use output with multiple sections Use output with multiple sections
EOF EOH
} }
# show a label to divide the output in multiple sections # show a label to divide the output in multiple sections
......
#!/bin/bash
# ======================================================================
#
# SENSU CHECK FOR VALIDITY OF PLUGIN LINKS
#
# ----------------------------------------------------------------------
#
# ----------------------------------------------------------------------
# 2018-07-17 first lines
# 2022-10-21 v1.1 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# ======================================================================
. `dirname $0`/inc_pluginfunctions
tmpfile=/tmp/check_sensuplugins.out
# ----------------------------------------------------------------------
# functions to fetch infos by status
# ----------------------------------------------------------------------
function _getStatus(){
cat $tmpfile | grep '^\.\.\.' | grep " $1\:"
}
function getTotal(){
_getStatus '.*'
}
function getOK(){
_getStatus "OK"
}
function getWarnings(){
_getStatus "WARNING"
}
function getErrors(){
_getStatus "ERROR"
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
(/usr/local/bin/link-sensu-checks.sh -i ; /usr/local/bin/link-sensu-checks.sh -f) >$tmpfile
# --- output of errors and warnings
echo --- Check sensu plugins
getErrors
getWarnings
# --- show status
typeset -i iTOTAL=`getTotal | wc -l`
typeset -i iOK=`getOK | wc -l`
typeset -i iERRORS=`getErrors | wc -l`
typeset -i iWARNINGS=`getWarnings | wc -l`
echo --- Status:
echo "total : $iTOTAL"
echo "Errors : $iERRORS"
echo "Warnings: $iWARNINGS"
echo "OK : $iOK"
rm -f $tmpfile
# --- return with wanted exitcode
if [ $iERRORS -gt 0 ]; then
echo exit with error.
exit $EXIT_CRITICAL
fi
if [ $iWARNINGS -gt 0 ]; then
echo exit with warning
exit $EXIT_WARNING
fi
echo exit with OK
exit $EXIT_OK
# ----------------------------------------------------------------------
...@@ -46,8 +46,7 @@ There is one include script used by all checks: ...@@ -46,8 +46,7 @@ There is one include script used by all checks:
* [check_psqlserver](check_psqlserver.md) * [check_psqlserver](check_psqlserver.md)
* [check_rearbackup](check_rearbackup.md) * [check_rearbackup](check_rearbackup.md)
* [check_reboot_required](check_reboot_required.md) * [check_reboot_required](check_reboot_required.md)
* check_requirements * [check_requirements](check_requirements.md)
* check_sensuplugins
* check_smartstatus * check_smartstatus
* [check_snmp_data](check_snmp_data.md) * [check_snmp_data](check_snmp_data.md)
* check_snmp_printer * check_snmp_printer
......
# Check_requirements
## Introduction
**check_requirements** is a plugin to run different check to show the ability to run an application. You can these checks
* Check if a process exists
* Check an open udp or tcp port (local or on given host/ ip)
You can insert a label to create multiple blocks.
## Requirements
* `ps`
* `top`
## Syntax
```txt
______________________________________________________________________
CHECK_REQUIREMENTS
v1.2
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_requirements.html
______________________________________________________________________
Check if a list requirements regarding processes and network
connections do exist.
The check returns OK if all given requirements match.
SYNTAX:
check_requirements [-h] [-v] [PARAMETERS]
OPTIONS:
-h|--help show this help.
-v|--verbose show more data: processes and port numbers from
/etc/services; add it as first param
PARAMETERS:
-c|--connect TYPE TARGET PORT
check if connect to a server to a given port
is reachable
TYPE string one of tcp|udp
TARGET string target host
PORT int port number
-l|--label STRING add label to divide the output in multiple sections
-p|--process STRING check if a process with given regex exists in the
output of 'ps aux'
-t|--tcp PORT check if connect on local tcp port is reachable;
This is a shortcut for '-c tcp localhost PORT'
The parameters can be repeated multiple times. Checks will be executed in
the given order.
EXAMPLES
check_requirements -p httpd -p mysqld -t 22 -t 80 -t 443 -t 3306
Check if
- a process httpd and a process mysqld exist
- localhost listens to ports 22, 80, 443 and 3306
check_requirements -l "webservice" -p httpd -t 80 -t 443 -l "database" -p mysqld -t 3306
Use output with multiple sections
```
### Parameters
(none)
## Examples
Check a webservice as process and 2 ports: ``check_requirements -p nginx -t 443 -t 80``
```txt
OK: 3 Requirement checks - errors: 0
STATUS TYPE RESULT
OK process nginx (2 x)
OK connection tcp to localhost on port 443
OK connection tcp to localhost on port 80
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment