[UPDATE] - fork process with screen + webserver
This commit is contained in:
parent
fc88812101
commit
6cacea01ba
@ -13,10 +13,8 @@ while [[ ! -f /tmp/endmonitor ]]
|
|||||||
do
|
do
|
||||||
if [[ -f /tmp/Monithor_${ConfFile}-tmp ]]
|
if [[ -f /tmp/Monithor_${ConfFile}-tmp ]]
|
||||||
then
|
then
|
||||||
|
|
||||||
sleep ${Rotation}
|
|
||||||
GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp
|
GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp
|
||||||
CheckAllEnd ${TotalConfig}
|
sleep ${Rotation}
|
||||||
else
|
else
|
||||||
while read DATA
|
while read DATA
|
||||||
do
|
do
|
||||||
|
|||||||
@ -5,13 +5,16 @@ PrintRes() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CheckAllEnd() {
|
CheckAllEnd() {
|
||||||
|
|
||||||
|
if [[ ! -f /tmp/webmonithor ]]
|
||||||
|
then
|
||||||
Total=$1
|
Total=$1
|
||||||
Actual=0
|
Actual=0
|
||||||
for AcutalFile in $(find /tmp/ -name Monithor_\*-tmp)
|
for ActualFile in $(find /tmp/ -name Monithor_\*-tmp)
|
||||||
do
|
do
|
||||||
[[ ! -z $(tail -n 1 $ActualFile | grep 'End of') ]] && Acutal=$((Actual + 1))
|
[[ ! -z $(tail -n 1 $ActualFile | grep 'End of') ]] && Actual=$((Actual + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ${Total} -eq ${Actual} ]]
|
if [[ ${Total} -eq ${Actual} ]]
|
||||||
@ -21,36 +24,31 @@ CheckAllEnd() {
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>MoniThor on '${RemoteIp}' </title>
|
<title>MoniThor on '${RemoteIp}' </title>
|
||||||
<meta http-equiv="refresh" content="'${Rotation}'" />
|
<meta http-equiv="refresh" content="1" />
|
||||||
</head>
|
</head>
|
||||||
<title>MONITHOR</title>
|
<title>MONITHOR</title>
|
||||||
|
|
||||||
Date : '$(date +'%Y-%m-%d %H:%M:%S')'
|
Date : '$(date +'%Y-%m-%d %H:%M:%S')'
|
||||||
|
|
||||||
<table border="1" color="#FFFFFF">
|
<table border="1" color="#FFFFFF">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="4">MoniThor Result</th>
|
<th colspan="4">MoniThor Result</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>' > /tmp/webmonithor
|
||||||
' > /tmp/webmonithor
|
|
||||||
|
|
||||||
cat /tmp/Monithor_* >> /tmp/webmonithor
|
|
||||||
rm /tmp/Monithor -f
|
|
||||||
|
|
||||||
|
cat /tmp/Monithor_*-tmp >> /tmp/webmonithor
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</tbody>
|
</tbody>
|
||||||
</table> ' >> /tmp/webmonithor
|
</table> ' >> /tmp/webmonithor
|
||||||
mv /tmp/webmonithor ../web/index.html
|
mv /tmp/webmonithor ../web/index.html
|
||||||
|
rm /tmp/Monithor_* -f
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateWebEnd(){
|
GenerateWebEnd(){
|
||||||
echo '<!--End of '$1'-->'| tee -a $1
|
echo '<!--End of '$1' '$(pwd)'-->' >> $1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,13 +65,7 @@ GenerateWeb(){
|
|||||||
[[ $Val == "1" ]] && Color=yellow
|
[[ $Val == "1" ]] && Color=yellow
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr> <td>'$Remote'</td> <td>'$Sonde'</td> <td>'$Arg'</td> <td style="background-color:'${Color}';" > '$Val' </td> <td> '$Txt'</td> </tr>' >> ${File}
|
||||||
<td>'$Remote'</td>
|
|
||||||
<td>'$Sonde'</td>
|
|
||||||
<td>'$Arg'</td>
|
|
||||||
<td style="background-color:'${Color}';" > '$Val' </td>
|
|
||||||
<td> '$Txt'</td>
|
|
||||||
</tr>' >> ${File}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -81,3 +73,4 @@ GenerateWeb(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
Date : 2022-03-16 12:27:19
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th colspan="2">MoniThor Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>file</td>
|
|
||||||
<td>/tmp/coucou</td>
|
|
||||||
<td> 0 </td>
|
|
||||||
<td> 0</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>file</td>
|
|
||||||
<td>/tmp/nop</td>
|
|
||||||
<td> 0 </td>
|
|
||||||
<td> 0</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>file</td>
|
|
||||||
<td></td>
|
|
||||||
<td> 5 </td>
|
|
||||||
<td> 5</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>tamere</td>
|
|
||||||
<td>reboot</td>
|
|
||||||
<td> 5 </td>
|
|
||||||
<td> 5</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
@ -1,5 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
cd $(dirname $0)/../web/
|
||||||
|
source ../conf-client/functions
|
||||||
|
python -m SimpleHTTPServer ${1} &
|
||||||
|
|
||||||
|
|
||||||
|
echo '<html>
|
||||||
|
<head>
|
||||||
|
<title>MoniThor on '${RemoteIp}' </title>
|
||||||
|
<meta http-equiv="refresh" content="1" />
|
||||||
|
</head>
|
||||||
|
<title>MONITHOR</title>
|
||||||
|
|
||||||
|
!!!! 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}
|
|
||||||
|
|
||||||
|
|||||||
@ -6,20 +6,20 @@ source $(dirname $0)/conf-client/functions
|
|||||||
if [[ "$1" == "start" ]]
|
if [[ "$1" == "start" ]]
|
||||||
then
|
then
|
||||||
[[ -f /tmp/endmonitor ]] && rm -f /tmp/endmonitor
|
[[ -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)
|
for Conf in $(ls -1 ./conf-client | grep Card_.*\.cfg)
|
||||||
do
|
do
|
||||||
screen -dmS ${Conf} bash -x ./conf-client/exec.sh ${Conf}
|
screen -dmS ${Conf} bash ./conf-client/exec.sh ${Conf}
|
||||||
done
|
done
|
||||||
|
screen -dmS webserver bash ./conf-client/webserver.sh ${WebPort} $TotalConfig
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "stop" ]]
|
if [[ "$1" == "stop" ]]
|
||||||
then
|
then
|
||||||
killall python
|
killall python &> /dev/null
|
||||||
rm /tmp/Monithor*
|
rm /tmp/Monithor* &> /dev/null
|
||||||
touch /tmp/endmonitor
|
touch /tmp/endmonitor
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
Date : 2022-03-16 12:29:16
|
|
||||||
|
|
||||||
<table border="1" color='#FFFFFF' >
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th colspan="4">MoniThor Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>file</td>
|
|
||||||
<td>/tmp/coucou</td>
|
|
||||||
<td> 0 </td>
|
|
||||||
<td> 0</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>file</td>
|
|
||||||
<td>/tmp/nop</td>
|
|
||||||
<td> 0 </td>
|
|
||||||
<td> 0</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>file</td>
|
|
||||||
<td></td>
|
|
||||||
<td style="background-color:red;" > 5 </td>
|
|
||||||
<td> 5</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>tamere</td>
|
|
||||||
<td>reboot</td>
|
|
||||||
<td> 5 </td>
|
|
||||||
<td> 5</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user