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

add filesystem checks check_fs_errors and check_fs_writable

parent f0aae829
No related branches found
No related tags found
No related merge requests found
# IML Checks for Icinga / Nagios
[Home](readme.md)
---
## check CPU
### Introduction
**check_cpu** is a plugin to check cpu usage and cpu io wait.
It reads cpu data from output of top command and shows
hwi - Time spent handling hardware interrupt routines. (Whenever a peripheral unit want attention form the CPU, it literally pulls a line, to signal the CPU to service it)
swi - Time spent handling software interrupt routines. (a piece of code, calls an interrupt routine...)
st - Time spent on involuntary waits by virtual cpu while hypervisor is servicing another processor (stolen from a virtual machine)
nice - Time spent running niced user processes (User defined priority)
wait - Time spent on waiting on IO peripherals (eg. disk)
system - Time spent in kernel space
user - Time spent in user space
idle - Time spent in idle operations
For all values it sends performance data.
### Syntax
``$ check_NAME [-c CRITICAL] [-w WARING] [-i CRITICAL_IO]``
#### Parameters
```text
-w VALUE cpu usage warning level (default: 75)
-c VALUE cpu usage critical level (default: 90)
-i VALUE io wait critical level (default: 50)
-h or --help show this help.
```
# Examples
``check_cpu -w 60 -c 80 -i 40``
check cpu usage.
It shows a warning if usage is higer 60%.
It shows critical status if usage is higer 80% or io wait is 40%
#!/usr/bin/env bash
# ======================================================================
#
# Check filesystem errors
#
#
# requirements:
# - sudo permission on /bin/journalctl
#
# ----------------------------------------------------------------------
# 2021-03-23 v0.0 <axel.hahn@iml.unibe.ch>
# ======================================================================
. `dirname $0`/inc_pluginfunctions
# ----------------------------------------------------------------------
# functions
# ----------------------------------------------------------------------
function showHelp(){
cat <<EOF
______________________________________________________________________
CHECK_FS_ERRORS check if kernel logs inconsistency messages
(c) Institute for Medical Education - Univerity of Bern
Licence: GNU GPL 3
______________________________________________________________________
SYNTAX:
`basename $0` [-h]
OPTIONS:
-h or --help show this help.
PARAMETERS:
none
EXAMPLE:
`basename $0`
EOF
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
# --- check required tools
# ph.require bc top
# --- check param -h
case "$1" in
"--help"|"-h")
showHelp
exit 0
;;
*)
esac
# ----- MAKE CHECK
out=$( sudo /bin/journalctl | grep 'kernel: ' | grep -v 'check_fs_errors' | grep -E '(error|fail)' | grep 'inconsistent' )
test ! -z "$out" && ph.setStatus "critical"
# ----- OUTPUT
ph.status "check if kernel logs inconsistency messages"
echo $out
# ----- CLEANUP AND BYE!
ph.exit
# ----------------------------------------------------------------------
#!/usr/bin/env bash
# ======================================================================
#
# Check filesystem ... is it readonly?
#
# requirements:
# - none
#
# ----------------------------------------------------------------------
# 2021-03-23 v0.0 <axel.hahn@iml.unibe.ch>
# ======================================================================
. `dirname $0`/inc_pluginfunctions
dirs2test="/tmp /var/tmp"
out=""
# ----------------------------------------------------------------------
# functions
# ----------------------------------------------------------------------
function showHelp(){
cat <<EOF
______________________________________________________________________
CHECK_FS_READONLY check if filesystem is readonly - v0.0
(c) Institute for Medical Education - Univerity of Bern
Licence: GNU GPL 3
______________________________________________________________________
SYNTAX:
`basename $0` [directory [more directories]]
OPTIONS:
-h or --help show this help.
PARAMETERS:
DIRECTORY where to touch a temporary file
EXAMPLE:
`basename $0` /tmp /root /var/www
EOF
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
# --- check required tools
# ph.require bc top
# --- check param -h
case "$1" in
"--help"|"-h")
showHelp
exit 0
;;
*)
esac
# params are directory names ... if a param was given it overrides the internal default
test $# -gt 0 && dirs2test="$*"
# ----- MAKE CHECK
for mydir in $dirs2test
do
touchfile=$mydir/icinga_touch_testfile__${RANDOM}_${RANDOM}
out="$out
--- touching something into $mydir
$( touch $touchfile && ls -l $touchfile && rm -f $touchfile 2>&1 )"
if [ $? -ne 0 ]; then
ph.setStatus "critical"
fi
done
# ----- OUTPUT
ph.status "check if filesystem is writable in $dirs2test $out"
#echo "$out"
# ----- CLEANUP AND BYE!
ph.exit
# ----------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment