77 lines
1.2 KiB
Bash

#!/bin/bash
PrintRes() {
echo "$1"
}
CheckAllEnd() {
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
if [[ ${Total} -eq ${Actual} ]]
then
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
cat /tmp/Monithor_*-tmp >> /tmp/webmonithor
echo '
</tbody>
</table> ' >> /tmp/webmonithor
mv /tmp/webmonithor ../web/index.html
rm /tmp/Monithor_* -f
fi
fi
}
GenerateWebEnd(){
echo '<!--End of '$1' '$(pwd)'-->' >> $1
}
GenerateWeb(){
Val=$(echo $1 | cut -d"|" -f1)
Txt=$(echo $1 | cut -d"|" -f2)
Sonde=$2
Arg=$3
Remote=$4
File=$5
Color=red
[[ $Val == "0" ]] && Color=green
[[ $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}
}