이전 글의 작업으로 만든 로그 모니터링웹 화면에 아주아주 간단한 HTML을 입혀 가독성 개선
백엔드2 서버 예시
#!/bin/bash
echo "yes"
SLEEP_SECOND=3
function some_task {
echo $(date "+%Y-%m-%d %H:%M:%S") ;
}
for i in $(seq -s " " 1 ${SLEEP_SECOND} 60);do
cp /usr/local/tomcat8/logs/catalina.out /home/admin/tmp-catalina.out
sed -i'' -r -e "/2022-/a\ " /home/admin/tmp-catalina.out
#rsync /usr/local/tomcat8/logs/catalina.out admin@10.1.xx.x:/home/admin/log-fhir/fhir-log.log
rsync /home/admin/tmp-catalina.out admin@10.1.xx.x:/home/admin/log-fhir/fhir-log.log
sleep ${SLEEP_SECOND};
done
sed 명령어로 '2022-' 로 시작할 경우 줄바꿈 추가
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TEST Fhir app log</title>
<script type="text/javascript">
var xhttp;
function createHttpRequest() {
xhttp = new XMLHttpRequest();
}
function mySend() {
createHttpRequest();
xhttp.onreadystatechange = callFunction;
xhttp.open("GET", "sample.txt", true);
xhttp.send(null);
}
function callFunction(){
if(xhttp.readyState == 4 ){
if(xhttp.status == 200 ){
var responseData = xhttp.responseText;
document.getElementById("result").innerHTML = responseData;
}
}
}
</script>
</head>
<body>
<H1>📲TEST Fhir app log 불러오기</H1>
<br>
<button onclick="mySend()">get log</button>
<div>
<pre id="result"></pre>
</div>
</body>
</html>
화면
get log 버튼을 누르면 새로 파일을 읽어와서 화면 갱신
grafana같은 로그 모니터링 툴 도입이 필요할 것 같다