[UPDATE] - fork process with screen + webserver
This commit is contained in:
parent
fc88812101
commit
6cacea01ba
@ -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
|
||||
|
||||
@ -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 '
|
||||
<html>
|
||||
<head>
|
||||
<title>MoniThor on '${RemoteIp}' </title>
|
||||
<meta http-equiv="refresh" content="'${Rotation}'" />
|
||||
</head>
|
||||
<title>MONITHOR</title>
|
||||
if [[ ${Total} -eq ${Actual} ]]
|
||||
then
|
||||
|
||||
Date : '$(date +'%Y-%m-%d %H:%M:%S')'
|
||||
echo '
|
||||
<html>
|
||||
<head>
|
||||
<title>MoniThor on '${RemoteIp}' </title>
|
||||
<meta http-equiv="refresh" content="1" />
|
||||
</head>
|
||||
<title>MONITHOR</title>
|
||||
Date : '$(date +'%Y-%m-%d %H:%M:%S')'
|
||||
<table border="1" color="#FFFFFF">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4">MoniThor Result</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>' > /tmp/webmonithor
|
||||
|
||||
<table border="1" color="#FFFFFF">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4">MoniThor Result</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
' > /tmp/webmonithor
|
||||
cat /tmp/Monithor_*-tmp >> /tmp/webmonithor
|
||||
|
||||
cat /tmp/Monithor_* >> /tmp/webmonithor
|
||||
rm /tmp/Monithor -f
|
||||
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
echo '
|
||||
</tbody>
|
||||
</table> ' >> /tmp/webmonithor
|
||||
mv /tmp/webmonithor ../web/index.html
|
||||
|
||||
|
||||
mv /tmp/webmonithor ../web/index.html
|
||||
rm /tmp/Monithor_* -f
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
GenerateWebEnd(){
|
||||
echo '<!--End of '$1'-->'| tee -a $1
|
||||
echo '<!--End of '$1' '$(pwd)'-->' >> $1
|
||||
|
||||
}
|
||||
|
||||
@ -67,13 +65,7 @@ GenerateWeb(){
|
||||
[[ $Val == "1" ]] && Color=yellow
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>'$Remote'</td>
|
||||
<td>'$Sonde'</td>
|
||||
<td>'$Arg'</td>
|
||||
<td style="background-color:'${Color}';" > '$Val' </td>
|
||||
<td> '$Txt'</td>
|
||||
</tr>' >> ${File}
|
||||
<tr> <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
|
||||
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" ]]
|
||||
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
|
||||
|
||||
@ -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