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

add check_fs_writable

parent ee916f18
No related branches found
No related tags found
No related merge requests found
#!/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