[UPDATE] Add script sonde

This commit is contained in:
Prof Isen 2022-03-17 11:21:52 +01:00
parent c69661a84f
commit ff1c26d7fb
5 changed files with 32 additions and 1 deletions

View File

@ -43,7 +43,9 @@ Actual :
**file-present.sh** : check if a file (abosult path) is persent **file-present.sh** : check if a file (abosult path) is persent
** **part-space.sh** : check the partition % (arg are : PATH|Min%|Max% ex : /home/isen|50|80)
**process-present.sh** : check if a process is running
### tree ### tree

View File

@ -0,0 +1,18 @@
#!/bin/bash
source $(dirname $0)/FunctionOutput
Part="$(echo $1 | cut -d"|" -f1)"
Min="$(echo $1 | cut -d"|" -f2)"
Max="$(echo $1 | cut -d"|" -f3)"
[[ -z ${Part} ]] && Exit "5|no argument"
[[ ! -d ${Part} ]] && Exit "2|Part $Part don't exist"
[[ -z $(mount | grep -w ${Part}) ]] && Exit "2|$Part is not a partition"
Size=$(df -h ${Part} | grep -v Filesystem | awk '{print $5}' | sed "s#%##g")
[[ ${Size} -lt ${Min} ]] && Exit "0|Part $Part is under ${Min}% : ${Size}"
[[ ${Size} -gt ${Max} ]] && Exit "2|Part $Part is over ${Max}% : ${Size}"
[[ ${Size} -gt ${Min} ]] && Exit "1|Part $Part is between ${Min}% and ${Max}% : ${Size}"

View File

@ -0,0 +1,11 @@
#!/bin/bash
source $(dirname $0)/FunctionOutput
Process="${1}"
[[ -z ${Process} ]] && Exit "5|no argument"
[[ ! -z $(ps axf | grep ${Process}| grep -v grep) ]] && Exit "0|Process $Process is running" || Exit "2|Process $Process is NOT running"