From 6cacea01bae4dde3acf4f37f034414a8abf1e8f1 Mon Sep 17 00:00:00 2001 From: guillaume Date: Wed, 16 Mar 2022 18:05:23 +0000 Subject: [PATCH] [UPDATE] - fork process with screen + webserver --- client/conf-client/exec.sh | 4 +- client/conf-client/functions | 75 +++++++++++++---------------- client/conf-client/webmonithor.html | 44 ----------------- client/conf-client/webserver.sh | 31 +++++++++++- client/service.sh | 12 ++--- client/web/webmonithor.html | 44 ----------------- 6 files changed, 70 insertions(+), 140 deletions(-) delete mode 100644 client/conf-client/webmonithor.html delete mode 100644 client/web/webmonithor.html diff --git a/client/conf-client/exec.sh b/client/conf-client/exec.sh index 2307940..21e80c5 100755 --- a/client/conf-client/exec.sh +++ b/client/conf-client/exec.sh @@ -13,10 +13,8 @@ while [[ ! -f /tmp/endmonitor ]] do if [[ -f /tmp/Monithor_${ConfFile}-tmp ]] then - + GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp sleep ${Rotation} - GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp - CheckAllEnd ${TotalConfig} else while read DATA do diff --git a/client/conf-client/functions b/client/conf-client/functions index 7354bc7..89f2b52 100644 --- a/client/conf-client/functions +++ b/client/conf-client/functions @@ -5,52 +5,50 @@ PrintRes() { } + CheckAllEnd() { - Total=$1 - Actual=0 - for AcutalFile in $(find /tmp/ -name Monithor_\*-tmp) - do - [[ ! -z $(tail -n 1 $ActualFile | grep 'End of') ]] && Acutal=$((Actual + 1)) - done - - if [[ ${Total} -eq ${Actual} ]] + if [[ ! -f /tmp/webmonithor ]] then + Total=$1 + Actual=0 + for ActualFile in $(find /tmp/ -name Monithor_\*-tmp) + do + [[ ! -z $(tail -n 1 $ActualFile | grep 'End of') ]] && Actual=$((Actual + 1)) + done - echo ' - - - MoniThor on '${RemoteIp}' - - - MONITHOR + if [[ ${Total} -eq ${Actual} ]] + then - Date : '$(date +'%Y-%m-%d %H:%M:%S')' + echo ' + + + MoniThor on '${RemoteIp}' + + +MONITHOR + Date : '$(date +'%Y-%m-%d %H:%M:%S')' + + + + + + + ' > /tmp/webmonithor -
MoniThor Result
- - - - - - -' > /tmp/webmonithor + cat /tmp/Monithor_*-tmp >> /tmp/webmonithor -cat /tmp/Monithor_* >> /tmp/webmonithor -rm /tmp/Monithor -f - - - echo ' - + echo ' +
MoniThor Result
' >> /tmp/webmonithor - mv /tmp/webmonithor ../web/index.html - - + mv /tmp/webmonithor ../web/index.html + rm /tmp/Monithor_* -f + fi fi } GenerateWebEnd(){ - echo ''| tee -a $1 + echo '' >> $1 } @@ -67,13 +65,7 @@ GenerateWeb(){ [[ $Val == "1" ]] && Color=yellow echo ' - - '$Remote' - '$Sonde' - '$Arg' - '$Val' - '$Txt' -' >> ${File} + '$Remote' '$Sonde' '$Arg' '$Val' '$Txt' ' >> ${File} @@ -81,3 +73,4 @@ GenerateWeb(){ + diff --git a/client/conf-client/webmonithor.html b/client/conf-client/webmonithor.html deleted file mode 100644 index 0152752..0000000 --- a/client/conf-client/webmonithor.html +++ /dev/null @@ -1,44 +0,0 @@ - - - Date : 2022-03-16 12:27:19 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MoniThor Result
file/tmp/coucou 0 0
file/tmp/nop 0 0
file 5 5
tamerereboot 5 5
diff --git a/client/conf-client/webserver.sh b/client/conf-client/webserver.sh index 9fc07bf..5c6a744 100644 --- a/client/conf-client/webserver.sh +++ b/client/conf-client/webserver.sh @@ -1,5 +1,32 @@ #!/bin/bash +cd $(dirname $0)/../web/ +source ../conf-client/functions +python -m SimpleHTTPServer ${1} & + + +echo ' + + MoniThor on '${RemoteIp}' + + +MONITHOR + +!!!! Initialization !!!! + +' > index.html + +while [[ ! -f /tmp/endmonitor ]] + do + if [[ ! -z $(ls -1 /tmp/ | grep Monithor_.*-tmp) ]] + then + CheckAllEnd $2 + echo INSIDE + fi + sleep 1 + + done + + + -pushd $(dirname $0)/../web/ -python -m SimpleHTTPServer ${1} diff --git a/client/service.sh b/client/service.sh index 6898460..63d4af7 100755 --- a/client/service.sh +++ b/client/service.sh @@ -6,20 +6,20 @@ source $(dirname $0)/conf-client/functions if [[ "$1" == "start" ]] then [[ -f /tmp/endmonitor ]] && rm -f /tmp/endmonitor - bash ./conf-client/webserver.sh ${WebPort} & + rm /tmp/Monitor* /tmp/webmonithor &> /dev/null - export TotalConfig=$(ls -1 ./conf-client | grep Card_.*\.cfg|wc -l) + TotalConfig=$(ls -1 ./conf-client | grep Card_.*\.cfg|wc -l) for Conf in $(ls -1 ./conf-client | grep Card_.*\.cfg) do - screen -dmS ${Conf} bash -x ./conf-client/exec.sh ${Conf} + screen -dmS ${Conf} bash ./conf-client/exec.sh ${Conf} done - + screen -dmS webserver bash ./conf-client/webserver.sh ${WebPort} $TotalConfig fi if [[ "$1" == "stop" ]] then - killall python - rm /tmp/Monithor* + killall python &> /dev/null + rm /tmp/Monithor* &> /dev/null touch /tmp/endmonitor fi diff --git a/client/web/webmonithor.html b/client/web/webmonithor.html deleted file mode 100644 index 5015a96..0000000 --- a/client/web/webmonithor.html +++ /dev/null @@ -1,44 +0,0 @@ - - - Date : 2022-03-16 12:29:16 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MoniThor Result
file/tmp/coucou 0 0
file/tmp/nop 0 0
file 5 5
tamerereboot 5 5