[UPDATE] add web server python
This commit is contained in:
parent
852c50002d
commit
9b2ae01b4a
@ -1,12 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
cd $(dirname $0)/conf-client/
|
||||
cd $(dirname $0)
|
||||
|
||||
SondeFile=$(pwd)/sonde.cfg
|
||||
source service.cfg
|
||||
source functions
|
||||
|
||||
[[ "${Crypted}" == "yes" ]] && NcCmd="timeout 0.1 cryptcat -k ${LocalPassword} ${RemoteIp} ${RemotePort} ${Udp}" || NcCmd="timeout 0.1 nc ${RemoteIp} ${RemotePort}"
|
||||
[[ "${Crypted}" == "yes" ]] && NcCmd="timeout 0.1 cryptcat -k ${LocalPassword} ${RemoteIp} ${RemotePort} " || NcCmd="timeout 0.1 nc ${RemoteIp} ${RemotePort}"
|
||||
|
||||
|
||||
while read DATA
|
||||
@ -14,12 +15,10 @@ while read DATA
|
||||
Cmd=$(echo $DATA| cut -d"#" -f1)
|
||||
Arg=$(echo $DATA| cut -d"#" -f2)
|
||||
Res=$( echo -e "${Cmd}#${Arg}" | eval ${NcCmd} 2> /dev/null)
|
||||
if [[ -z $Res ]]
|
||||
then
|
||||
echo "5|No sonde $Cmd on serveur $RemoteIp"
|
||||
else
|
||||
echo "$Res"
|
||||
fi
|
||||
Ret=$?
|
||||
PrintRes "${Res:-5|No sonde $Cmd on serveur $RemoteIp}"
|
||||
PrintWeb "${Res:-5|No sonde $Cmd on serveur $RemoteIp}" $Cmd $Arg
|
||||
done < ${SondeFile}
|
||||
PrintWeb END_DNE
|
||||
|
||||
|
||||
59
client/conf-client/functions
Normal file
59
client/conf-client/functions
Normal file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
PrintRes() {
|
||||
|
||||
echo "$1"
|
||||
|
||||
}
|
||||
|
||||
PrintWeb() {
|
||||
|
||||
if [ ! -f /tmp/webmonithor ]
|
||||
then
|
||||
echo '
|
||||
<html>
|
||||
<head>
|
||||
<title>MoniThor on '${RemoteIp}' </title>
|
||||
<meta http-equiv="refresh" content="'${Rotation}'" />
|
||||
</head>
|
||||
|
||||
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
|
||||
|
||||
fi
|
||||
|
||||
if [ "$1" == "END_DNE" ]
|
||||
then
|
||||
echo '
|
||||
|
||||
</tbody>
|
||||
</table> ' >> /tmp/webmonithor
|
||||
mv /tmp/webmonithor ../web/index.html
|
||||
|
||||
else
|
||||
|
||||
Val=$(echo $1 | cut -d"|" -f1)
|
||||
Txt=$(echo $1 | cut -d"|" -f2)
|
||||
Sonde=$2
|
||||
Arg=$3
|
||||
Color=red
|
||||
[[ $Val == "0" ]] && Color=green
|
||||
[[ $Val == "1" ]] && Color=yellow
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>'$Sonde'</td>
|
||||
<td>'$Arg'</td>
|
||||
<td style="background-color:'${Color}';" > '$Val' </td>
|
||||
<td> '$Txt'</td>
|
||||
</tr>' >> /tmp/webmonithor
|
||||
fi
|
||||
|
||||
}
|
||||
@ -2,5 +2,7 @@ RemoteIp=127.0.0.1
|
||||
RemotePort=8080
|
||||
LocalPassword='Evil@MonitoR-666'
|
||||
Crypted=no
|
||||
Rotation=1
|
||||
WebPort=8888
|
||||
|
||||
|
||||
|
||||
44
client/conf-client/webmonithor.html
Normal file
44
client/conf-client/webmonithor.html
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
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>
|
||||
5
client/conf-client/webserver.sh
Normal file
5
client/conf-client/webserver.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
pushd $(dirname $0)/../web/
|
||||
python -m SimpleHTTPServer ${1}
|
||||
|
||||
17
client/service.sh
Executable file
17
client/service.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
source $(dirname $0)/conf-client/service.cfg
|
||||
|
||||
if [[ -z $(ps axf| grep pyhton | grep ${WebPort}) ]]
|
||||
then
|
||||
bash ./conf-client/webserver.sh ${WebPort} &
|
||||
fi
|
||||
|
||||
while true
|
||||
do
|
||||
./conf-client/exec.sh
|
||||
sleep $Rotation
|
||||
done
|
||||
|
||||
|
||||
49
client/web/index.html
Normal file
49
client/web/index.html
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>MoniThor on 127.0.0.1 </title>
|
||||
<meta http-equiv="refresh" content="1" />
|
||||
</head>
|
||||
|
||||
Date : 2022-03-16 12:55:53
|
||||
|
||||
<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 style="background-color:green;" > 0 </td>
|
||||
<td> File /tmp/coucou exist</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>file</td>
|
||||
<td>/tmp/nop</td>
|
||||
<td style="background-color:red;" > 2 </td>
|
||||
<td> File /tmp/nop is NOT present</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>file</td>
|
||||
<td></td>
|
||||
<td style="background-color:red;" > 5 </td>
|
||||
<td> no argument</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>tamere</td>
|
||||
<td>reboot</td>
|
||||
<td style="background-color:red;" > 5 </td>
|
||||
<td> No sonde tamere on serveur 127.0.0.1</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
44
client/web/webmonithor.html
Normal file
44
client/web/webmonithor.html
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
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>
|
||||
@ -24,6 +24,7 @@ while true
|
||||
if [[ "${RealCmd}" == "$Sonde" ]]
|
||||
then
|
||||
logger "Exec $Exec $Arg $cpt"
|
||||
[ "$1" == '-d' ] && echo "############ Exec $Exec $Arg $cpt" 1>&2
|
||||
bash ${ScriptDir}/${Exec} $ArgCmd
|
||||
cpt=$((cpt+1))
|
||||
break
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user