[UPDATE] - fork process with screen
This commit is contained in:
parent
5ad25fb23d
commit
304043d02f
4
client/conf-client/Card_10.10.10.3-1666.cfg
Normal file
4
client/conf-client/Card_10.10.10.3-1666.cfg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
10.10.10.3:1666#file#/tmp/coucou
|
||||||
|
10.10.10.3:1666#file#/tmp/nop
|
||||||
|
10.10.10.3:1666#file#
|
||||||
|
10.10.10.3:1666#NotRealSondeName#reboot
|
||||||
4
client/conf-client/Card_10.10.10.4-1666.cfg
Normal file
4
client/conf-client/Card_10.10.10.4-1666.cfg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
10.10.10.4:1666#file#/tmp/coucou
|
||||||
|
10.10.10.4:1666#file#/tmp/nop
|
||||||
|
10.10.10.4:1666#file#
|
||||||
|
10.10.10.4:1666#NotRealSondeName#reboot
|
||||||
@ -6,11 +6,18 @@ cd $(dirname $0)
|
|||||||
SondeFile=$(pwd)/sonde.cfg
|
SondeFile=$(pwd)/sonde.cfg
|
||||||
source service.cfg
|
source service.cfg
|
||||||
source functions
|
source functions
|
||||||
|
ConfFile=$1
|
||||||
|
|
||||||
#[[ "${Crypted}" == "yes" ]] && NcCmd="timeout ${TimeOut} cryptcat -k ${LocalPassword} ${RemoteIp} ${RemotePort} " || NcCmd="timeout ${TimeOut} nc ${RemoteIp} ${RemotePort}"
|
|
||||||
[[ "${Crypted}" == "yes" ]] && NcCmd="timeout ${TimeOut} cryptcat -k ${LocalPassword} " || NcCmd="timeout ${TimeOut} nc "
|
[[ "${Crypted}" == "yes" ]] && NcCmd="timeout ${TimeOut} cryptcat -k ${LocalPassword} " || NcCmd="timeout ${TimeOut} nc "
|
||||||
|
while [[ ! -f /tmp/endmonitor ]]
|
||||||
|
do
|
||||||
|
if [[ -f /tmp/Monithor_${ConfFile}-tmp ]]
|
||||||
|
then
|
||||||
|
|
||||||
PrintWeb START_TRATS
|
sleep ${Rotation}
|
||||||
|
GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp
|
||||||
|
CheckAllEnd ${TotalConfig}
|
||||||
|
else
|
||||||
while read DATA
|
while read DATA
|
||||||
do
|
do
|
||||||
Remote=$(echo $DATA| cut -d"#" -f1| cut -d":" -f1)
|
Remote=$(echo $DATA| cut -d"#" -f1| cut -d":" -f1)
|
||||||
@ -19,9 +26,9 @@ PrintWeb START_TRATS
|
|||||||
Arg=$(echo $DATA| cut -d"#" -f3)
|
Arg=$(echo $DATA| cut -d"#" -f3)
|
||||||
Res=$( echo -e "${Cmd}#${Arg}" | eval ${NcCmd} ${Remote} ${Port} 2> /dev/null)
|
Res=$( echo -e "${Cmd}#${Arg}" | eval ${NcCmd} ${Remote} ${Port} 2> /dev/null)
|
||||||
Ret=$?
|
Ret=$?
|
||||||
PrintRes "${Res:-5|No sonde $Cmd on serveur $Remote}"
|
GenerateWeb "${Res:-5|No sonde $Cmd on serveur $Remote}" ${Cmd:-Nodata} ${Arg:-Noadata} ${Remote:-Nodata} /tmp/Monithor_${ConfFile}-tmp
|
||||||
PrintWeb "${Res:-5|No sonde $Cmd on serveur $Remote}" ${Cmd:-Nodata} ${Arg:-Noadata} ${Remote:-Nodata}
|
done < ${ConfFile}
|
||||||
done < ${SondeFile}
|
fi
|
||||||
PrintWeb END_DNE
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,16 +5,25 @@ PrintRes() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintWeb() {
|
CheckAllEnd() {
|
||||||
|
|
||||||
if [[ ! -f /tmp/webmonithor ]] || [[ "$1" == "START_TRATS" ]]
|
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} ]]
|
||||||
then
|
then
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<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="'${Rotation}'" />
|
||||||
</head>
|
</head>
|
||||||
|
<title>MONITHOR</title>
|
||||||
|
|
||||||
Date : '$(date +'%Y-%m-%d %H:%M:%S')'
|
Date : '$(date +'%Y-%m-%d %H:%M:%S')'
|
||||||
|
|
||||||
@ -27,23 +36,32 @@ PrintWeb() {
|
|||||||
<tbody>
|
<tbody>
|
||||||
' > /tmp/webmonithor
|
' > /tmp/webmonithor
|
||||||
|
|
||||||
fi
|
cat /tmp/Monithor_* >> /tmp/webmonithor
|
||||||
|
rm /tmp/Monithor -f
|
||||||
|
|
||||||
|
|
||||||
if [ "$1" == "END_DNE" ]
|
|
||||||
then
|
|
||||||
echo '
|
echo '
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table> ' >> /tmp/webmonithor
|
</table> ' >> /tmp/webmonithor
|
||||||
mv /tmp/webmonithor ../web/index.html
|
mv /tmp/webmonithor ../web/index.html
|
||||||
|
|
||||||
else
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
GenerateWebEnd(){
|
||||||
|
echo '<!--End of '$1'-->'| tee -a $1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GenerateWeb(){
|
||||||
|
|
||||||
Val=$(echo $1 | cut -d"|" -f1)
|
Val=$(echo $1 | cut -d"|" -f1)
|
||||||
Txt=$(echo $1 | cut -d"|" -f2)
|
Txt=$(echo $1 | cut -d"|" -f2)
|
||||||
Sonde=$2
|
Sonde=$2
|
||||||
Arg=$3
|
Arg=$3
|
||||||
Remote=$4
|
Remote=$4
|
||||||
|
File=$5
|
||||||
Color=red
|
Color=red
|
||||||
[[ $Val == "0" ]] && Color=green
|
[[ $Val == "0" ]] && Color=green
|
||||||
[[ $Val == "1" ]] && Color=yellow
|
[[ $Val == "1" ]] && Color=yellow
|
||||||
@ -55,7 +73,11 @@ PrintWeb() {
|
|||||||
<td>'$Arg'</td>
|
<td>'$Arg'</td>
|
||||||
<td style="background-color:'${Color}';" > '$Val' </td>
|
<td style="background-color:'${Color}';" > '$Val' </td>
|
||||||
<td> '$Txt'</td>
|
<td> '$Txt'</td>
|
||||||
</tr>' >> /tmp/webmonithor
|
</tr>' >> ${File}
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,3 +2,7 @@
|
|||||||
10.10.10.3:1666#file#/tmp/nop
|
10.10.10.3:1666#file#/tmp/nop
|
||||||
10.10.10.3:1666#file#
|
10.10.10.3:1666#file#
|
||||||
10.10.10.3:1666#NotRealSondeName#reboot
|
10.10.10.3:1666#NotRealSondeName#reboot
|
||||||
|
10.10.10.4:1666#file#/tmp/coucou
|
||||||
|
10.10.10.4:1666#file#/tmp/nop
|
||||||
|
10.10.10.4:1666#file#
|
||||||
|
10.10.10.4:1666#NotRealSondeName#reboot
|
||||||
|
|||||||
@ -1,17 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
source $(dirname $0)/conf-client/service.cfg
|
source $(dirname $0)/conf-client/service.cfg
|
||||||
|
source $(dirname $0)/conf-client/functions
|
||||||
|
|
||||||
if [[ -z $(ps axf| grep pyhton | grep ${WebPort}) ]]
|
if [[ "$1" == "start" ]]
|
||||||
then
|
then
|
||||||
|
[[ -f /tmp/endmonitor ]] && rm -f /tmp/endmonitor
|
||||||
bash ./conf-client/webserver.sh ${WebPort} &
|
bash ./conf-client/webserver.sh ${WebPort} &
|
||||||
fi
|
|
||||||
|
|
||||||
while true
|
export TotalConfig=$(ls -1 ./conf-client | grep Card_.*\.cfg|wc -l)
|
||||||
|
for Conf in $(ls -1 ./conf-client | grep Card_.*\.cfg)
|
||||||
do
|
do
|
||||||
./conf-client/exec.sh
|
screen -dmS ${Conf} bash -x ./conf-client/exec.sh ${Conf}
|
||||||
sleep $Rotation
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" == "stop" ]]
|
||||||
|
then
|
||||||
|
killall python
|
||||||
|
rm /tmp/Monithor*
|
||||||
|
touch /tmp/endmonitor
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user